]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: fd: Set owner and iocb field before inserting a new fd in the fdtab
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 5 Sep 2017 07:51:57 +0000 (09:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 5 Sep 2017 08:17:10 +0000 (10:17 +0200)
This will be needed for concurrent accesses.

include/proto/connection.h
src/dns.c

index 9be862b40c8ffcd5de11911c33947263683da7c3..2ec2ef8b11b58f93b131da885418f96ac87f95c7 100644 (file)
@@ -108,12 +108,12 @@ static inline void conn_ctrl_init(struct connection *conn)
        if (!conn_ctrl_ready(conn)) {
                int fd = conn->handle.fd;
 
+               fdtab[fd].owner = conn;
+               fdtab[fd].iocb = conn_fd_handler;
                fd_insert(fd);
                /* mark the fd as ready so as not to needlessly poll at the beginning */
                fd_may_recv(fd);
                fd_may_send(fd);
-               fdtab[fd].owner = conn;
-               fdtab[fd].iocb = conn_fd_handler;
                conn->flags |= CO_FL_CTRL_READY;
        }
 }
index 2cf1ec954aea2a0b4e14e71e33cd5fdc9efabc8e..d96c91d5657e579e36af1c77c8ecf73495d3c749 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -1721,9 +1721,9 @@ int dns_init_resolvers(int close_socket)
                        fcntl(fd, F_SETFL, O_NONBLOCK);
 
                        /* add the fd in the fd list and update its parameters */
-                       fd_insert(fd);
                        fdtab[fd].owner = dgram;
                        fdtab[fd].iocb = dgram_fd_handler;
+                       fd_insert(fd);
                        fd_want_recv(fd);
                        dgram->t.sock.fd = fd;