]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: threads/fd: Initialize the process mask during the call to fd_insert
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 30 May 2017 09:07:16 +0000 (11:07 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 12:58:30 +0000 (13:58 +0100)
Listeners will allow any threads to process the corresponding fd. But for other
FDs, we limit the processing to the current thread.

include/proto/connection.h
include/proto/fd.h
src/dns.c
src/haproxy.c
src/hathreads.c
src/proto_tcp.c
src/proto_uxst.c
src/ssl_sock.c

index 7060046b82f890d7b04ff1fc5b7e32926b8553c4..ecba6dddcc7df99eb13122abe96ad11b57e4dfb6 100644 (file)
@@ -110,7 +110,7 @@ static inline void conn_ctrl_init(struct connection *conn)
 
                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);
index 465d6601a8fe11ca0379469b8727a98167ce34ab..72af70fa9232fe9981b1066896dad0d6c9018c86 100644 (file)
@@ -395,7 +395,7 @@ static inline void fd_update_events(int fd, int evts)
 }
 
 /* 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 @@ static inline void fd_insert(int fd)
        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);
index 2d684b060e53b69b94db33528bf851d3bc342283..c2b87c015b82ce4d46342b034b53e9c566c9c086 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -193,7 +193,7 @@ static int dns_connect_namesaver(struct dns_nameserver *ns)
        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;
 }
index 7f485148b2e429faf85156ef0cd2ee45b32cc035..170b002e393a191faf195db1f740eae440f1bea9 100644 (file)
@@ -2228,7 +2228,7 @@ void mworker_pipe_register(int pipefd[2])
        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]);
 }
 
index 4c795b12411a20518e84a5e72f05f6fd79c5fcbe..470ee023df521114fe245e9a8350a1d8a713772f 100644 (file)
@@ -50,7 +50,7 @@ int thread_sync_init(unsigned long mask)
 
        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;
index b43fdef59ba39f676a1521a207468c3aedaad63d..1a26bcc47b74e80f18794c169b34a695de8a9cbd 100644 (file)
@@ -1107,7 +1107,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
 
        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) {
index 4210f5d20247d0187923dc9bca2550120aadadff..fc4a5197169b3c4c1c9c1f8995a68eaaa9a0eeb8 100644 (file)
@@ -332,9 +332,9 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
        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:
index 68f5d252b5ae853a36ff3cf47c15ce4527e7f1e7..ca9647d365213c0b42c8d3face1f21ecf4f4f15a 100644 (file)
@@ -459,7 +459,7 @@ static void inline ssl_async_process_fds(struct connection *conn, SSL *ssl)
                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;