From df3b01e5d8dc3ef99bf54acae1073940272b74a5 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 19 Jan 2012 00:03:40 +0000 Subject: [PATCH] Use the right errno in handle_connect_result catch-all assert. We call getsockopt(SO_ERROR) to get the socket error, but then we were calling perror, which uses the global errno instead. --- nsock/src/nsock_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nsock/src/nsock_core.c b/nsock/src/nsock_core.c index afe890de2..0de8c6b48 100644 --- a/nsock/src/nsock_core.c +++ b/nsock/src/nsock_core.c @@ -312,7 +312,6 @@ static int iod_add_event(msiod *iod, msevent *nse) { void handle_connect_result(mspool *ms, msevent *nse, enum nse_status status) { int optval; socklen_t optlen = sizeof(int); - char buf[1024]; msiod *iod = nse->iod; #if HAVE_OPENSSL int sslerr; @@ -360,9 +359,8 @@ void handle_connect_result(mspool *ms, msevent *nse, enum nse_status status) { nse->errnum = optval; break; default: - Snprintf(buf, sizeof(buf), "Strange connect error from %s (%d)", - inet_ntop_ez(&iod->peer, iod->peerlen), optval); - perror(buf); + fprintf(stderr, "Strange connect error from %s (%d): %s", + inet_ntop_ez(&iod->peer, iod->peerlen), optval, socket_strerror(optval)); assert(0); /* I'd like for someone to report it */ break; }