From d2aa785290a283e06624f22a381a7ea02baae5ad Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 2 Oct 2012 12:20:26 +0200 Subject: lib/tsocket: fix loop in tdgram_bsd_recvfrom() (bug #9184) If the socket is not readable yet, we need to retry if tsocket_bsd_pending() returns 0. See also https://lists.samba.org/archive/samba-technical/2012-October/087164.html metze Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Tue Oct 23 14:44:21 CEST 2012 on sn-devel-104 --- lib/tsocket/tsocket_bsd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c index d5721b4d94..135fd027aa 100644 --- a/lib/tsocket/tsocket_bsd.c +++ b/lib/tsocket/tsocket_bsd.c @@ -792,7 +792,7 @@ static int tdgram_bsd_set_writeable_handler(struct tdgram_bsd *bsds, struct tdgram_bsd_recvfrom_state { struct tdgram_context *dgram; - + bool first_try; uint8_t *buf; size_t len; struct tsocket_address *src; @@ -826,6 +826,7 @@ static struct tevent_req *tdgram_bsd_recvfrom_send(TALLOC_CTX *mem_ctx, } state->dgram = dgram; + state->first_try= true; state->buf = NULL; state->len = 0; state->src = NULL; @@ -876,6 +877,13 @@ static void tdgram_bsd_recvfrom_handler(void *private_data) bool retry; ret = tsocket_bsd_pending(bsds->fd); + if (state->first_try && ret == 0) { + state->first_try = false; + /* retry later */ + return; + } + state->first_try = false; + err = tsocket_bsd_error_from_errno(ret, errno, &retry); if (retry) { /* retry later */ -- cgit