Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:145:   // with 2.4.   // Note also that 5.3 only existed in the Print repository, and   // thus is skipped here.   array(string) compat_levels = ({"2.1", "2.2", "2.4", "2.5",    "3.3", "3.4",    "4.0", "4.5",    "5.0", "5.1", "5.2", "5.4", "5.5",    "6.0", "6.1",   });    + // Compat stubs for relocated methods   #ifdef THREADS - mapping(string:string) thread_names = ([]); -  +    string thread_name_from_addr(string hex_addr)   { -  // Lookup using a key like "Thread.Thread(0x...)" that matches what -  // sprint("%O") generates. -  string th_key = "Thread.Thread(" + hex_addr + ")"; -  return thread_names[th_key]; +  return Roxen.thread_name_from_addr(hex_addr);   }    - string thread_name( object thread, int|void skip_auto_name ) + string thread_name(object thread, int|void skip_auto_name)   { -  string tn; -  if( thread_names[ tn=sprintf("%O",thread) ] || skip_auto_name ) -  return thread_names[tn]; -  return tn; +  return Roxen.thread_name(thread, skip_auto_name);   }      void name_thread( object thread, string name )   { -  string th_key = sprintf("%O", thread); -  if (name) -  thread_names[th_key] = name; -  else -  m_delete(thread_names, th_key); +  Roxen.name_thread(thread, name);   } -  + #endif    - #endif /* THREADS */ +       /* Used by read_config.pike, since there seems to be problems with    * overloading otherwise.    */   protected Privs PRIVS(string r, int|string|void u, int|string|void g)   {    return Privs(r, u, g);   }      // Current Configuration.
Roxen.git/server/base_server/roxen.pike:371:   /*    * handle() stuff    */      #ifdef THREADS   // function handle = threaded_handle;      Thread.Thread do_thread_create(string id, function f, mixed ... args)   {    Thread.Thread t = thread_create(f, @args); -  name_thread( t, id ); +  Roxen.name_thread( t, id );    return t;   }      #if 1   constant Queue = Thread.Queue;   #else   // Shamelessly uses facts about pikes preemting algorithm.   // Might have to be fixed in the future.   class Queue   //! Thread.Queue lookalike, which uses some archaic and less
Roxen.git/server/base_server/roxen.pike:454: Inside #if undefined(NO_SLOW_REQ_BT)
  // This is a system to dump all threads whenever a request takes   // longer than a configurable timeout.      protected Pike.Backend slow_req_monitor; // Set iff slow req bt is enabled.   protected float slow_req_timeout, slow_be_timeout;      protected void slow_req_monitor_thread (Pike.Backend my_monitor)   {    // my_monitor is just a safeguard to ensure we don't get multiple    // monitor threads. -  name_thread(this_thread(), "Slow request monitor"); +  Roxen.name_thread(this_thread(), "Slow request monitor");    while (slow_req_monitor == my_monitor)    slow_req_monitor (3600.0); -  name_thread(this_thread(), 0); +  Roxen.name_thread(this_thread(), 0);   }      protected mixed slow_be_call_out;      protected void slow_be_before_cb()   {   #ifdef DEBUG    if (this_thread() != backend_thread) error ("Run from wrong thread.\n");   #endif    if (Pike.Backend monitor = slow_be_call_out && slow_req_monitor) {
Roxen.git/server/base_server/roxen.pike:580: Inside #if undefined(NO_SLOW_REQ_BT)
      if (thread == backend_thread && !slow_be_call_out) {    // Avoid false alarms for the backend thread if we got here due to    // a race. Should perhaps have something like this for the handler    // threads too, but otoh races are more rare there due to the    // longer timeouts.    }       else {    string th_name = -  ((thread != backend_thread) && thread_name(thread, 1)) || ""; +  ((thread != backend_thread) && Roxen.thread_name(thread, 1)) || "";    if (sizeof(th_name))    th_name = " - " + th_name + " -";    report_debug ("###### %s 0x%x%s has been busy for more than %g seconds.\n",    thread == backend_thread ? "Backend thread" : "Thread",    thread->id_number(), th_name, timeout);    int hrnow = gethrtime();    if ((hrnow - last_dump_hrtime) / 1E6 < slow_req_timeout / 2) {    describe_thread (thread);    } else {    last_dump_hrtime = hrnow;
Roxen.git/server/base_server/roxen.pike:609: Inside #if undefined(NO_SLOW_REQ_BT)
  }      protected void report_slow_thread_finished (Thread.Thread thread,    float time_spent)   {    if (query ("slow_req_bt_count") == 0) {    return;    }       string th_name = -  ((thread != backend_thread) && thread_name(thread, 1)) || ""; +  ((thread != backend_thread) && Roxen.thread_name(thread, 1)) || "";    if (sizeof(th_name))    th_name = " - " + th_name + " -";       report_debug ("###### %s 0x%x%s finished after %.2f seconds.\n",    (thread == backend_thread ?    "Backend thread" : "Thread"),    thread->id_number(), th_name, time_spent);   }      #endif // !NO_SLOW_REQ_BT
