@@ -167,6 +167,7 @@ _mongoc_socket_wait (int sd, /* IN */
167167 } else if (ret < 0 ) {
168168 /* poll itself failed */
169169
170+ TRACE ("errno is: %d" , errno );
170171 if (MONGOC_ERRNO_IS_AGAIN (errno )) {
171172 now = bson_get_monotonic_time ();
172173
@@ -342,6 +343,7 @@ _mongoc_socket_capture_errno (mongoc_socket_t *sock) /* IN */
342343#else
343344 sock -> errno_ = errno ;
344345#endif
346+ TRACE ("setting errno: %d" , sock -> errno_ );
345347}
346348
347349
@@ -365,6 +367,7 @@ _mongoc_socket_capture_errno (mongoc_socket_t *sock) /* IN */
365367static bool
366368_mongoc_socket_errno_is_again (mongoc_socket_t * sock ) /* IN */
367369{
370+ TRACE ("errno is: %d" , sock -> errno_ );
368371 return MONGOC_ERRNO_IS_AGAIN (sock -> errno_ );
369372}
370373
@@ -437,7 +440,6 @@ mongoc_socket_accept_ex (mongoc_socket_t *sock, /* IN */
437440 sd = accept (sock -> sd , (struct sockaddr * ) & addr , & addrlen );
438441
439442 _mongoc_socket_capture_errno (sock );
440-
441443#ifdef _WIN32
442444 failed = (sd == INVALID_SOCKET );
443445#else
@@ -801,7 +803,6 @@ mongoc_socket_recv (mongoc_socket_t *sock, /* IN */
801803{
802804 ssize_t ret = 0 ;
803805 bool failed = false;
804- bool try_again = false;
805806
806807 ENTRY ;
807808
@@ -820,11 +821,8 @@ mongoc_socket_recv (mongoc_socket_t *sock, /* IN */
820821#endif
821822 if (failed ) {
822823 _mongoc_socket_capture_errno (sock );
823- }
824- try_again = (failed && _mongoc_socket_errno_is_again (sock ));
825-
826- if (failed && try_again ) {
827- if (_mongoc_socket_wait (sock -> sd , POLLIN , expire_at )) {
824+ if (_mongoc_socket_errno_is_again (sock ) &&
825+ _mongoc_socket_wait (sock -> sd , POLLIN , expire_at )) {
828826 GOTO (again );
829827 }
830828 }
@@ -1025,27 +1023,30 @@ _mongoc_socket_try_sendv (mongoc_socket_t *sock, /* IN */
10251023 ret = sendmsg (sock -> sd , & msg ,
10261024# ifdef MSG_NOSIGNAL
10271025 MSG_NOSIGNAL );
1028- #else
1026+ # else
10291027 0 );
10301028# endif
10311029#endif
10321030
1033- TRACE ("Send %ld out of %ld bytes (errno=%d)" , ret , iov -> iov_len , errno );
1034- /*
1035- * Check to see if we have sent an iovec too large for sendmsg to
1036- * complete. If so, we need to fallback to the slow path of multiple
1037- * send() commands.
1038- */
1031+ TRACE ("Send %ld out of %ld bytes" , ret , iov -> iov_len );
1032+
1033+ if (ret == -1 ) {
1034+ _mongoc_socket_capture_errno (sock );
1035+
1036+ /*
1037+ * Check to see if we have sent an iovec too large for sendmsg to
1038+ * complete. If so, we need to fallback to the slow path of multiple
1039+ * send() commands.
1040+ */
10391041#ifdef _WIN32
1040- if (( ret == -1 ) && (errno == WSAEMSGSIZE ) ) {
1042+ if (errno == WSAEMSGSIZE ) {
10411043#else
1042- if (( ret == -1 ) && (errno == EMSGSIZE ) ) {
1044+ if (errno == EMSGSIZE ) {
10431045#endif
1044- RETURN (_mongoc_socket_try_sendv_slow (sock , iov , iovcnt ));
1046+ RETURN (_mongoc_socket_try_sendv_slow (sock , iov , iovcnt ));
1047+ }
10451048 }
10461049
1047- _mongoc_socket_capture_errno (sock );
1048-
10491050 RETURN (ret );
10501051}
10511052
0 commit comments