diff options
-rw-r--r-- | src/library.js | 12 | ||||
-rw-r--r-- | tests/websockets_partial.c | 3 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js index aa93598e..6c2702ba 100644 --- a/src/library.js +++ b/src/library.js @@ -7053,6 +7053,13 @@ LibraryManager.library = { Module.print('recv: ' + [Array.prototype.slice.call(buffer)]); #endif if (len < buffer.length) { + if (info.stream) { + // This is tcp (reliable), so if not all was read, keep it + info.inQueue.unshift(buffer.subarray(len)); +#if SOCKET_DEBUG + Module.print('recv: put back: ' + (len - buffer.length)); +#endif + } buffer = buffer.subarray(0, len); } HEAPU8.set(buffer, buf); @@ -7151,7 +7158,10 @@ LibraryManager.library = { if (info.stream) { // This is tcp (reliable), so if not all was read, keep it if (bufferPos < bytes) { - info.inQueue.unshift(buffer.subArray(bufferPos)); + info.inQueue.unshift(buffer.subarray(bufferPos)); +#if SOCKET_DEBUG + Module.print('recvmsg: put back: ' + (bytes - bufferPos)); +#endif } } return ret; diff --git a/tests/websockets_partial.c b/tests/websockets_partial.c index deacdb6b..f71160b7 100644 --- a/tests/websockets_partial.c +++ b/tests/websockets_partial.c @@ -46,6 +46,8 @@ void iter(void *arg) { packetLength = buffer[0]; n = recv(SocketFD, buffer, packetLength, 0); + printf("got %d,%d\n", n, packetLength); + if (n != packetLength) { fprintf(stderr, "lost packet data, expected: %d readed: %d", packetLength, n); exit(EXIT_FAILURE); @@ -66,6 +68,7 @@ void iter(void *arg) { done = 1; #if EMSCRIPTEN + printf("sum: %d\n", sum); int result = sum; REPORT_RESULT(); #endif |