MEDIUM: threads/fd: Initialize the process mask during the call to fd_insert
Listeners will allow any threads to process the corresponding fd. But for other
FDs, we limit the processing to the current thread.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index 7060046..ecba6dd 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -110,7 +110,7 @@
fdtab[fd].owner = conn;
fdtab[fd].iocb = conn_fd_handler;
- fd_insert(fd);
+ fd_insert(fd, tid_bit);
/* mark the fd as ready so as not to needlessly poll at the beginning */
fd_may_recv(fd);
fd_may_send(fd);
diff --git a/include/proto/fd.h b/include/proto/fd.h
index 465d660..72af70f 100644
--- a/include/proto/fd.h
+++ b/include/proto/fd.h
@@ -395,7 +395,7 @@
}
/* Prepares <fd> for being polled */
-static inline void fd_insert(int fd)
+static inline void fd_insert(int fd, unsigned long thread_mask)
{
SPIN_LOCK(FD_LOCK, &fdtab[fd].lock);
fdtab[fd].ev = 0;
@@ -404,7 +404,7 @@
fdtab[fd].linger_risk = 0;
fdtab[fd].cloned = 0;
fdtab[fd].cache = 0;
- fdtab[fd].process_mask = 0; // unused for now
+ fdtab[fd].process_mask = thread_mask;
SPIN_UNLOCK(FD_LOCK, &fdtab[fd].lock);
SPIN_LOCK(FDTAB_LOCK, &fdtab_lock);
diff --git a/src/dns.c b/src/dns.c
index 2d684b0..c2b87c0 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -193,7 +193,7 @@
dgram->t.sock.fd = fd;
fdtab[fd].owner = dgram;
fdtab[fd].iocb = dgram_fd_handler;
- fd_insert(fd);
+ fd_insert(fd, (unsigned long)-1);
fd_want_recv(fd);
return 0;
}
diff --git a/src/haproxy.c b/src/haproxy.c
index 7f48514..170b002 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -2228,7 +2228,7 @@
fcntl(mworker_pipe[0], F_SETFL, O_NONBLOCK);
fdtab[mworker_pipe[0]].owner = mworker_pipe;
fdtab[mworker_pipe[0]].iocb = mworker_pipe_handler;
- fd_insert(mworker_pipe[0]);
+ fd_insert(mworker_pipe[0], MAX_THREADS_MASK);
fd_want_recv(mworker_pipe[0]);
}
diff --git a/src/hathreads.c b/src/hathreads.c
index 4c795b1..470ee02 100644
--- a/src/hathreads.c
+++ b/src/hathreads.c
@@ -50,7 +50,7 @@
fdtab[rfd].owner = NULL;
fdtab[rfd].iocb = thread_sync_io_handler;
- fd_insert(rfd);
+ fd_insert(rfd, MAX_THREADS_MASK);
all_threads_mask = mask;
return 0;
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index b43fdef..1a26bcc 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -1107,7 +1107,7 @@
fdtab[fd].owner = listener; /* reference the listener instead of a task */
fdtab[fd].iocb = listener->proto->accept;
- fd_insert(fd);
+ fd_insert(fd, MAX_THREADS_MASK);
tcp_return:
if (msg && errlen) {
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index 4210f5d..fc4a519 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -332,9 +332,9 @@
listener->state = LI_LISTEN;
/* the function for the accept() event */
- fd_insert(fd);
fdtab[fd].iocb = listener->proto->accept;
fdtab[fd].owner = listener; /* reference the listener instead of a task */
+ fd_insert(fd, MAX_THREADS_MASK);
return err;
err_rename:
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index 68f5d25..ca9647d 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -459,7 +459,7 @@
afd = add_fd[i];
fdtab[afd].owner = conn;
fdtab[afd].iocb = ssl_async_fd_handler;
- fd_insert(afd);
+ fd_insert(afd, tid_bit);
}
num_add_fds = 0;