Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2004, Roxen IS.   //   // The Roxen WebServer main program.   //   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.951 2006/11/23 13:06:42 mast Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.952 2006/11/30 12:41:56 grubba Exp $";      //! @appears roxen   //!   //! The Roxen WebServer main program.      // The argument cache. Used by the image cache.   ArgCache argcache;      // Some headerfiles   #define IN_ROXEN
Roxen.git/server/base_server/roxen.pike:2678:   string create_unique_id()   {    object md5 = Crypto.md5();    md5->update(query("server_salt") + start_time + "|" +    (unique_id_counter++) + "|" + time(1));    return Crypto.string_to_hex(md5->digest());   }      #ifndef __NT__   static int abs_started; + static int handlers_alive;    - void restart_if_stuck (int force) - //! @note - //! Must be called from the backend thread due to Linux peculiarities. + static void low_engage_abs()   { -  remove_call_out(restart_if_stuck); -  if (!(query("abs_engage") || force)) -  return; -  if(!abs_started) -  { -  abs_started = 1; -  report_debug("Anti-Block System Enabled.\n"); +  report_debug("**** %s: ABS exiting roxen!\n\n", +  ctime(time()) - "\n"); +  _exit(1); // It might not quit correctly otherwise, if it's +  // locked up   } -  call_out (restart_if_stuck,10); - // werror("call_out_info %O\n", filter(call_out_info(), lambda(array a) { - // return a[2] == restart_if_stuck; })); -  signal(signum("SIGALRM"), -  lambda( int n ) { +  + static void engage_abs(int n) + {    if (!query("abs_engage")) {    abs_started = 0;    report_debug("Anti-Block System Disabled.\n");    return;    }    report_debug("**** %s: ABS engaged!\n"    "Waited more than %d minute(s).\n"    "Trying to dump backlog: \n",    ctime(time()) - "\n",    query("abs_timeout")); -  +  // Paranoia exit in case describe_all_threads below hangs. +  signal(signum("SIGALRM"), low_engage_abs); +  int t = alarm(20);    catch {    // Catch for paranoia reasons.    describe_all_threads();    }; -  report_debug("**** %s: ABS exiting roxen!\n\n", -  ctime(time())); -  _exit(1); // It might now quit correctly otherwise, if it's -  // locked up -  }); +  low_engage_abs(); + } +  + void restart_if_stuck (int force) + //! @note + //! Must be called from the backend thread due to Linux peculiarities. + { +  remove_call_out(restart_if_stuck); +  if (!(query("abs_engage") || force)) +  return; +  if(!abs_started) +  { +  abs_started = 1; +  handlers_alive = time(1); +  report_debug("Anti-Block System Enabled.\n"); +  } +  call_out (restart_if_stuck,10); + // werror("call_out_info %O\n", filter(call_out_info(), lambda(array a) { + // return a[2] == restart_if_stuck; })); +  signal(signum("SIGALRM"), engage_abs);    int t = alarm (60*query("abs_timeout")+20);    // werror("alarm: %d seconds left, set to %d\n", t, 60*query("abs_timeout")+20); -  +  if ((time(1) - handlers_alive) > 60*query("abs_timeout")) { +  // The handler installed below hasn't run. +  report_debug("**** %s: ABS: Handlers are dead!\n", +  ctime(time()) - "\n"); +  engage_abs(0);    } -  +  handle(lambda() { handlers_alive = time(1); }); + }   #endif      #if constant(ROXEN_MYSQL_SUPPORTS_UNICODE)   // NOTE: We need to mark binary data as binary in case   // the Mysql character_set_connection has been   // set to anything other than "latin1".   #define MYSQL__BINARY "_binary"   #else   #define MYSQL__BINARY ""   #endif