}
-Ipc::SharedListenResponse::SharedListenResponse(const Comm::ConnectionPointer &c, int anErrNo, int aMapId):
- conn(c), errNo(anErrNo), mapId(aMapId)
+Ipc::SharedListenResponse::SharedListenResponse(int aFd, int anErrNo, int aMapId):
+ fd(aFd), errNo(anErrNo), mapId(aMapId)
{
}
Ipc::SharedListenResponse::SharedListenResponse(const TypedMsgHdr &hdrMsg):
- conn(NULL), errNo(0), mapId(-1)
+ fd(-1), errNo(0), mapId(-1)
{
hdrMsg.checkType(mtSharedListenResponse);
hdrMsg.getPod(*this);
- conn = new Comm::Connection;
- conn->fd = hdrMsg.getFd();
+ fd = hdrMsg.getFd();
// other conn details are passed in OpenListenerParams and filled out by SharedListenJoin()
}
{
hdrMsg.setType(mtSharedListenResponse);
hdrMsg.putPod(*this);
- hdrMsg.putFd(conn->fd);
+ hdrMsg.putFd(fd);
}
void Ipc::SharedListenJoined(const SharedListenResponse &response)
{
- Comm::ConnectionPointer c = response.conn;
-
// Dont debugs c fully since only FD is filled right now.
- debugs(54, 3, HERE << "got listening FD " << c->fd << " errNo=" <<
+ debugs(54, 3, HERE << "got listening FD " << response.fd << " errNo=" <<
response.errNo << " mapId=" << response.mapId);
Must(TheSharedListenRequestMap.find(response.mapId) != TheSharedListenRequestMap.end());
Must(por.callback != NULL);
TheSharedListenRequestMap.erase(response.mapId);
- if (Comm::IsConnOpen(c)) {
+ StartListeningCb *cbd = dynamic_cast<StartListeningCb*>(por.callback->getDialer());
+ assert(cbd && cbd->conn != NULL);
+ Must(cbd && cbd->conn != NULL);
+ cbd->conn->fd = response.fd;
+
+ if (Comm::IsConnOpen(cbd->conn)) {
OpenListenerParams &p = por.params;
- c->local = p.addr;
- c->flags = p.flags;
+ cbd->conn->local = p.addr;
+ cbd->conn->flags = p.flags;
// XXX: leave the comm AI stuff to comm_import_opened()?
struct addrinfo *AI = NULL;
p.addr.GetAddrInfo(AI);
AI->ai_socktype = p.sock_type;
AI->ai_protocol = p.proto;
- comm_import_opened(c, FdNote(p.fdNote), AI);
+ comm_import_opened(cbd->conn, FdNote(p.fdNote), AI);
p.addr.FreeAddrInfo(AI);
}
- StartListeningCb *cbd = dynamic_cast<StartListeningCb*>(por.callback->getDialer());
- Must(cbd);
- cbd->conn = c;
cbd->errNo = response.errNo;
cbd->handlerSubscription = por.params.handlerSubscription;
ScheduleCallHere(por.callback);
class SharedListenResponse
{
public:
- SharedListenResponse(const Comm::ConnectionPointer &c, int errNo, int mapId);
+ SharedListenResponse(int fd, int errNo, int mapId);
explicit SharedListenResponse(const TypedMsgHdr &hdrMsg); ///< from recvmsg()
void pack(TypedMsgHdr &hdrMsg) const; ///< prepare for sendmsg()
public:
- Comm::ConnectionPointer conn; ///< opened listening socket or -1
+ int fd; ///< opened listening socket or -1
int errNo; ///< errno value from comm_open_sharedListen() call
int mapId; ///< to map future response to the requestor's callback
};
Ipc::StartListening(int sock_type, int proto, const Comm::ConnectionPointer &listenConn,
FdNoteId fdNote, AsyncCall::Pointer &callback)
{
+ StartListeningCb *cbd = dynamic_cast<StartListeningCb*>(callback->getDialer());
+ Must(cbd);
+ cbd->conn = listenConn;
+
if (UsingSmp()) { // if SMP is on, share
OpenListenerParams p;
p.sock_type = sock_type;
return; // wait for the call back
}
- StartListeningCb *cbd = dynamic_cast<StartListeningCb*>(callback->getDialer());
- Must(cbd);
- cbd->conn = listenConn;
-
enter_suid();
comm_open_listener(sock_type, proto, cbd->conn, FdNote(fdNote));
cbd->errNo = Comm::IsConnOpen(cbd->conn) ? 0 : errno;