python/hypothesis: update to 6.122.3
[oi-userland.git] / components / network / proftpd / patches / 004.proftpd-retry.patch
blob0eb06518ac0ee687bccd47d2976e2de314a93498
2 # This is the patch, which seems to appear and disappear with
3 # every upgrade of proftpd. It first disappeared with
4 # integration of CR 23124279 [1] (ProFTPd: Update to 1.3.5b).
5 # The upgrade removed the earlier fix for 15744390 [2].
6 # This omission got fixed by CR 23536514, which re-adds the patch.
8 # The history repeats with upgrade to 1.3.6 [4], which is going
9 # to be fixed by current CR [5]. This time I've submitted also
10 # a pull request [6], so we will know for sure whether the change
11 # also got accepted by upstream or not.
13 # For 1.3.6 we also must increase number of connect(2) attempts
14 # in case of connect(2) fails with EADDRINUSE
16 # [1] https://bug.oraclecorp.com/pls/bug/webbug_print.show?c_rptno=23124279
17 # [2] https://bug.oraclecorp.com/pls/bug/webbug_print.show?c_rptno=15744390
18 # [3] https://bug.oraclecorp.com/pls/bug/webbug_print.show?c_rptno=23536514
19 # [4] https://bug.oraclecorp.com/pls/bug/webbug_print.show?c_rptno=27889131
20 # [5] https://bug.oraclecorp.com/pls/bug/webbug_print.show?c_rptno=30009346
21 # [6] https://github.com/proftpd/proftpd/pull/812
22 # [7] https://bug.oraclecorp.com/pls/bug/webbug_print.show?c_rptno=30216085
25 diff --git a/src/data.c b/src/data.c
26 index 05b3a34d8..5b3f923a1 100644
27 --- a/src/data.c
28 +++ b/src/data.c
29 @@ -213,6 +213,7 @@ static int data_passive_open(const char *reason, off_t size) {
30 static int data_active_open(const char *reason, off_t size) {
31 conn_t *c;
32 int bind_port, rev;
33 + int retries = 0;
34 const pr_netaddr_t *bind_addr = NULL;
35 unsigned char *root_revoke = NULL;
37 @@ -268,6 +269,7 @@ static int data_active_open(const char *reason, off_t size) {
41 + for(;;) { /* begin of endless loop */
42 session.d = pr_inet_create_conn(session.pool, -1, bind_addr, bind_port, TRUE);
43 if (session.d == NULL) {
44 int xerrno = errno;
45 @@ -309,7 +311,7 @@ static int data_active_open(const char *reason, off_t size) {
46 pr_inet_set_socket_opts(session.d->pool, session.d,
47 (main_server->tcp_rcvbuf_override ? main_server->tcp_rcvbuf_len : 0), 0,
48 main_server->tcp_keepalive);
51 } else {
52 pr_inet_set_socket_opts(session.d->pool, session.d,
53 0, (main_server->tcp_sndbuf_override ? main_server->tcp_sndbuf_len : 0),
54 @@ -328,6 +330,13 @@ static int data_active_open(const char *reason, off_t size) {
55 session.data_port) < 0) {
56 int xerrno = session.d->xerrno;
58 + if (xerrno == EADDRINUSE && retries < 42) {
59 + destroy_pool(session.d->pool);
60 + pr_signals_handle();
61 + /* Wait up to MSL to avoid TIME_WAIT. */
62 + sleep(retries++);
63 + continue; /* continue in endless loop */
64 + }
65 pr_log_debug(DEBUG6,
66 "Error connecting to %s#%u for active data transfer: %s",
67 pr_netaddr_get_ipstr(&session.data_addr), session.data_port,
68 @@ -340,7 +349,8 @@ static int data_active_open(const char *reason, off_t size) {
70 errno = xerrno;
71 return -1;
72 - }
73 + } else break; /* finish the endless loop */
74 + } /* end of endless loop */
76 c = pr_inet_openrw(session.pool, session.d, NULL, PR_NETIO_STRM_DATA,
77 session.d->listen_fd, -1, -1, TRUE);