当前位置: 首页>>代码示例>>C++>>正文


C++ TcpConnection::getSocketpairPeerId方法代码示例

本文整理汇总了C++中TcpConnection::getSocketpairPeerId方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnection::getSocketpairPeerId方法的具体用法?C++ TcpConnection::getSocketpairPeerId怎么用?C++ TcpConnection::getSocketpairPeerId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TcpConnection的用法示例。


在下文中一共展示了TcpConnection::getSocketpairPeerId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sizeof

void dmtcp::ConnectionState::doReconnect(jalib::JSocket& coordinator,
                                         jalib::JSocket& restoreListen)
{
  _rewirer.addDataSocket(new jalib::JChunkReader(coordinator,
                                                 sizeof(DmtcpMessage)));
  _rewirer.addListenSocket(restoreListen);
  _rewirer.setCoordinatorFd(coordinator.sockfd());

  handleDuplicateFilesInSeparateConnections();

  ConnectionList& connections = ConnectionList::instance();

  // Here we modify the restore algorithm by splitting it in two parts. In the
  // first part we restore all the connection except the PTY_SLAVE types and in
  // the second part we restore only PTY_SLAVE connections. This is done to
  // make sure that by the time we are trying to restore a PTY_SLAVE
  // connection, its corresponding PTY_MASTER connection has already been
  // restored.
  // UPDATE: We also restore the files for which the we didn't have the lock in
  //         second iteration along with PTY_SLAVEs
  // Part 1: Restore all but Pseudo-terminal slaves and file connection which
  //         were not checkpointed
  ConnectionList::iterator i;
  for (i= connections.begin(); i != connections.end(); ++i) {
    ConnectionIdentifier id = i->first;
    Connection *con = i->second;

    JASSERT(_conToFds[id].size() > 0)
      .Text("stale connections should be gone by now");

    if (con->subType() == FileConnection::FILE_PROCFS) {
      continue;
    }

    if (con->conType() == Connection::TCP) {
      TcpConnection *tcpCon =(TcpConnection *) con;
      if (tcpCon->peerType() == TcpConnection::PEER_SOCKETPAIR) {
        ConnectionIdentifier peerId = tcpCon->getSocketpairPeerId();
        TcpConnection *peerCon =
          (TcpConnection*) connections.getConnection(peerId);
        if (peerCon != NULL) {
          tcpCon->restoreSocketPair(_conToFds[id], peerCon, _conToFds[peerId]);
          continue;
        }
      }
    }

    if (con->restoreInSecondIteration() == false) {
      con->restore(_conToFds[id], &_rewirer);
    }
  }

  // Part 2: Restore all Pseudo-terminal slaves and file connections that were
  //         not checkpointed.
  for (i = connections.begin(); i != connections.end(); ++i) {
    Connection *con = i->second;
    JASSERT(_conToFds[i->first].size() > 0)
      .Text("stale connections should be gone by now");

    if (con->subType() == FileConnection::FILE_PROCFS) {
      continue;
    }

    if (con->restoreInSecondIteration() == true) {
      con->restore(_conToFds[i->first], &_rewirer);
    }
  }
  _rewirer.doReconnect();
}
开发者ID:ningke,项目名称:dmtcp,代码行数:69,代码来源:connectionstate.cpp


注:本文中的TcpConnection::getSocketpairPeerId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。