aboutsummaryrefslogtreecommitdiff
path: root/libsylph/socket.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-11-26 03:01:23 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-11-26 03:01:23 +0000
commit3d6d522c1bd157b3a0d3f3c2df549ff886f03828 (patch)
tree25a32c89c30336962b0060d2c98ddd6f181e9247 /libsylph/socket.c
parent050ce4e2bc694290e771574a4d48e723b7a8488f (diff)
sock_connect_with_timeout(): check socket with getsockopt() even if select() succeed.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2355 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/socket.c')
-rw-r--r--libsylph/socket.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libsylph/socket.c b/libsylph/socket.c
index f28c8136..a3ad08b4 100644
--- a/libsylph/socket.c
+++ b/libsylph/socket.c
@@ -667,12 +667,25 @@ static gint sock_connect_with_timeout(gint sock,
errno = ETIMEDOUT;
return -1;
} else {
+ gint val;
+ guint len;
+
if (FD_ISSET(sock, &fds)) {
ret = 0;
} else {
debug_print("sock_connect_with_timeout: fd not set\n");
return -1;
}
+
+ len = sizeof(val);
+ if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &val, &len) < 0) {
+ perror("sock_connect_with_timeout: getsockopt");
+ return -1;
+ }
+ if (val != 0) {
+ debug_print("sock_connect_with_timeout: getsockopt(SOL_SOCKET, SO_ERROR) returned error: %s\n", g_strerror(val));
+ return -1;
+ }
}
} else {
perror("sock_connect_with_timeout: connect");