From 02cd2ad53c7c1c11d919b8a1290432a2e9cf5f24 Mon Sep 17 00:00:00 2001 From: stefanocasazza Date: Thu, 5 Feb 2015 20:04:40 +0100 Subject: [PATCH] fix bug on partial response (extended) --- src/ulib/net/server/client_image.cpp | 13 ++++++++++++- src/ulib/net/server/plugin/mod_nocat.cpp | 1 + src/ulib/utility/socket_ext.cpp | 4 ++-- tests/examples/TSA/CA/tsaserial | 1 - tests/ulib/inp/test.db | Bin 4096 -> 0 bytes 5 files changed, 15 insertions(+), 4 deletions(-) delete mode 100644 tests/examples/TSA/CA/tsaserial delete mode 100644 tests/ulib/inp/test.db diff --git a/src/ulib/net/server/client_image.cpp b/src/ulib/net/server/client_image.cpp index ffb91e63..e1d008ce 100644 --- a/src/ulib/net/server/client_image.cpp +++ b/src/ulib/net/server/client_image.cpp @@ -1392,6 +1392,8 @@ bool UClientImage_Base::writeResponse() U_RETURN(true); } + int idx = 0, iovcnt = 4; + loop: if (iBytesWrite > 0) { @@ -1413,7 +1415,16 @@ loop: { if (UNotifier::waitForWrite(socket->iSockDesc, U_TIMEOUT_MS) != 1) U_RETURN(false); - iBytesWrite = USocketExt::writev(socket, iov_vec, 4, ncount, UServer_Base::timeoutMS); + while (iov_vec[idx].iov_len == 0) + { + ++idx; + --iovcnt; + + U_INTERNAL_ASSERT_MINOR(idx, 4) + U_INTERNAL_ASSERT_MAJOR(iovcnt, 0) + } + + iBytesWrite = USocketExt::writev(socket, iov_vec+idx, iovcnt, ncount, UServer_Base::timeoutMS); if (LIKELY(iBytesWrite == (int)ncount)) { diff --git a/src/ulib/net/server/plugin/mod_nocat.cpp b/src/ulib/net/server/plugin/mod_nocat.cpp index 0aae1a9c..37d0c2de 100644 --- a/src/ulib/net/server/plugin/mod_nocat.cpp +++ b/src/ulib/net/server/plugin/mod_nocat.cpp @@ -651,6 +651,7 @@ int UNoCatPlugIn::handlerTime() UTimeVal::setSecond(next_event_time); } + // --------------- // return value: // --------------- // -1 - normal diff --git a/src/ulib/utility/socket_ext.cpp b/src/ulib/utility/socket_ext.cpp index cdc6f429..896af5de 100644 --- a/src/ulib/utility/socket_ext.cpp +++ b/src/ulib/utility/socket_ext.cpp @@ -439,8 +439,6 @@ error: U_INTERNAL_DUMP("errno = %d", errno) iov[idx].iov_len = 0; ++idx; - - U_INTERNAL_ASSERT_MINOR(idx, iovcnt) } U_INTERNAL_DUMP("iov[%d].iov_len = %d", idx, iov[idx].iov_len) @@ -453,6 +451,8 @@ error: U_INTERNAL_DUMP("errno = %d", errno) iov += idx; iovcnt -= idx; + U_INTERNAL_ASSERT_MAJOR(iovcnt, 0) + timeoutMS = 0; goto write; diff --git a/tests/examples/TSA/CA/tsaserial b/tests/examples/TSA/CA/tsaserial deleted file mode 100644 index 0baf9488..00000000 --- a/tests/examples/TSA/CA/tsaserial +++ /dev/null @@ -1 +0,0 @@ -B0D1 diff --git a/tests/ulib/inp/test.db b/tests/ulib/inp/test.db deleted file mode 100644 index 9bf470eb621a7222427d1a8b2c236512f3750426..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4096 zcmeHJze~eF6u!%qwhA3f*5}lgrjV-y#HlI;hYJ2Eh?AV{sfU-OUan%@y14j{2>uK1 zUHW%8IlJiKC1A0Fv((-rcX{t6dGE`|`{0faIzn?ek5$MttfL&l7_|Tpdip@fgfr_X z&p_E?q^|A-&pg5D@fd(x? zQ;dZJ@FEs+Q~FjzO-%iQ>$-SMGZe#wt0dcUb2zfp??7g)AuD~uRPU0hDs67mX0V{P z@8sQj9iL>Kl51&1bDHq$A&+|eM@Z(n|9DtUn|S8Sni+!ozvU23DJrG2XjD!nWU}aE zY4KYImXv|KlmGg2iVN$N)z-?|d-t*a(DZ50@S6=k02*vke>3oRxs)+fj$