Skip to content

Commit

Permalink
trying to understand jeromelebel/MongoHub-Mac#126
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérôme Lebel committed Oct 8, 2014
1 parent 321af77 commit 903a92a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/mongoc/mongoc-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,26 @@ mongoc_socket_recv (mongoc_socket_t *sock, /* IN */
if (failed && try_again) {
if (_mongoc_socket_wait (sock->sd, POLLIN, expire_at)) {
GOTO (again);
} else {
int optval;
socklen_t optlen = sizeof optval;

if (getsockopt (sock->sd, SOL_SOCKET, SO_ERROR,
&optval, &optlen) == 0 &&
optval != 0) {
MONGOC_WARNING("previous error %d\n", sock->errno_);
sock->errno_ = optval;
}
}
}

if (failed) {
char errmsg[32];

bson_strerror_r (mongoc_socket_errno (sock), errmsg, sizeof errmsg);
MONGOC_WARNING ("Socket read error: %d, %s",
mongoc_socket_errno (sock),
errmsg);
RETURN (-1);
}

Expand Down

0 comments on commit 903a92a

Please sign in to comment.