From: Alex Rousskov Date: Sun, 2 May 2010 01:37:34 +0000 (-0600) Subject: Added comm_import_opened() to update Comm state after getting a comm_open() X-Git-Tag: SQUID_3_2_0_1~93^2~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a4c0f9c619693286df1427ec4242f59281fa8ece;p=thirdparty%2Fsquid.git Added comm_import_opened() to update Comm state after getting a comm_open() FD from another process. While both FDs point to the same kernel object, Squid internal tables are local to each process and need to be maintained separately. --- diff --git a/src/comm.cc b/src/comm.cc index d5b5ceb972..100541683c 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -849,6 +849,47 @@ comm_apply_flags(int new_socket, return new_socket; } +void +comm_import_opened(int fd, + IpAddress &addr, + int flags, + const char *note, + struct addrinfo *AI) +{ + debugs(5, 2, HERE << " FD " << fd << " at " << addr); + assert(fd >= 0); + assert(AI); + + comm_init_opened(fd, addr, 0, note, AI); + + if (!(flags & COMM_NOCLOEXEC)) + fd_table[fd].flags.close_on_exec = 1; + + if (addr.GetPort() > (u_short) 0) { +#ifdef _SQUID_MSWIN_ + if (sock_type != SOCK_DGRAM) +#endif + fd_table[fd].flags.nolinger = 1; + } + + if ((flags & COMM_TRANSPARENT)) + fd_table[fd].flags.transparent = 1; + + if (flags & COMM_NONBLOCKING) + fd_table[fd].flags.nonblocking = 1; + +#ifdef TCP_NODELAY + if (AI->ai_socktype == SOCK_STREAM) + fd_table[fd].flags.nodelay = 1; +#endif + + /* no fd_table[fd].flags. updates needed for these conditions: + * if ((flags & COMM_REUSEADDR)) ... + * if ((flags & COMM_DOBIND) ...) ... + */ +} + + CBDATA_CLASS_INIT(ConnectStateData); void * diff --git a/src/comm.h b/src/comm.h index 4e289d98a5..145a4fba05 100644 --- a/src/comm.h +++ b/src/comm.h @@ -56,6 +56,8 @@ SQUIDCEXTERN void comm_exit(void); SQUIDCEXTERN int comm_open(int, int, IpAddress &, int, const char *note); SQUIDCEXTERN int comm_open_uds(int sock_type, int proto, struct sockaddr_un* addr, int flags); +/// update tables after getting a comm_open() FD from another strand +SQUIDCEXTERN void comm_import_opened(int fd, IpAddress &addr, int flags, const char *note, struct addrinfo *AI); /** * Open a port specially bound for listening or sending through a specific port.