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 - 2009, 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.1104 2012/01/19 14:13:03 grubba Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.1105 2012/01/26 11:12:10 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:830:    programp (task[0]) ?    sprintf ("%s: %s", Program.defined (task[0]),    master()->describe_program (task[0])) :    sprintf ("%O", task[0])) +    "(" +    map (task[1], lambda (mixed arg)    {return sprintf ("%O", arg);}) * ", " +    ")");   }    + protected mapping(Thread.Thread:int) thread_task_start_times = ([]); +    local protected 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:869:    THREAD_WERR("Handle thread ["+id+"] waiting for next event");    if(arrayp(h=handle_queue->read()) && h[0]) {    THREAD_WERR(sprintf("Handle thread [%O] calling %s",    id, debug_format_queue_task (h)));    set_locale();    busy_threads++;    thread_flagged_as_busy = 1;    handler_num_runs++;       int start_hrtime = gethrtime(); +  thread_task_start_times[this_thread()] = start_hrtime;    float handler_vtime = gauge {   #ifndef NO_SLOW_REQ_BT    if (h[0] != bg_process_queue &&    // Leave out bg_process_queue. It makes a timeout on    // every individual job instead.    (monitor = slow_req_monitor) && slow_req_timeout > 0.0) {    call_out = monitor->call_out (dump_slow_req, slow_req_timeout,    this_thread(), slow_req_timeout);    h[0](@h[1]);    monitor->remove_call_out (call_out);    }    else   #endif    {    h[0](@h[1]);    }    };    float handler_rtime = (gethrtime() - start_hrtime)/1E6; -  +  thread_task_start_times[this_thread()] = 0;       h=0;    busy_threads--;    thread_flagged_as_busy = 0;    if (handler_rtime > 0.01) handler_num_runs_001s++;    if (handler_rtime > 0.05) handler_num_runs_005s++;    if (handler_rtime > 0.15) handler_num_runs_015s++;    if (handler_rtime > 0.50) handler_num_runs_05s++;    if (handler_rtime > 1.00) handler_num_runs_1s++;    if (handler_rtime > 5.00) handler_num_runs_5s++;
Roxen.git/server/base_server/roxen.pike:1308: Inside #if defined(THREADS)
  #endif       float task_vtime, task_rtime;    bg_num_runs++;      #ifndef NO_SLOW_REQ_BT    if ((monitor = slow_req_monitor) && slow_req_timeout > 0.0) {    call_out = monitor->call_out (dump_slow_req, slow_req_timeout,    this_thread(), slow_req_timeout);    int start_hrtime = gethrtime (1); +  thread_task_start_times[this_thread()] = start_hrtime;    task_vtime = gauge {    if (task[0]) // Ignore things that have become destructed.    // Note: BackgroundProcess.repeat assumes that there are    // exactly two refs to task[0] during the call below.    task[0] (@task[1]);    };    task_rtime = (gethrtime (1) - start_hrtime) / 1e9; -  +  thread_task_start_times[this_thread()] = 0;    monitor->remove_call_out (call_out);    }    else   #endif    {    int start_hrtime = gethrtime (1); -  +  thread_task_start_times[this_thread()] = start_hrtime;    task_vtime = gauge {    if (task[0])    task[0] (@task[1]);    };    task_rtime = (gethrtime (1) - start_hrtime) / 1e9; -  +  thread_task_start_times[this_thread()] = 0;    }       if (task_rtime > 0.01) bg_num_runs_001s++;    if (task_rtime > 0.05) bg_num_runs_005s++;    if (task_rtime > 0.15) bg_num_runs_015s++;    if (task_rtime > 0.50) bg_num_runs_05s++;    if (task_rtime > 1.00) bg_num_runs_1s++;    if (task_rtime > 5.00) bg_num_runs_5s++;    if (task_rtime > 15.00) bg_num_runs_15s++;    bg_acc_cpu_time += (int)(1E6*task_vtime);
Roxen.git/server/base_server/roxen.pike:5631:    lambda (Thread.Thread a, Thread.Thread b) {    // Backend thread first, otherwise in id order.    if (a == backend_thread)    return 0;    else if (b == backend_thread)    return 1;    else    return a->id_number() > b->id_number();    });    -  int i; -  for(i=0; i < sizeof(threads); i++) { +  int hrnow = gethrtime(); +  foreach (threads, Thread.Thread thread) { +  string thread_descr = ""; +  if (int start_hrtime = thread_task_start_times[thread]) +  thread_descr += sprintf (", busy for %.3fs", +  (hrnow - start_hrtime) / 1e6); +  if (thread == backend_thread) +  thread_descr += " (backend thread)";    report_debug(">> ### Thread 0x%x%s:\n", -  threads[i]->id_number(), -  threads[i] == backend_thread ? " (backend thread)" : "" -  ); +  thread->id_number(), +  thread_descr);    report_debug(">> " + -  replace (describe_backtrace (threads[i]->backtrace()), +  replace (describe_backtrace (thread->backtrace()),    "\n", "\n>> ") +    "\n");    }       array(array) queue = handle_queue->peek_array();       // Ignore the handle thread shutdown marker, if any.    queue -= ({0});       if (!sizeof (queue))