@@ -975,6 +975,31 @@ mongoc_socket_sendv (mongoc_socket_t *sock, /* IN */
975
975
if (sent > 0 ) {
976
976
ret += sent ;
977
977
mongoc_counter_streams_egress_add (sent );
978
+
979
+ /*
980
+ * Subtract the sent amount from what we still need to send.
981
+ */
982
+ while ((cur < iovcnt ) && (sent >= (ssize_t )iov [cur ].iov_len )) {
983
+ sent -= iov [cur ++ ].iov_len ;
984
+ }
985
+
986
+ /*
987
+ * Check if that made us finish all of the iovecs. If so, we are done
988
+ * sending data over the socket.
989
+ */
990
+ if (cur == iovcnt ) {
991
+ break ;
992
+ }
993
+
994
+ /*
995
+ * Increment the current iovec buffer to its proper offset and adjust
996
+ * the number of bytes to write.
997
+ */
998
+ iov [cur ].iov_base = ((char * )iov [cur ].iov_base ) + sent ;
999
+ iov [cur ].iov_len -= sent ;
1000
+
1001
+ BSON_ASSERT (iovcnt - cur );
1002
+ BSON_ASSERT (iov [cur ].iov_len );
978
1003
} else if (OPERATION_EXPIRED (expire_at )) {
979
1004
#ifdef _WIN32
980
1005
errno = WSAETIMEDOUT ;
@@ -984,31 +1009,6 @@ mongoc_socket_sendv (mongoc_socket_t *sock, /* IN */
984
1009
RETURN (ret ? ret : -1 );
985
1010
}
986
1011
987
- /*
988
- * Subtract the sent amount from what we still need to send.
989
- */
990
- while ((cur < iovcnt ) && (sent >= (ssize_t )iov [cur ].iov_len )) {
991
- sent -= iov [cur ++ ].iov_len ;
992
- }
993
-
994
- /*
995
- * Check if that made us finish all of the iovecs. If so, we are done
996
- * sending data over the socket.
997
- */
998
- if (cur == iovcnt ) {
999
- break ;
1000
- }
1001
-
1002
- /*
1003
- * Increment the current iovec buffer to its proper offset and adjust
1004
- * the number of bytes to write.
1005
- */
1006
- iov [cur ].iov_base = ((char * )iov [cur ].iov_base ) + sent ;
1007
- iov [cur ].iov_len -= sent ;
1008
-
1009
- BSON_ASSERT (iovcnt - cur );
1010
- BSON_ASSERT (iov [cur ].iov_len );
1011
-
1012
1012
/*
1013
1013
* Block on poll() until our desired condition is met.
1014
1014
*/
0 commit comments