summarylogtreecommitdiffstats
path: root/0013-server-error-on-connect-to-zero.patch
diff options
context:
space:
mode:
authormoonshadow5652023-12-27 21:50:38 +0100
committermoonshadow5652023-12-27 21:50:38 +0100
commit6f12e53ef7823ae62a0c8e3f4d12505b23dcf399 (patch)
treed65c8954c620fb02c666e05c185f8bcdc5a2f080 /0013-server-error-on-connect-to-zero.patch
parent8838ef4292aa0d05eb2ef35efae954b9ea6fae47 (diff)
downloadaur-6f12e53ef7823ae62a0c8e3f4d12505b23dcf399.tar.gz
cleaner fix for slow start
Diffstat (limited to '0013-server-error-on-connect-to-zero.patch')
-rw-r--r--0013-server-error-on-connect-to-zero.patch26
1 files changed, 26 insertions, 0 deletions
diff --git a/0013-server-error-on-connect-to-zero.patch b/0013-server-error-on-connect-to-zero.patch
new file mode 100644
index 000000000000..ee68329f98d3
--- /dev/null
+++ b/0013-server-error-on-connect-to-zero.patch
@@ -0,0 +1,26 @@
+diff --git a/server/sock.c b/server/sock.c
+index 84c0d4a4931..b33d06aa706 100644
+--- a/server/sock.c
++++ b/server/sock.c
+@@ -2647,6 +2647,21 @@ static void sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
+ if (unix_addr.addr.sa_family == AF_INET && !memcmp( &unix_addr.in.sin_addr, magic_loopback_addr, 4 ))
+ unix_addr.in.sin_addr.s_addr = htonl( INADDR_LOOPBACK );
+
++ /* NOTE: winsock treats 0.0.0.0 address as special case error. */
++ /* TODO: this should also work for AF_INET6, AF_IPX, AF_... */
++ if (unix_addr.addr.sa_family == AF_INET && unix_addr.in.sin_addr.s_addr == 0 && unix_addr.in.sin_port == 0)
++ {
++ /* TODO: Microsoft docs mention that socket can not be connect-ed after this.
++ * Maybe shutdown and transition to special state for this? */
++ sock->errors[AFD_POLL_BIT_CONNECT_ERR] = EADDRNOTAVAIL;
++ set_error( sock_get_ntstatus( EADDRNOTAVAIL ) );
++ post_socket_event( sock, AFD_POLL_BIT_CONNECT_ERR );
++
++ /* NOTE: Some applications rely on this behaviour as a mechanism to abort select from another thread. */
++ async_wake_up( &sock->poll_q, STATUS_SUCCESS );
++ return;
++ }
++
+ memcpy( &peer_addr, &unix_addr, sizeof(unix_addr) );
+ ret = connect( unix_fd, &unix_addr.addr, unix_len );
+ if (ret < 0 && errno == ECONNABORTED)