1 # name : bugfix48929.patch
2 # introduced : 11 or before
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
13 AC_CHECK_HEADERS(fcntl.h fenv.h float.h floatingpoint.h fpu_control.h \
14 - ieeefp.h limits.h memory.h pwd.h select.h \
15 + ieeefp.h limits.h memory.h pwd.h select.h poll.h \
17 strings.h string.h synch.h sys/mman.h sys/socket.h netinet/in.h arpa/inet.h \
18 sys/timeb.h sys/types.h sys/un.h sys/vadvise.h sys/wait.h term.h \
22 #include "sp_rcontext.h"
29 #define mysqld_charset &my_charset_latin1
32 @@ -5137,31 +5141,58 @@
33 #ifndef EMBEDDED_LIBRARY
34 pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused)))
36 - my_socket sock,new_sock;
37 + my_socket UNINIT_VAR(sock),new_sock;
39 - uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
40 - fd_set readFDs,clientFDs;
42 struct sockaddr_in cAddr;
43 - int ip_flags=0,socket_flags=0,flags;
44 +#if !defined(HAVE_POLL)
47 +#if defined(HAVE_SYS_UN_H) && !defined(HAVE_POLL)
48 + int socket_flags= 0;
50 + int UNINIT_VAR(flags),retval;
53 + int socket_count= 0;
54 + struct pollfd fds[2]; // for ip_sock and unix_sock
56 + fd_set readFDs,clientFDs;
57 + uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
60 DBUG_ENTER("handle_connections_sockets");
64 (void) my_pthread_getprio(pthread_self()); // For debugging
70 if (ip_sock != INVALID_SOCKET)
73 + fds[socket_count].fd= ip_sock;
74 + fds[socket_count].events= POLLIN;
77 FD_SET(ip_sock,&clientFDs);
80 +#if !defined (HAVE_POLL) && defined(HAVE_FCNTL)
81 ip_flags = fcntl(ip_sock, F_GETFL, 0);
86 + fds[socket_count].fd= unix_sock;
87 + fds[socket_count].events= POLLIN;
90 FD_SET(unix_sock,&clientFDs);
93 +#if defined(HAVE_FCNTL) && defined(HAVE_SYS_UN_H) && !defined(HAVE_POLL)
94 socket_flags=fcntl(unix_sock, F_GETFL, 0);
97 @@ -5170,12 +5201,15 @@
103 - if (select(max_used_connection,(int*) &readFDs,0,0,0) < 0)
106 + retval= poll(fds, socket_count, -1);
108 - if (select((int) max_used_connection,&readFDs,0,0,0) < 0)
111 + retval= select((int) max_used_connection,&readFDs,0,0,0);
116 if (socket_errno != SOCKET_EINTR)
118 @@ -5185,7 +5219,7 @@
126 MAYBE_BROKEN_SYSCALL;
127 @@ -5193,6 +5227,21 @@
130 /* Is this a new connection request ? */
132 + for (int i= 0; i < socket_count; ++i)
134 + if (fds[i].revents & POLLIN)
138 + flags= fcntl(sock, F_GETFL, 0);
141 +#endif // HAVE_FCNTL
147 if (FD_ISSET(unix_sock,&readFDs))
149 @@ -5200,11 +5249,12 @@
154 +#endif // HAVE_SYS_UN_H
161 #if !defined(NO_FCNTL_NONBLOCK)
162 if (!(test_flags & TEST_BLOCKING))