summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-10-02 12:20:26 +0200
committerAndrew Bartlett <abartlet@samba.org>2012-10-23 14:44:21 +0200
commitd2aa785290a283e06624f22a381a7ea02baae5ad (patch)
tree311b93ecf2b63179b2b512e5f78c83072d697190 /lib
parent7138b2138ba1f67386c6aa1e1c5ef49fde07cc41 (diff)
downloadsamba-d2aa785290a283e06624f22a381a7ea02baae5ad.tar.gz
samba-d2aa785290a283e06624f22a381a7ea02baae5ad.tar.bz2
samba-d2aa785290a283e06624f22a381a7ea02baae5ad.zip
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 <abartlet@samba.org> Autobuild-Date(master): Tue Oct 23 14:44:21 CEST 2012 on sn-devel-104
Diffstat (limited to 'lib')
-rw-r--r--lib/tsocket/tsocket_bsd.c10
1 files changed, 9 insertions, 1 deletions
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 */