=== modified file 'src/comm/ListenStateData.cc' --- src/comm/ListenStateData.cc 2010-07-25 08:10:12 +0000 +++ src/comm/ListenStateData.cc 2010-08-03 08:25:52 +0000 @@ -45,9 +45,9 @@ /** * New-style listen and accept routines * - * Listen simply registers our interest in an FD for listening, - * and accept takes a callback to call when an FD has been - * accept()ed. + * setListen simply registers our interest in an FD for listening. + * The constructor takes a callback to call when an FD has been + * accept()ed some time later. */ void Comm::ListenStateData::setListen() @@ -166,7 +166,7 @@ // A non-recoverable error; notify the caller */ debugs(5, 5, HERE << "non-recoverable error: FD " << fd << " handler: " << theCallback); - notify(-1, COMM_ERROR, errno, connDetails); + notify(-1, COMM_ERROR, connDetails); mayAcceptMore = false; return; } @@ -174,7 +174,7 @@ debugs(5, 5, HERE << "accepted: FD " << fd << " newfd: " << newfd << " from: " << connDetails.peer << " handler: " << theCallback); - notify(newfd, COMM_OK, 0, connDetails); + notify(newfd, COMM_OK, connDetails); } void @@ -186,11 +186,11 @@ } void -Comm::ListenStateData::notify(int newfd, comm_err_t errcode, int xerrno, const ConnectionDetail &connDetails) +Comm::ListenStateData::notify(int newfd, comm_err_t flag, const ConnectionDetail &connDetails) { // listener socket handlers just abandon the port with COMM_ERR_CLOSING // it should only happen when this object is deleted... - if (errcode == COMM_ERR_CLOSING) { + if (flag == COMM_ERR_CLOSING) { return; } @@ -200,8 +200,8 @@ params.fd = fd; params.nfd = newfd; params.details = connDetails; - params.flag = errcode; - params.xerrno = xerrno; + params.flag = flag; + params.xerrno = errcode; ScheduleCallHere(theCallback); if (!mayAcceptMore) theCallback = NULL; @@ -221,8 +221,11 @@ struct addrinfo *gai = NULL; details.me.InitAddrInfo(gai); + errcode = errno = 0; // reset errno and local copy. if ((sock = accept(fd, gai->ai_addr, &gai->ai_addrlen)) < 0) { + errcode = errno; // store last accept errno locally. + details.me.FreeAddrInfo(gai); PROF_stop(comm_accept); === modified file 'src/comm/ListenStateData.h' --- src/comm/ListenStateData.h 2010-07-07 00:45:34 +0000 +++ src/comm/ListenStateData.h 2010-08-02 06:27:26 +0000 @@ -23,7 +23,7 @@ void subscribe(AsyncCall::Pointer &call); void acceptNext(); - void notify(int newfd, comm_err_t, int xerrno, const ConnectionDetail &); + void notify(int newfd, comm_err_t flag, const ConnectionDetail &details); int fd;