1 |
From b863a62ef2c1e71f3cdf4c74994369baa45dbce7 Mon Sep 17 00:00:00 2001 |
2 |
From: Ralph Boehme <slow@samba.org> |
3 |
Date: Wed, 3 Aug 2016 15:00:45 +0200 |
4 |
Subject: [PATCH] async_req: make async_connect_send() "reentrant" |
5 |
MIME-Version: 1.0 |
6 |
Content-Type: text/plain; charset=UTF-8 |
7 |
Content-Transfer-Encoding: 8bit |
8 |
|
9 |
Allow callers to pass in socket fds that where already passed to an |
10 |
earlier call of async_connect_send(). Callers expect this behaviour and |
11 |
it was working until 05d4dbda8357712cb81008e0d611fdb0e7239587 broke it. |
12 |
|
13 |
The proper fix would be to change callers to close the fd and start from |
14 |
scratch with a fresh socket. |
15 |
|
16 |
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12105 |
17 |
|
18 |
Signed-off-by: Ralph Boehme <slow@samba.org> |
19 |
Reviewed-by: Jeremy Allison <jra@samba.org> |
20 |
|
21 |
Autobuild-User(master): Ralph Böhme <slow@samba.org> |
22 |
Autobuild-Date(master): Thu Aug 4 05:03:21 CEST 2016 on sn-devel-144 |
23 |
|
24 |
(cherry picked from commit 9c6a4ea2788808bdcc7bfea798d838ea56c3b5ec) |
25 |
--- |
26 |
lib/async_req/async_sock.c | 16 +++++++++++++--- |
27 |
1 file changed, 13 insertions(+), 3 deletions(-) |
28 |
|
29 |
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c |
30 |
index c14acf3..3af1748 100644 |
31 |
--- a/lib/async_req/async_sock.c |
32 |
+++ b/lib/async_req/async_sock.c |
33 |
@@ -128,11 +128,21 @@ struct tevent_req *async_connect_send( |
34 |
} |
35 |
|
36 |
/* |
37 |
- * The only errno indicating that the connect is still in |
38 |
- * flight is EINPROGRESS, everything else is an error |
39 |
+ * The only errno indicating that an initial connect is still |
40 |
+ * in flight is EINPROGRESS. |
41 |
+ * |
42 |
+ * We get EALREADY when someone calls us a second time for a |
43 |
+ * given fd and the connect is still in flight (and returned |
44 |
+ * EINPROGRESS the first time). |
45 |
+ * |
46 |
+ * This allows callers like open_socket_out_send() to reuse |
47 |
+ * fds and call us with an fd for which the connect is still |
48 |
+ * in flight. The proper thing to do for callers would be |
49 |
+ * closing the fd and starting from scratch with a fresh |
50 |
+ * socket. |
51 |
*/ |
52 |
|
53 |
- if (errno != EINPROGRESS) { |
54 |
+ if (errno != EINPROGRESS && errno != EALREADY) { |
55 |
tevent_req_error(req, errno); |
56 |
return tevent_req_post(req, ev); |
57 |
} |
58 |
-- |
59 |
2.7.4 |
60 |
|