@@ -167,6 +167,7 @@ _mongoc_socket_wait (int sd, /* IN */
167
167
} else if (ret < 0 ) {
168
168
/* poll itself failed */
169
169
170
+ TRACE ("errno is: %d" , errno );
170
171
if (MONGOC_ERRNO_IS_AGAIN (errno )) {
171
172
now = bson_get_monotonic_time ();
172
173
@@ -342,6 +343,7 @@ _mongoc_socket_capture_errno (mongoc_socket_t *sock) /* IN */
342
343
#else
343
344
sock -> errno_ = errno ;
344
345
#endif
346
+ TRACE ("setting errno: %d" , sock -> errno_ );
345
347
}
346
348
347
349
@@ -365,6 +367,7 @@ _mongoc_socket_capture_errno (mongoc_socket_t *sock) /* IN */
365
367
static bool
366
368
_mongoc_socket_errno_is_again (mongoc_socket_t * sock ) /* IN */
367
369
{
370
+ TRACE ("errno is: %d" , sock -> errno_ );
368
371
return MONGOC_ERRNO_IS_AGAIN (sock -> errno_ );
369
372
}
370
373
@@ -437,7 +440,6 @@ mongoc_socket_accept_ex (mongoc_socket_t *sock, /* IN */
437
440
sd = accept (sock -> sd , (struct sockaddr * ) & addr , & addrlen );
438
441
439
442
_mongoc_socket_capture_errno (sock );
440
-
441
443
#ifdef _WIN32
442
444
failed = (sd == INVALID_SOCKET );
443
445
#else
@@ -801,7 +803,6 @@ mongoc_socket_recv (mongoc_socket_t *sock, /* IN */
801
803
{
802
804
ssize_t ret = 0 ;
803
805
bool failed = false;
804
- bool try_again = false;
805
806
806
807
ENTRY ;
807
808
@@ -820,11 +821,8 @@ mongoc_socket_recv (mongoc_socket_t *sock, /* IN */
820
821
#endif
821
822
if (failed ) {
822
823
_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 )) {
828
826
GOTO (again );
829
827
}
830
828
}
@@ -1025,27 +1023,30 @@ _mongoc_socket_try_sendv (mongoc_socket_t *sock, /* IN */
1025
1023
ret = sendmsg (sock -> sd , & msg ,
1026
1024
# ifdef MSG_NOSIGNAL
1027
1025
MSG_NOSIGNAL );
1028
- #else
1026
+ # else
1029
1027
0 );
1030
1028
# endif
1031
1029
#endif
1032
1030
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
+ */
1039
1041
#ifdef _WIN32
1040
- if (( ret == -1 ) && (errno == WSAEMSGSIZE ) ) {
1042
+ if (errno == WSAEMSGSIZE ) {
1041
1043
#else
1042
- if (( ret == -1 ) && (errno == EMSGSIZE ) ) {
1044
+ if (errno == EMSGSIZE ) {
1043
1045
#endif
1044
- RETURN (_mongoc_socket_try_sendv_slow (sock , iov , iovcnt ));
1046
+ RETURN (_mongoc_socket_try_sendv_slow (sock , iov , iovcnt ));
1047
+ }
1045
1048
}
1046
1049
1047
- _mongoc_socket_capture_errno (sock );
1048
-
1049
1050
RETURN (ret );
1050
1051
}
1051
1052
0 commit comments