From bdadcaf271818e88e56e86c2bd90663a08fd9721 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Sat, 18 Jun 2016 19:30:04 +0200 Subject: 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 Reviewed-by: Simo Sorce --- src/util/sss_sockets.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/util') diff --git a/src/util/sss_sockets.c b/src/util/sss_sockets.c index 67db80850..5e9be9ebd 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"); -- cgit