From fe0b8a5df42109dee44743e29c2e6e42565ff5c5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 18 May 2007 05:47:33 +0000 Subject: r22987: Clarify how the events are handled in the kerberos code, and standardise with the rest of the code. Andrew Bartlett (This used to be commit 3aa9d70723d4377d29e33281b640499193b06c69) --- source4/auth/kerberos/krb5_init_context.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'source4/auth') diff --git a/source4/auth/kerberos/krb5_init_context.c b/source4/auth/kerberos/krb5_init_context.c index 9eccd459fa..ba1455c227 100644 --- a/source4/auth/kerberos/krb5_init_context.c +++ b/source4/auth/kerberos/krb5_init_context.c @@ -176,21 +176,27 @@ static void smb_krb5_socket_handler(struct event_context *ev, struct fd_event *f struct smb_krb5_socket *smb_krb5 = talloc_get_type(private, struct smb_krb5_socket); switch (smb_krb5->hi->proto) { case KRB5_KRBHST_UDP: - if (flags & EVENT_FD_WRITE) { - smb_krb5_socket_send(smb_krb5); - } if (flags & EVENT_FD_READ) { smb_krb5_socket_recv(smb_krb5); + return; } - break; + if (flags & EVENT_FD_WRITE) { + smb_krb5_socket_send(smb_krb5); + return; + } + /* not reached */ + return; case KRB5_KRBHST_TCP: if (flags & EVENT_FD_READ) { packet_recv(smb_krb5->packet); + return; } if (flags & EVENT_FD_WRITE) { packet_queue_run(smb_krb5->packet); + return; } - break; + /* not reached */ + return; case KRB5_KRBHST_HTTP: /* can't happen */ break; @@ -277,9 +283,14 @@ krb5_error_code smb_krb5_send_and_recv_func(krb5_context context, } talloc_free(remote_addr); + /* Setup the FDE, start listening for read events + * from the start (otherwise we may miss a socket + * drop) and mark as AUTOCLOSE along with the fde */ + + /* Ths is equivilant to EVENT_FD_READABLE(smb_krb5->fde) */ smb_krb5->fde = event_add_fd(ev, smb_krb5->sock, socket_get_fd(smb_krb5->sock), - EVENT_FD_AUTOCLOSE, + EVENT_FD_READ|EVENT_FD_AUTOCLOSE, smb_krb5_socket_handler, smb_krb5); /* its now the job of the event layer to close the socket */ socket_set_flags(smb_krb5->sock, SOCKET_FLAG_NOCLOSE); @@ -316,7 +327,6 @@ krb5_error_code smb_krb5_send_and_recv_func(krb5_context context, RSIVAL(smb_krb5->request.data, 0, send_blob.length); memcpy(smb_krb5->request.data+4, send_blob.data, send_blob.length); packet_send(smb_krb5->packet, smb_krb5->request); - EVENT_FD_READABLE(smb_krb5->fde); break; case KRB5_KRBHST_HTTP: talloc_free(smb_krb5); -- cgit