Comm::TcpAcceptor creates a Comm::Connection with an open FD. Lots of
things could go wrong while that connection object travels to its
intended owner (e.g., Ftp::Server). A Connection object abandoned during
that travel will auto-close, triggering level-4 "BUG #3329" messages.
TODO: The manual enter/leaveOrphanage() tracking is unreliable. We need
to design and implement a true connection ownership concept that does
not require such tracking. These changes highlight handover spots.
Also made a few TcpAcceptor members protected to reduce the chance of
missing a Connection recipient (i.e. TcpAcceptor subscriber). Most of
these members should be (at least) protected for other reasons as well.
assert(aCloser != NULL);
conn = newConn;
+ conn->leaveOrphanage();
closer = aCloser;
comm_add_close_handler(conn->fd, closer);
}
// so we end up with a uniform "(HTTP|FTP-data|HTTPS|...) remote-ip:remote-port"
fd_open(sock, FD_SOCKET, "HTTP Request");
details->fd = sock;
+ details->enterOrphanage();
details->remote = *gai;
TcpAcceptor(const Comm::ConnectionPointer &conn, const char *note, const Subscription::Pointer &aSub);
TcpAcceptor(const AnyP::PortCfgPointer &listenPort, const char *note, const Subscription::Pointer &aSub);
+protected:
/** Subscribe a handler to receive calls back about new connections.
* Unsubscribes any existing subscribed handler.
*/
/// if not the accept() will be postponed
static bool okToAccept();
-protected:
friend class AcceptLimiter;
private:
} else {
closeDataConnection();
dataConn = params.conn;
+ dataConn->leaveOrphanage();
uploadAvailSize = 0;
debugs(33, 7, "ready for data");
if (onDataAcceptCall != NULL) {
transferProtocol(xact->squidPort->transport),
port(xact->squidPort),
receivedFirstByte_(false)
-{}
+{
+ clientConnection->leaveOrphanage();
+}
bool
Server::doneAll() const