From 6b87b25a0edc2b0bb6e1fb2205813b113a2332aa Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Sat, 18 Jun 2016 19:30:04 +0200 Subject: [PATCH 2/2] UTIL: Revent connection handling in sssd_async_connect_send Even though the connect() man page says waiting on a non-blocking connect should be done by checking for writability, we need to check also for readability. Otherwise it slightly break offline mode. Changing password in offline mode is not supported by sssd and error message "System is offline, password change not possible" is printed. However without TEVENT_FD_READ for connect it takes much longer when sssd finds out that it cannot connect to a server. It fails after expiration of timeout (6 seconds). But meanwhile "passwd user" finished without logging the offline message. With TEVENT_FD_READ, connect fails much faster with errno 113/No route to host. The change was introduced in the commit e05d3f5872263aadfbc2f6a2a8c9735219922387 --- src/util/sss_sockets.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/util/sss_sockets.c b/src/util/sss_sockets.c index 67db80850f7a2348900003fe0d0244de46fcfc25..5e9be9ebd11d94bdd3f107f793f3e5438b26cd6b 100644 --- a/src/util/sss_sockets.c +++ b/src/util/sss_sockets.c @@ -142,7 +142,15 @@ struct tevent_req *sssd_async_connect_send(TALLOC_CTX *mem_ctx, switch (ret) { case EINPROGRESS: case EINTR: - state->fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE, + + /* Despite the connect() man page says waiting on a non-blocking + * connect should be done by checking for writability, we need to check + * also for readability. + * With TEVENT_FD_READ, connect fails much faster in offline mode with + * errno 113/No route to host. + */ + state->fde = tevent_add_fd(ev, state, fd, + TEVENT_FD_READ | TEVENT_FD_WRITE, sssd_async_connect_done, req); if (state->fde == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, "tevent_add_fd failed.\n"); -- 2.7.4