Roxen.git/server/base_server/roxen.pike:6038: Inside #if constant(spider.shuffle)
  #if constant(spider.shuffle)    }   #endif   }      // Dump a single thread.   void describe_thread (Thread.Thread thread)   {    int hrnow = gethrtime();    string thread_descr = ""; -  if (string th_name = thread_name(thread, 1)) +  if (string th_name = Roxen.thread_name(thread, 1))    thread_descr += " - " + th_name;    if (int start_hrtime = thread_task_start_times[thread])    thread_descr += sprintf (" - busy for %.3fs",    (hrnow - start_hrtime) / 1e6);    report_debug(">> ### Thread 0x%x%s:\n",    thread->id_number(),    thread_descr);    // Use master()->describe_backtrace to sidestep the background    // failure wrapper that's active in RUN_SELF_TEST.    string th_bt = master()->describe_backtrace (thread->backtrace());
Roxen.git/server/base_server/roxen.pike:6060:    // Expand any occurrences of:    // Thread.Mutex(/*locked by 0x....*/)    // to:    // Thread.Mutex(/*locked by 0x.... - <thread name>*/)    string bt_separator = "Thread.Mutex(/*locked by ";    if (has_value(th_bt, bt_separator)) {    array(string) bt_segs = th_bt / bt_separator;    if (sizeof(bt_segs) > 1) {    foreach (bt_segs; int idx; string bt_seg) {    if (sscanf(bt_seg, "0x%[0-9a-fA-F]*/", string th_hex_addr)) { -  if (string th_name = thread_name_from_addr("0x" + th_hex_addr)) { +  if (string th_name = Roxen.thread_name_from_addr("0x" + th_hex_addr)) {    bt_segs[idx] =    "0x" + th_hex_addr + " - " + th_name +    bt_seg[sizeof(th_hex_addr) + 2..];    }    }    }    th_bt = bt_segs * bt_separator;    }    }   
Roxen.git/server/base_server/roxen.pike:6168:   constant cdt_poll_interval = 5; // Seconds.   constant cdt_dump_seq_interval = 60;      string cdt_directory, cdt_filename;      Thread.Thread cdt_thread;   int cdt_next_seq_dump;      void cdt_poll_file()   { -  name_thread(this_thread(), "Dump thread file monitor"); +  Roxen.name_thread(this_thread(), "Dump thread file monitor");    while (this && query ("dump_threads_by_file")) {    if (array(string) dir = r_get_dir (cdt_directory)) {    if (has_value (dir, cdt_filename)) {    r_rm (cdt_directory + "/" + cdt_filename);    describe_all_threads();    }    else if (time() >= cdt_next_seq_dump) {    dir = glob (cdt_filename + ".*", dir);    if (sizeof (dir)) {    string file = dir[0];
Roxen.git/server/base_server/roxen.pike:6192:    if (--count > 0) {    open (cdt_directory + "/" + cdt_filename + "." + count,    "cwt");    cdt_next_seq_dump = time (1) + cdt_dump_seq_interval;    }    }    }    }    sleep (cdt_poll_interval);    } -  name_thread(this_thread(), 0); +  Roxen.name_thread(this_thread(), 0);    cdt_thread = 0;   }      void cdt_changed (Variable.Variable v)   {    if (cdt_directory && v->query() && !cdt_thread)    cdt_thread = Thread.thread_create (cdt_poll_file);   }      // ----------------------------------------
Roxen.git/server/base_server/roxen.pike:6739: Inside #if defined(SNMP_AGENT)
   snmpagent->enable();    report_debug("\benabled.\n");    snmpagent->start_trap();       } else    report_debug("\bdisabled.\n");   #endif // SNMP_AGENT       backend_thread = this_thread();   #ifdef THREADS -  name_thread( backend_thread, "Backend" ); +  Roxen.name_thread( backend_thread, "Backend" );   #else    report_debug("\n"    "WARNING: Threads not enabled!\n"    "\n");   #endif /* THREADS */       foreach(({ "testca.pem", "demo_certificate.pem" }), string file_name) {    if (!sizeof(roxenloader.package_directories)) break;    CertDB.register_pem_file(file_name);    string cert;