Index: nsock/src/engine_epoll.c =================================================================== --- nsock/src/engine_epoll.c (revision 29137) +++ nsock/src/engine_epoll.c (working copy) @@ -230,16 +230,10 @@ epev.events |= EPOLL_X_FLAGS; sd = nsi_getsd(iod); - if (epoll_ctl(einfo->epfd, EPOLL_CTL_MOD, sd, &epev) < 0) { - if (errno == ENOENT) { - /* This IOD is registered but its associated fd is not in the epoll set. - * It was probably closed and another one was open (e.g.: reconnect operation). - * We therefore want to add the new one. */ - epoll_ctl(einfo->epfd, EPOLL_CTL_ADD, sd, &epev); - } else { - fatal("Unable to update events for IOD #%lu: %s", iod->id, strerror(errno)); - } - } + + if (epoll_ctl(einfo->epfd, EPOLL_CTL_MOD, sd, &epev) < 0) + fatal("Unable to update events for IOD #%lu: %s", iod->id, strerror(errno)); + return 1; } Index: nsock/src/engine_select.c =================================================================== --- nsock/src/engine_select.c (revision 29137) +++ nsock/src/engine_select.c (working copy) @@ -208,8 +208,10 @@ { CHECKED_FD_CLR(iod->sd, &sinfo->fds_master_r); CHECKED_FD_CLR(iod->sd, &sinfo->fds_master_w); + CHECKED_FD_CLR(iod->sd, &sinfo->fds_master_x); CHECKED_FD_CLR(iod->sd, &sinfo->fds_results_r); CHECKED_FD_CLR(iod->sd, &sinfo->fds_results_w); + CHECKED_FD_CLR(iod->sd, &sinfo->fds_results_x); } if (sinfo->max_sd == iod->sd) Index: nsock/src/nsock_core.c =================================================================== --- nsock/src/nsock_core.c (revision 29137) +++ nsock/src/nsock_core.c (working copy) @@ -462,6 +462,8 @@ socket_count_write_inc(iod); update_events(iod, ms, EV_WRITE, EV_NONE); } else if (!(options & SSL_OP_NO_SSLv2)) { + int saved_ev; + /* SSLv3-only and TLSv1-only servers can't be connected to when the * SSL_OP_NO_SSLv2 option is not set, which is the case when the pool * was initialized with nsp_ssl_init_max_speed. Try reconnecting with @@ -469,8 +471,13 @@ * might use SSLv2. */ if (ms->tracelevel > 0) nsock_trace(ms, "EID %li reconnecting with SSL_OP_NO_SSLv2", nse->id); + + saved_ev = iod->watched_events; + ms->engine->iod_unregister(ms, iod); close(iod->sd); nsock_connect_internal(ms, nse, iod->lastproto, &iod->peer, iod->peerlen, nsi_peerport(iod)); + ms->engine->iod_register(ms, iod, saved_ev); + SSL_clear(iod->ssl); if(!SSL_clear(iod->ssl)) fatal("SSL_clear failed: %s", ERR_error_string(ERR_get_error(), NULL));