示例#1
0
int TakeoverAgent::setupFdServer(event_base *eventBase, int sock,
                                 Callback *callback) {
#ifdef _MSC_VER
  return -1;
#else
  int ret;
  m_sock = sock;
  m_callback = callback;
  ret = unlink(m_transfer_fname.c_str());
  if (ret < 0 && errno != ENOENT) {
    Logger::Error("Unalbe to unlink '%s': %s",
                  m_transfer_fname.c_str(), folly::errnoStr(errno).c_str());
    return -1;
  }

  ret = afdt_create_server(m_transfer_fname.c_str(),
                           eventBase,
                           fd_transfer_request_handler,
                           afdt_no_post,
                           fd_transfer_error_handler,
                           &m_delete_handle,
                           this);
  // We don't really care if this worked or not.
  // If it didn't, the next invocation of the server
  // will just have to kill us.
  if (ret >= 0) {
    Logger::Info("takeover: fd server set up successfully");
  }
  return ret;
#endif
}
void LibEventServerWithTakeover::setupFdServer() {
  int ret;
  ret = unlink(m_transfer_fname.c_str());
  if (ret < 0 && errno != ENOENT) {
    Logger::Error("Unalbe to unlink '%s': %s",
                  m_transfer_fname.c_str(), Util::safe_strerror(errno).c_str());
    return;
  }

  ret = afdt_create_server(
      m_transfer_fname.c_str(),
      m_eventBase,
      fd_transfer_request_handler,
      afdt_no_post,
      fd_transfer_error_hander,
      &m_delete_handle,
      this);
  // We don't really care if this worked or not.
  // If it didn't, the next invocation of the server
  // will just have to kill us.
  if (ret >= 0) {
    Logger::Info("takeover: fd server set up successfully");
  }
}