diff options
author | Lukas Slebodnik <lslebodn@redhat.com> | 2016-06-18 19:30:04 +0200 |
---|---|---|
committer | Lukas Slebodnik <lslebodn@redhat.com> | 2016-06-28 17:34:10 +0200 |
commit | bdadcaf271818e88e56e86c2bd90663a08fd9721 (patch) | |
tree | a9fc9306f733f8d5b42e6552415e4b19cd1be504 | |
parent | 3108e0cce47ee168b86ac0de1deccee7e7f09119 (diff) | |
download | sssd-bdadcaf271818e88e56e86c2bd90663a08fd9721.tar.gz sssd-bdadcaf271818e88e56e86c2bd90663a08fd9721.tar.xz sssd-bdadcaf271818e88e56e86c2bd90663a08fd9721.zip |
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 <simo@redhat.com>
-rw-r--r-- | src/util/sss_sockets.c | 10 |
1 files changed, 9 insertions, 1 deletions
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"); |