Пример #1
0
int main(void) {
  struct mg_mgr mgr;
  struct mg_connection *nc1;
  struct mg_connection *nc2;
  const char *port1 = "127.0.0.1:80", *port2 = "[::1]:80";

  oom_adjust_setup();

  mg_mgr_init(&mgr, NULL);
  nc1 = mg_bind(&mgr, port1, ev_handler);
  nc2 = mg_bind(&mgr, port2, ev_handler);

  mg_set_protocol_http_websocket(nc1);
  mg_set_protocol_http_websocket(nc2);

  signal(SIGINT, signal_handler);
  signal(SIGTERM, signal_handler);

  __android_log_print(ANDROID_LOG_INFO, THIS_FILE, "AdAway Native Webserver: starting");
  while (s_sig_num == 0) {
    mg_mgr_poll(&mgr, 1000);
  }

  mg_mgr_free(&mgr);
  __android_log_print(ANDROID_LOG_INFO, THIS_FILE, "AdAway Native Webserver: exited on signal %d", s_sig_num);
  return EXIT_SUCCESS;
}
Пример #2
0
void
platform_pre_listen(void)
{
#ifdef LINUX_OOM_ADJUST
    /* Adjust out-of-memory killer so listening process is not killed */
    oom_adjust_setup();
#endif
}