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.957 2007/01/30 17:18:45 jonasw Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.958 2007/02/15 13:06:07 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:4729:   void describe_all_threads()   {   #if constant (thread_create)    // Disable all threads to avoid potential locking problems while we    // have the backtraces. It also gives an atomic view of the state.    object threads_disabled = _disable_threads();       report_debug("### Describing all Pike threads:\n\n");       array(Thread.Thread) threads = all_threads(); -  array(string|int) thread_ids = -  map (threads, -  lambda (Thread.Thread t) { -  string desc = sprintf ("%O", t); -  if (sscanf (desc, "Thread.Thread(%d)", int i)) return i; -  else return desc; +  +  mapping(Thread.Thread:string|int) thread_ids = ([]); +  foreach (threads, Thread.Thread thread) { +  string desc = sprintf ("%O", thread); +  if (sscanf (desc, "Thread.Thread(%d)", int i)) thread_ids[thread] = i; +  else thread_ids[thread] = desc; +  } +  +  threads = Array.sort_array ( +  threads, +  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 thread_ids[a] > thread_ids[b];    }); -  sort (thread_ids, threads); +        int i;    for(i=0; i < sizeof(threads); i++) {    report_debug("### Thread %s%s:\n", -  (string) thread_ids[i], +  (string) thread_ids[threads[i]],   #ifdef THREADS    threads[i] == backend_thread ? " (backend thread)" : ""   #else    ""   #endif    );    report_debug(describe_backtrace(threads[i]->backtrace()) + "\n");    }    -  report_debug ("### Total %d Pike threads\n", sizeof (threads)); +  report_debug ("### Total %d Pike threads\n\n", sizeof (threads));       threads = 0;    threads_disabled = 0;   #else -  report_debug("Describing single thread:\n%s\n", +  report_debug("Describing single thread:\n%s\n\n",    describe_backtrace (backtrace()));   #endif      #ifdef DEBUG    report_debug (RoxenDebug.report_leaks());   #endif   }         // Dump threads by file polling.