コード例 #1
0
ファイル: server.cpp プロジェクト: nealey/vera
//--------------------------------------------------------------------------
static void NT_CDECL shutdown_gracefully(int signum)
{
  qeprintf("got signal #%d\n", signum);

#ifdef __SINGLE_THREADED_SERVER__

  if ( g_global_server != NULL )
  {
    debmod_t *d = g_global_server->get_debugger_instance();
    if ( d != NULL )
      d->dbg_exit_process();
    g_global_server->term_irs();
  }
#else
  qmutex_lock(g_lock);

  for (rpc_server_list_t::iterator it = clients_list.begin(); it != clients_list.end();++it)
  {
    rpc_server_t *server = it->first;
    qthread_t thr = it->second;

    // free thread
    if ( thr != NULL )
      qthread_free(thr);

    if ( server == NULL || server->irs == NULL )
      continue;

    debmod_t *d = server->get_debugger_instance();
    if ( d != NULL )
      d->dbg_exit_process(); // kill the process instead of letting it run in wild

    server->term_irs();
  }

  clients_list.clear();
  qmutex_unlock(g_lock);
  qmutex_free(g_lock);
#endif

  if ( listen_socket != INVALID_SOCKET )
    closesocket(listen_socket);

  term_subsystem();
  _exit(1);
}
コード例 #2
0
ファイル: server.cpp プロジェクト: mailwl/android_server
//--------------------------------------------------------------------------
static void NT_CDECL shutdown_gracefully(int signum)
{
  if ( signum == SIGINT && ignore_sigint )
  {
    ignore_sigint = false;
    return;
  }

#if defined(__NT__) || defined(__ARM__) // strsignal() is not available
  qeprintf("got signal #%d, terminating\n", signum);
#else
  qeprintf("%s: terminating the server\n", strsignal(signum));
#endif

  srv_lock_begin();

  for (rpc_server_list_t::iterator it = clients_list.begin(); it != clients_list.end();++it)
  {
    rpc_server_t *server = it->first;
#ifndef __SINGLE_THREADED_SERVER__
    qthread_t thr = it->second;

    // free thread
    if ( thr != NULL )
      qthread_free(thr);
#endif
    if ( server == NULL || server->irs == NULL )
      continue;

    debmod_t *d = server->get_debugger_instance();
    if ( d != NULL )
      d->dbg_exit_process(); // kill the process instead of letting it run in wild

    server->term_irs();
  }

  clients_list.clear();
  srv_lock_end();
  srv_lock_free();

  if ( listen_socket != INVALID_SOCKET )
    closesocket(listen_socket);

  term_subsystem();
  _exit(1);
}