Exemplo n.º 1
0
void finish_thread_locals(void *arg /* = NULL */) {
  for (InitFiniNode *in = extra_fini; in; in = in->next) {
    in->func();
  }
  if (!g_context.isNull()) g_context.destroy();
  if (!g_persistentObjects.isNull()) g_persistentObjects.destroy();
}
Exemplo n.º 2
0
// Beware: this is correctly called once per thread, as the name suggests
void finish_thread_locals(void *arg /* = NULL */) {
  for (InitFiniNode *in = extra_fini; in; in = in->next) {
    in->func();
  }
  Extension::ThreadShutdownModules();
  if (!g_context.isNull()) g_context.destroy();
}
Exemplo n.º 3
0
void init_thread_locals(void *arg /* = NULL */) {
  Sweepable::InitSweepableList();
  ObjectData::GetMaxId();
  ResourceData::GetMaxResourceId();
  ServerStats::GetLogger();
  zend_get_bigint_data();
  zend_get_rand_data();
  get_server_note();
  g_persistentObjects.getCheck();
  MemoryManager::TlsWrapper::getCheck();
  ThreadInfo::s_threadInfo.getCheck();
  g_context.getCheck();
  AsioSession::Init();
  HardwareCounter::s_counter.getCheck();
  for (InitFiniNode *in = extra_init; in; in = in->next) {
    in->func();
  }
}
Exemplo n.º 4
0
// Beware: this is actually called once per request, not as the name suggests
void init_thread_locals(void *arg /* = NULL */) {
  ServerStats::GetLogger();
  zend_get_bigint_data();
  zend_get_rand_data();
  get_server_note();
  MemoryManager::TlsWrapper::getCheck();
  if (ThreadInfo::s_threadInfo.isNull()) {
    // Only call init() when there isn't a s_threadInfo already
    ThreadInfo::s_threadInfo.getCheck()->init();
  }
  g_context.getCheck();
  AsioSession::Init();
  HardwareCounter::s_counter.getCheck();
  Extension::ThreadInitModules();
  for (InitFiniNode *in = extra_init; in; in = in->next) {
    in->func();
  }
}
Exemplo n.º 5
0
void init_thread_locals(void *arg /* = NULL */) {
  ObjectData::GetMaxId();
  ResourceData::GetMaxResourceId();
  ServerStats::GetLogger();
  zend_get_bigint_data();
  zend_get_rand_data();
  get_server_note();
  g_persistentObjects.getCheck();
  Sweepable::GetSweepData();
  MemoryManager::TlsWrapper::getCheck();
  InitAllocatorThreadLocal();
  RefData::AllocatorType::getCheck();
  get_global_variables_check();
  ThreadInfo::s_threadInfo.getCheck();
  g_context.getCheck();
  icu_get_checks();
  s_hasRenamedFunction.getCheck();
  Util::HardwareCounter::s_counter.getCheck();
  for (InitFiniNode *in = extra_init; in; in = in->next) {
    in->func();
  }
}
Exemplo n.º 6
0
// Synchronously stop satellites and start danglings
void HttpServer::onServerShutdown() {
  for (InitFiniNode *in = extra_server_exit; in; in = in->next) {
    in->func();
  }

  Eval::Debugger::Stop();
  if (RuntimeOption::EnableDebuggerServer) {
    Logger::Info("debugger server stopped");
  }

  XboxServer::Stop();

  // When a new instance of HPHP has taken over our page server socket,
  // stop our admin server and satellites so it can acquire those ports.
  for (unsigned int i = 0; i < m_satellites.size(); i++) {
    std::string name = m_satellites[i]->getName();
    m_satellites[i]->stop();
    Logger::Info("satellite server %s stopped", name.c_str());
  }
  if (RuntimeOption::AdminServerPort) {
    m_adminServer->stop();
    m_adminServer->waitForEnd();
    Logger::Info("admin server stopped");
  }

  // start dangling servers, so they can serve old version of pages
  for (unsigned int i = 0; i < m_danglings.size(); i++) {
    std::string name = m_danglings[i]->getName();
    try {
      m_danglings[i]->start();
      Logger::Info("dangling server %s started", name.c_str());
    } catch (Exception &e) {
      Logger::Error("Unable to start danglings server %s: %s",
                    name.c_str(), e.getMessage().c_str());
      // it's okay not able to start them
    }
  }
}
Exemplo n.º 7
0
void HttpServer::run() {
  StartTime = time(0);

  m_watchDog.start();

  for (unsigned int i = 0; i < m_serviceThreads.size(); i++) {
    m_serviceThreads[i]->start();
  }
  for (unsigned int i = 0; i < m_serviceThreads.size(); i++) {
    m_serviceThreads[i]->waitForStarted();
  }

  if (RuntimeOption::ServerPort) {
    if (!startServer(true)) {
      Logger::Error("Unable to start page server");
      return;
    }
    Logger::Info("page server started");
  }

  if (RuntimeOption::AdminServerPort) {
    if (!startServer(false)) {
      Logger::Error("Unable to start admin server");
      abortServers();
      return;
    }
    Logger::Info("admin server started");
  }

  for (unsigned int i = 0; i < m_satellites.size(); i++) {
    string name = m_satellites[i]->getName();
    try {
      m_satellites[i]->start();
      Logger::Info("satellite server %s started", name.c_str());
    } catch (Exception &e) {
      Logger::Error("Unable to start satellite server %s: %s",
                    name.c_str(), e.getMessage().c_str());
      abortServers();
      return;
    }
  }

  if (!Eval::Debugger::StartServer()) {
    Logger::Error("Unable to start debugger server");
    abortServers();
    return;
  } else if (RuntimeOption::EnableDebuggerServer) {
    Logger::Info("debugger server started");
  }

  for (InitFiniNode *in = extra_server_init; in; in = in->next) {
    in->func();
  }

  {
    Logger::Info("all servers started");
    createPid();
    Lock lock(this);
    // continously running until /stop is received on admin server
    while (!m_stopped) {
      wait();
    }
    if (m_stopReason) {
      Logger::Warning("Server stopping with reason: %s\n", m_stopReason);
    }
    removePid();
    Logger::Info("page server stopped");
  }

  onServerShutdown(); // dangling server already started here
  time_t t0 = time(0);
  if (RuntimeOption::ServerPort) {
    m_pageServer->stop();
  }
  time_t t1 = time(0);
  if (!m_danglings.empty() && RuntimeOption::ServerDanglingWait > 0) {
    int elapsed = t1 - t0;
    if (RuntimeOption::ServerDanglingWait > elapsed) {
      sleep(RuntimeOption::ServerDanglingWait - elapsed);
    }
  }

  for (unsigned int i = 0; i < m_danglings.size(); i++) {
    m_danglings[i]->stop();
    Logger::Info("dangling server %s stopped",
                 m_danglings[i]->getName().c_str());
  }

  for (unsigned int i = 0; i < m_serviceThreads.size(); i++) {
    m_serviceThreads[i]->notifyStopped();
  }
  for (unsigned int i = 0; i < m_serviceThreads.size(); i++) {
    m_serviceThreads[i]->waitForEnd();
  }

  hphp_process_exit();
  m_watchDog.waitForEnd();
  Logger::Info("all servers stopped");
}