Branch: Tag:

2008-09-22

2008-09-22 12:07:59 by Martin Stjernholm <mast@lysator.liu.se>

Added a debug tool that dumps all threads whenever any handler thread or
background job has been running for a set number of seconds. It's
configurable from Globals/Logging and can be disabled with -DNO_SLOW_REQ_BT.

Rev: server/base_server/global_variables.pike:1.111
Rev: server/base_server/roxen.pike:1.987

1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2004, Roxen IS. - // $Id: global_variables.pike,v 1.110 2008/08/15 12:33:53 mast Exp $ + // $Id: global_variables.pike,v 1.111 2008/09/22 12:07:59 mast Exp $      // #pragma strict_types   #define DEFVAR mixed...:object
29:   private int(0..1) ident_disabled_p() { return [int(0..1)]query("default_ident"); }      protected void cdt_changed (Variable.Variable v); + protected void set_slow_req_timeout (int t);      #ifdef SNMP_AGENT   private int(0..1) snmp_disabled() { return !query("snmp_agent"); }
624:    v->set_changed_callback (cdt_changed);    defvar ("dump_threads_by_file", v);    +  defvar ("slow_req_bt", 0, +  LOCALE(0, "Logging: Dump threads for slow requests"), +  TYPE_INT, +  LOCALE(0, #"\ + <p>This setting enables a monitor that dumps all the threads in the + debug log whenever any request or background job has been running for + more than the set number of seconds. Zero disables the monitor.</p> +  + <p><b>Warning:</b> If you set this too low then the debug log can fill + up very quickly and the server become very slow due to the amount of + logging. If that happens and it gets difficult to change back the + value then you can add the define NO_SLOW_REQ_BT to disable this + feature at startup regardless of the timeout configured here.</p> +  + <p>Enabling this creates a dedicated thread.</p>")) +  ->set_changed_callback ( +  lambda (Variable.Variable v) { + #ifndef NO_SLOW_REQ_BT +  int timeout = query ("slow_req_bt"); +  v->set_warning (timeout < 0 && +  LOCALE(0, "Timeout cannot be negative.")); +  if (timeout >= 0) set_slow_req_timeout (timeout); + #else +  v->set_warning ( +  LOCALE(0, "Feature disabled by NO_SLOW_REQ_BT define.")); + #endif +  }); +    #ifdef THREADS    defvar("numthreads", 15, LOCALE(150, "Number of threads to run"),    TYPE_INT,