From: Amos Jeffries Date: Thu, 31 Dec 2009 04:07:20 +0000 (+1300) Subject: Remove last remaining legacy functions and fdc_table dregs X-Git-Tag: SQUID_3_2_0_1~468^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=273f66c4b9f8e6e5d14b36028e70e6e022500c0b;p=thirdparty%2Fsquid.git Remove last remaining legacy functions and fdc_table dregs --- diff --git a/src/comm.cc b/src/comm.cc index 5a297df815..3492488354 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1522,9 +1522,6 @@ _comm_close(int fd, char const *file, int line) commio_finish_callback(fd, COMMIO_FD_READCB(fd), COMM_ERR_CLOSING, errno); } - // Listening FD need to be closed by deleting their ListenStateData object. - assert(Comm::CurrentListenerSockets[fd] == NULL); - commCallCloseHandlers(fd); if (F->pconn.uses) @@ -1837,9 +1834,6 @@ comm_init(void) fd_table =(fde *) xcalloc(Squid_MaxFD, sizeof(fde)); fdd_table = (fd_debug_t *)xcalloc(Squid_MaxFD, sizeof(fd_debug_t)); - /* make sure we have an empty listening socket map */ - Comm::CurrentListenerSockets.clear(); - /* make sure the accept() socket FIFO delay queue exists */ Comm::AcceptLimiter::Instance(); @@ -1871,7 +1865,6 @@ comm_exit(void) safe_free(fd_table); safe_free(fdd_table); - Comm::CurrentListenerSockets.clear(); safe_free(commfd_table); } diff --git a/src/comm/ListenStateData.cc b/src/comm/ListenStateData.cc index 9d8dd0693f..7fca3f673b 100644 --- a/src/comm/ListenStateData.cc +++ b/src/comm/ListenStateData.cc @@ -41,24 +41,6 @@ #include "fde.h" #include "SquidTime.h" -/* - * This is not strictly needed at all. - * It's only needed by the cachemgr interface to list the currently active sockets. - * which could be done for HTTP/HTTPS by listing the http_port_list->listener->fd - * BUT, FTP data connections is a bit of a problem. - * - * AYJ: for now the old way of doing Comm:: actions sequentially in some caller - * requires this to anchor each of those Comm:: functions together. - */ -std::map Comm::CurrentListenerSockets; - -/** - * Set of listener sockets which are known to have events pending but we - * do not have enough sockets available to do the accept just yet. - */ -//std::list Comm::PendingAccepts; - - /** * New-style listen and accept routines * @@ -66,52 +48,37 @@ std::map Comm::CurrentListenerSockets; * and accept takes a callback to call when an FD has been * accept()ed. */ -int -Comm::comm_listen(int sock) +void +Comm::ListenStateData::setListen() { int x; - if ((x = listen(sock, Squid_MaxFD >> 2)) < 0) { - debugs(50, 0, HERE << "listen(" << (Squid_MaxFD >> 2) << ", " << sock << "): " << xstrerror()); - return x; + if ((x = listen(fd, Squid_MaxFD >> 2)) < 0) { + debugs(50, 0, HERE << "listen(FD " << fd << ", " << (Squid_MaxFD >> 2) << "): " << xstrerror()); + errcode = x; + return; } if (Config.accept_filter && strcmp(Config.accept_filter, "none") != 0) { #ifdef SO_ACCEPTFILTER struct accept_filter_arg afa; bzero(&afa, sizeof(afa)); - debugs(5, DBG_IMPORTANT, "Installing accept filter '" << Config.accept_filter << "' on FD " << sock); + debugs(5, DBG_IMPORTANT, "Installing accept filter '" << Config.accept_filter << "' on FD " << fd); xstrncpy(afa.af_name, Config.accept_filter, sizeof(afa.af_name)); - x = setsockopt(sock, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa)); + x = setsockopt(fd, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa)); if (x < 0) debugs(5, DBG_CRITICAL, "SO_ACCEPTFILTER '" << Config.accept_filter << "': '" << xstrerror()); #elif defined(TCP_DEFER_ACCEPT) int seconds = 30; if (strncmp(Config.accept_filter, "data=", 5) == 0) seconds = atoi(Config.accept_filter + 5); - x = setsockopt(sock, IPPROTO_TCP, TCP_DEFER_ACCEPT, &seconds, sizeof(seconds)); + x = setsockopt(fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &seconds, sizeof(seconds)); if (x < 0) debugs(5, DBG_CRITICAL, "TCP_DEFER_ACCEPT '" << Config.accept_filter << "': '" << xstrerror()); #else debugs(5, DBG_CRITICAL, "accept_filter not supported on your OS"); #endif } - - return sock; -} - -// TODO make this a constructor of ListenStateData... -// better yet convert the places its used to setup AsyncCalls instead... -Comm::ListenStateData * -Comm::comm_accept(int fd, IOACB *handler, void *handler_data) -{ - debugs(5, 5, HERE << "FD " << fd << " handler: " << (void*)handler); - assert(isOpen(fd)); - - AsyncCall::Pointer call = commCbCall(5,5, "SomeCommAcceptHandler", - CommAcceptCbPtrFun(handler, handler_data)); - - return new Comm::ListenStateData(fd, call, false); } Comm::ListenStateData::ListenStateData(int aFd, AsyncCall::Pointer &call, bool accept_many) : @@ -122,20 +89,12 @@ Comm::ListenStateData::ListenStateData(int aFd, AsyncCall::Pointer &call, bool a assert(aFd >= 0); debugs(5, 5, HERE << "FD " << fd << " AsyncCall: " << call); assert(isOpen(aFd)); - - CurrentListenerSockets[fd] = this; - - errcode = comm_listen(fd); + setListen(); commSetSelect(fd, COMM_SELECT_READ, doAccept, this, 0); } Comm::ListenStateData::~ListenStateData() { - // un-register listener before closing the FD. - // TODO: is this the right way to remove from a std::map<> ? - if (CurrentListenerSockets[fd]) - CurrentListenerSockets[fd] = NULL; - comm_close(fd); fd = -1; } @@ -251,8 +210,8 @@ Comm::ListenStateData::notify(int newfd, comm_err_t errcode, int xerrno, const C /** * accept() and process - * Wait for an incoming connection on FD. FD should be a socket returned - * from comm_listen. */ + * Wait for an incoming connection on FD. + */ int Comm::ListenStateData::oldAccept(ConnectionDetail &details) { diff --git a/src/comm/ListenStateData.h b/src/comm/ListenStateData.h index f43997eeea..a349d648b1 100644 --- a/src/comm/ListenStateData.h +++ b/src/comm/ListenStateData.h @@ -45,13 +45,9 @@ private: AsyncCall::Pointer theCallback; bool mayAcceptMore; -}; - -extern std::map CurrentListenerSockets; -// remaining legacy functions. TODO replace all uses with the ListenData constructor -extern int comm_listen(int fd); -extern ListenStateData *comm_accept(int fd, IOACB *handler, void *handler_data); + void setListen(); +}; }; // namespace Comm