Esempio n. 1
0
void petabricks::RemoteHost::accept(jalib::JServerSocket& s) {
  _control.close();
  _control = s.accept();
  JASSERT(_control.isValid());
  for(int i=0; i<REMOTEHOST_DATACHANS; ++i) {
    _data[i].close();
    _data[i] = s.accept();
    JASSERT(_data[i].isValid());
  }
  _lastchan = 1;
  handshake();
}
Esempio n. 2
0
void IB2TCP::openListenSocket()
{
  if (Util::isValidFd(listenSock.sockfd())) {
    return;
  }
  listenSock = jalib::JServerSocket(jalib::JSockAddr::ANY, 0);
  JASSERT(listenSock.isValid());
  listenSock.changeFd(fdCounter++);
  JASSERT(dmtcp_is_protected_fd(fdCounter) == 0);

  // Setup restore socket for name service
  struct sockaddr_in addr_in;
  addr_in.sin_family = AF_INET;
  dmtcp_get_local_ip_addr(&addr_in.sin_addr);
  addr_in.sin_port = htons(listenSock.port());
  memcpy(&listenAddr, &addr_in, sizeof(addr_in));
  listenAddrLen = sizeof(addr_in);

  JNOTE("opened listen socket") (listenSock.sockfd())
    (inet_ntoa(addr_in.sin_addr)) (ntohs(addr_in.sin_port));
}
Esempio n. 3
0
void IB2TCP::createTCPConnections()
{
  if (!isVirtIB) {
    return;
  }

  size_t numRemaining = 0;
  map<uint32_t, IB_QP*>::iterator it;
  //First do a connect
  for (it = queuePairs.begin(); it != queuePairs.end(); it++) {
    IB_QP *ibqp = it->second;
    IB_QId remoteId = ibqp->getRemoteId();
    if (ibqp->localId > ibqp->remoteId) {
      struct sockaddr_in *addr_in = (struct sockaddr_in*) &ibqp->remoteAddr;
      JNOTE("connecting to remote node")
        (inet_ntoa(addr_in->sin_addr)) (ntohs(addr_in->sin_port));
      jalib::JSocket sock = jalib::JClientSocket((sockaddr*) &ibqp->remoteAddr,
                                                 ibqp->remoteAddrLen);
      sock.changeFd(fdCounter++);
      int fd = sock.sockfd();
      JASSERT(fd != -1);
      JASSERT(Util::writeAll(fd, &remoteId, sizeof(remoteId)) == sizeof(remoteId))
        (JASSERT_ERRNO);
      fdToQP[fd] = ibqp;
      qpToFd[ibqp] = fd;
      socks.push_back(fd);
    } else {
      numRemaining++;
    }
  }

  // Now accept all connections.
  for (size_t i = 0; i < numRemaining; i++) {
    IB_QId localId;
    jalib::JSocket sock = listenSock.accept();
    JASSERT(sock.isValid());
    sock.changeFd(fdCounter++);
    JASSERT(Util::readAll(sock.sockfd(), &localId, sizeof(localId)) == sizeof(localId))
      (JASSERT_ERRNO);

    JASSERT(queuePairs.find(localId.qp_num) != queuePairs.end())
      (localId.qp_num) (localId.lid);

    IB_QP *ibqp = queuePairs[localId.qp_num];
    JASSERT(ibqp->localId < ibqp->remoteId)
      (ibqp->localId.qp_num) (ibqp->remoteId.qp_num);

    fdToQP[sock.sockfd()] = ibqp;
    qpToFd[ibqp] = sock.sockfd();
    socks.push_back(sock.sockfd());
  }
}