Mercurial > hg
comparison mcabber/connwrap/connwrap.c @ 409:82064124324d
Fix a SIGPIPE issue when connecting to the server
This change fixes a SIGPIPE when cw_nb_connect() is called too fast after
make_nb_netsocket(). In this case getsockopt() reports a wrong value (no
error) and the first jab_send_raw() in jconn.c gets a SIGPIPE.
The delay in jabglue.c can then be removed.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 27 Aug 2005 22:20:03 +0200 |
parents | e536ab271584 |
children | ec86d759ed54 |
comparison
equal
deleted
inserted
replaced
408:73433860665c | 409:82064124324d |
---|---|
323 #endif | 323 #endif |
324 if ( !(*state & CW_CONNECT_WANT_SOMETHING)) | 324 if ( !(*state & CW_CONNECT_WANT_SOMETHING)) |
325 rc = connect(sockfd, serv_addr, addrlen); | 325 rc = connect(sockfd, serv_addr, addrlen); |
326 else{ /* check if the socket is connected correctly */ | 326 else{ /* check if the socket is connected correctly */ |
327 int optlen = sizeof(int), optval; | 327 int optlen = sizeof(int), optval; |
328 fd_set fds; | |
329 struct timeval tv; | |
330 | |
331 FD_ZERO(&fds); | |
332 FD_SET(sockfd, &fds); | |
333 | |
334 tv.tv_sec = 0; | |
335 tv.tv_usec = 10000; | |
336 | |
337 if (select(sockfd+1, 0, &fds, 0, &tv) < 1) | |
338 return -1; | |
328 if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &optval, (socklen_t*)&optlen) || optval) | 339 if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &optval, (socklen_t*)&optlen) || optval) |
329 return -1; | 340 return -1; |
330 *state = 0; | 341 *state = 0; |
331 return 0; | 342 return 0; |
332 } | 343 } |