Branch: Tag:

1997-09-14

1997-09-14 20:45:55 by Per Hedbor <ph@opera.com>

Added locking debug information

Rev: server/base_server/configuration.pike:1.79
Rev: server/config_actions/locks.pike:1.2

1: - string cvs_version = "$Id: configuration.pike,v 1.78 1997/09/14 20:02:40 neotron Exp $"; + string cvs_version = "$Id: configuration.pike,v 1.79 1997/09/14 20:45:53 per Exp $";   #include <module.h>   #include <roxen.h>   /* A configuration.. */
837: Inside #if defined(THREADS)
  #ifdef THREADS   import Thread;    + mapping locked = ([]), thread_safe = ([]); +    object _lock(object|function f)   {    object key;    function|int l; -  +     if (functionp(f)) {    f = function_object(f);    } -  if (l = locks[f]) { -  if (l != -1) { +  if (l = locks[f]) +  { +  if (l != -1) +  {    // Allow recursive locks. -  catch { +  catch +  {    //perror("lock %O\n", f); -  +  locked[f]++;    key = l();    }; -  } +  } else +  thread_safe[f]++;    } else if (f->thread_safe) {    locks[f]=-1; -  +  thread_safe[f]++;    } else { -  if (!locks[f]) { +  if (!locks[f]) +  {    // Needed to avoid race-condition.    l = Mutex()->lock;    if (!locks[f]) {
863: Inside #if defined(THREADS)
   }    }    //perror("lock %O\n", f); +  locked[f]++;    key = l();    }    return key;