winbindd: verify that client has closed the connection
authorUri Simchoni <urisimchoni@gmail.com>
Thu, 25 Jun 2015 07:12:37 +0000 (10:12 +0300)
committerJeremy Allison <jra@samba.org>
Wed, 15 Jul 2015 20:41:13 +0000 (22:41 +0200)
A recent change was to remove a client if the client socket
has become readable. In this change, a check is added to
determine the source of the readbility (actual readability,
closed connection, or some other error), and a suitable
debug message is printed.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11397

Signed-off-by: Uri Simchoni <urisimchoni@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/winbindd/winbindd.c

index 07faadf7be1f822074504e53882e59a15c64149d..fb47781bdb093fb16473e4418047efc5ccd85211 100644 (file)
@@ -973,7 +973,7 @@ static void winbind_client_request_read(struct tevent_req *req)
        }
 
        req = wait_for_read_send(state, winbind_event_context(), state->sock,
-                                false);
+                                true);
        if (req == NULL) {
                DEBUG(0, ("winbind_client_request_read[%d:%s]:"
                          " wait_for_read_send failed - removing client\n",
@@ -992,8 +992,28 @@ static void winbind_client_activity(struct tevent_req *req)
        struct winbindd_cli_state *state =
            tevent_req_callback_data(req, struct winbindd_cli_state);
        int err;
+       bool has_data;
 
-       wait_for_read_recv(req, &err);
+       has_data = wait_for_read_recv(req, &err);
+
+       if (has_data) {
+               DEBUG(0, ("winbind_client_activity[%d:%s]:"
+                         "unexpected data from client - removing client\n",
+                         (int)state->pid, state->cmd_name));
+       } else {
+               if (err == EPIPE) {
+                       DEBUG(6, ("winbind_client_activity[%d:%s]: "
+                                 "client has closed connection - removing "
+                                 "client\n",
+                                 (int)state->pid, state->cmd_name));
+               } else {
+                       DEBUG(2, ("winbind_client_activity[%d:%s]: "
+                                 "client socket error (%s) - removing "
+                                 "client\n",
+                                 (int)state->pid, state->cmd_name,
+                                 strerror(err)));
+               }
+       }
 
        remove_client(state);
 }