Skip to content

Commit 2ae1e8b

Browse files
committed
CDRIVER-788: Return how many bytes we wrote.
If a iovec is to large to send over sendmsg()/WSASend() we get [WSA]EMSGSIZE and hit the _slow version and try to send() it instead. Wether or not we finish writing the entire thing (say, hit [WSA]EWOULDBLOCK) we must return how much we actually wrote so we can resume from the correct location once _mongoc_socket_wait() finishes (e.g. poll(POLLOUT) succeeds) and we have enough socketTimeoutMS left to continue writing
1 parent ef9aaf2 commit 2ae1e8b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/mongoc/mongoc-socket.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,9 +900,9 @@ mongoc_socket_send (mongoc_socket_t *sock, /* IN */
900900
* _mongoc_socket_try_sendv_slow --
901901
*
902902
* A slow variant of _mongoc_socket_try_sendv() that sends each
903-
* iovec entry one by one. This can happen if we hit EMSGSIZE on
904-
* with sendmsg() on various POSIX systems (such as Solaris), or
905-
* on WinXP.
903+
* iovec entry one by one. This can happen if we hit EMSGSIZE
904+
* with sendmsg() on various POSIX systems or WSASend()+WSAEMSGSIZE
905+
* on Windows.
906906
*
907907
* Returns:
908908
* the number of bytes sent or -1 and errno is set.
@@ -1018,7 +1018,7 @@ _mongoc_socket_try_sendv (mongoc_socket_t *sock, /* IN */
10181018
#else
10191019
if ((ret == -1) && (errno == EMSGSIZE)) {
10201020
#endif
1021-
_mongoc_socket_try_sendv_slow (sock, iov, iovcnt);
1021+
RETURN(_mongoc_socket_try_sendv_slow (sock, iov, iovcnt));
10221022
}
10231023

10241024
_mongoc_socket_capture_errno (sock);

0 commit comments

Comments
 (0)