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.961 2008/04/07 13:04:47 grubba Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.962 2008/09/19 15:45:19 mast 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:606: Inside #if defined(THREADS)
  local static Queue handle_queue = Queue();   //! Queue of things to handle.   //! An entry consists of an array(function fp, array args)      local static int thread_reap_cnt;   //! Number of handler threads in the process of being stopped.      static int threads_on_hold;   //! Number of handler threads on hold.    + #ifdef SLOW_REQ_BT + static object slow_req_monitor = Pike.Backend(); +  + static void dump_slow_req (Thread.Thread thread) + { +  string desc = sprintf ("%O", thread); +  if (sscanf (desc, "Thread.Thread(%d)", int i)) desc = (string) i; +  report_debug ("### Thread %s has been busy for more than %d seconds.\n", +  desc, SLOW_REQ_BT); +  describe_all_threads(); + } + #endif +    local static void handler_thread(int id)   //! The actual handling function. This functions read function and   //! parameters from the queue, calls it, then reads another one. There   //! is a lot of error handling to ensure that nothing serious happens if   //! the handler function throws an error.   {    THREAD_WERR("Handle thread ["+id+"] started");    mixed h, q;    set_u_and_gid (1);   #ifdef TEST_EUID_CHANGE
Roxen.git/server/base_server/roxen.pike:627: Inside #if defined(THREADS) and #if defined(TEST_EUID_CHANGE)
   Stdio.File f = Stdio.File();    if (f->open ("rootonly", "r") && f->read())    werror ("Handler thread %d can read rootonly\n", id);    else    werror ("Handler thread %d can't read rootonly\n", id);    }   #endif    while(1)    {    int thread_flagged_as_busy; + #ifdef SLOW_REQ_BT +  mixed slow_req_call_out; + #endif    if(q=catch {    do {   // if (!busy_threads) werror ("GC: %d\n", gc());    THREAD_WERR("Handle thread ["+id+"] waiting for next event");    if(arrayp(h=handle_queue->read()) && h[0]) {    THREAD_WERR(sprintf("Handle thread [%O] calling %O(%{%O, %})",    id, h[0], h[1] / 1));    set_locale();    busy_threads++;    thread_flagged_as_busy = 1; -  + #ifdef SLOW_REQ_BT +  if (h[0] != bg_process_queue) +  // Don't want this on the background jobs (at least not +  // with the same timeout). +  slow_req_call_out = +  slow_req_monitor->call_out (dump_slow_req, SLOW_REQ_BT, +  this_thread()); + #endif    h[0](@h[1]);    h=0;    busy_threads--;    thread_flagged_as_busy = 0; -  + #ifdef SLOW_REQ_BT +  slow_req_monitor->remove_call_out (slow_req_call_out); + #endif    } else if(!h) {    // Roxen is shutting down.    report_debug("Handle thread ["+id+"] stopped.\n");    thread_reap_cnt--;   #ifdef NSERIOUS    if(!thread_reap_cnt) report_debug("+++ATH\n");   #endif    return;    }   #ifdef DEBUG
Roxen.git/server/base_server/roxen.pike:674: Inside #if defined(THREADS)
   Thread.Mutex m = Thread.Mutex();    cond->wait (m->lock());    }    threads_on_hold--;    THREAD_WERR("Handle thread [" + id + "] released");    }    } while(1);    }) {    if (thread_flagged_as_busy)    busy_threads--; + #ifdef SLOW_REQ_BT +  slow_req_monitor->remove_call_out (slow_req_call_out); + #endif    if (h = catch {    report_error(/*LOCALE("", "Uncaught error in handler thread: %s"    "Client will not get any response from Roxen.\n"),*/    describe_backtrace(q));    if (q = catch {h = 0;}) {    report_error(LOC_M(5, "Uncaught error in handler thread: %sClient "    "will not get any response from Roxen.")+"\n",    describe_backtrace(q));    catch (q = 0);    }
Roxen.git/server/base_server/roxen.pike:5321:   }         array argv;   int main(int argc, array tmp)   {    // __builtin.gc_parameters((["enabled": 0]));    argv = tmp;    tmp = 0;    + #ifdef SLOW_REQ_BT +  Thread.thread_create (lambda () { +  while (1) slow_req_monitor (3600); +  }); + #endif +    #if 0    Thread.thread_create (lambda () {    while (1) {    sleep (10);    describe_all_threads();    }    });   #endif      #ifdef LOG_GC_TIMESTAMPS