6775fc2000-02-02Per Hedbor /*
0917d32013-03-04Anders Johansson  * $Id$
6775fc2000-02-02Per Hedbor  */
bebbad2000-08-16Andreas Lange 
6775fc2000-02-02Per Hedbor #include <config.h>
bebbad2000-08-16Andreas Lange #ifdef THREADS
6775fc2000-02-02Per Hedbor  inherit "wizard";
dedda52000-02-03Johan Sundström inherit "../logutil";
6775fc2000-02-02Per Hedbor 
bebbad2000-08-16Andreas Lange #include <roxen.h> //<locale-token project="admin_tasks">LOCALE</locale-token> #define LOCALE(X,Y) _STR_LOCALE("admin_tasks",X,Y)
bfbc232000-09-19Andreas Lange constant action="debug_info";
bebbad2000-08-16Andreas Lange  string name= LOCALE(280, "Module lock status"); string doc = LOCALE(281, "Shows various information about the module thread " "locks in Roxen.");
6775fc2000-02-02Per Hedbor  string describe_module(object q) { foreach(roxen->configurations, object c) { foreach(indices(c->modules), string m) { int w; mapping mod = c->modules[m]; if(mod->enabled == q)
dedda52000-02-03Johan Sundström  return sprintf("<a href=\"%s\">%s</a></td><td>%s", @get_conf_url_to_module(c->name+"/"+m), roxen->filename(q));
6775fc2000-02-02Per Hedbor  else if(mod->copies && !zero_type(search(mod->copies,q)))
dedda52000-02-03Johan Sundström  return sprintf("<a href=\"%s\">%s</a></td><td>%s", @get_conf_url_to_module(c->name+"/"+m+"#"+search(mod->copies,q)), roxen->filename(q));
6775fc2000-02-02Per Hedbor  } }
bebbad2000-08-16Andreas Lange  return LOCALE(12, "Unknown module")+"</td><td>"+roxen->filename(q)+"";
6775fc2000-02-02Per Hedbor }
bebbad2000-08-16Andreas Lange string parse( RequestID id )
6775fc2000-02-02Per Hedbor { mapping l = ([]), locks=([]), L=([]); foreach(roxen->configurations, object c) { if (c->locked) { l += c->locked; } if (c->thread_safe) { L += c->thread_safe; } } mapping res=([]);
80cd682003-11-17Anders Johansson  string data=("<font size='+1'><b>"+
bebbad2000-08-16Andreas Lange  LOCALE(13, "Module lock status : Accesses to all modules")+
80cd682003-11-17Anders Johansson  "</b></font><p>"+
0897372000-08-17Johan Sundström  LOCALE(14, "Locked means that the access was done using a " "serializing lock since the module was not thread-safe, " "unlocked means that there was no need for a lock.")+
bebbad2000-08-16Andreas Lange  "</p><p>"+
0897372000-08-17Johan Sundström  LOCALE(15, "Locked accesses to a single module can inflict " "quite a severe performance degradation of the whole " "server, since a locked module will act as a bottleneck, " "blocking access for all other threads that want to " "access that module.")+ "</p><p>"+ LOCALE(16, "This is only a problem if a significant percentage " "of the accesses are passed through non-threadsafe " "modules.") +"</p>");
6775fc2000-02-02Per Hedbor  array mods = (indices(L)+indices(l)); mods &= mods; foreach(mods, object q) { res[describe_module(q)]+=l[q]; locks[describe_module(q)]+=L[q]; } array rows = ({}); foreach(sort(indices(res)), string q)
ccb6632000-02-03Johan Sundström  rows += ({ ({q,(string)(res[q]||""),(string)(locks[q]||"") }) });
80cd682003-11-17Anders Johansson 
bebbad2000-08-16Andreas Lange  return data +
80cd682003-11-17Anders Johansson  html_table( ({ LOCALE(17, "Module"), LOCALE(18, "File"), LOCALE(19, "Locked"), LOCALE(20, "Unlocked") }), rows, ([ "titlebgcolor":"&usr.obox-titlebg;", "bordercolor":"&usr.obox-border;", "titlecolor":"&usr.obox-titlefg;", "oddbgcolor":"&usr.obox-bodybg;", "evenbgcolor":"&usr.fade1;", ]) ) + "<p><cf-ok/></p>";
6775fc2000-02-02Per Hedbor } #endif /* THREADS */