Changeset 140 for trunk/src/sh_error.c


Ignore:
Timestamp:
Oct 29, 2007, 1:09:10 AM (17 years ago)
Author:
rainer
Message:

Utility function for threaded modules.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_error.c

    r133 r140  
    5656#include "sh_forward.h"
    5757#include "sh_prelude.h"
     58#include "sh_pthread.h"
    5859
    5960#if defined(WITH_DATABASE)
     
    857858 **********************************************************/
    858859
     860SH_MUTEX_RECURSIVE(mutex_err_handle);
     861
    859862void sh_error_handle (int sev, char * file, long line,
    860863                      long status, unsigned long msg_id, ...)
     
    868871
    869872  int    flag_inet  = S_FALSE;
     873
     874#ifdef SH_WITH_SERVER
    870875  int    class_inet = clt_class;      /* initialize from global */
    871 
    872 #ifdef SH_WITH_SERVER
    873876  char   local_inet_peer[SH_MINIBUF];
    874877#endif
     
    908911  SL_ENTER(_("sh_error_handle"));
    909912
     913  SH_MUTEX_RECURSIVE_INIT(mutex_err_handle);
     914  SH_MUTEX_RECURSIVE_LOCK(mutex_err_handle);
     915
    910916#ifdef SH_WITH_SERVER
    911917  /* copy the global string into a local array
     
    918924  else
    919925    local_inet_peer[0] = '\0';
    920 #endif
    921926
    922927  clt_class = (-1);      /* reset global */
     928#endif
     929
    923930
    924931  if (own_block == 1)
    925932    {
    926       SL_RET0(_("sh_error_handle"));
     933      goto exit_here;
    927934    }
    928935
    929936  /* --- Initialize to default values. ---
    930937   */
    931   own_block = 1;
    932938  if (IsInitialized == BAD)
    933939    (void) sh_error_init();
    934   own_block = 0;
    935 
    936   /* --- Consistency checks. ---
    937    */
    938   own_block = 1;
     940
     941  /* Returns pointer to (constant|thread-specific) static memory
     942   */
    939943  fmt = /*@i@*/get_format (msg_id, &severity, &class);
    940   own_block = 0;
    941 
     944
     945#ifdef SH_WITH_SERVER
    942946  if (class_inet != (-1))
    943947    class = (unsigned int) class_inet;
    944 
     948#endif
     949
     950  /* --- Consistency check. ---
     951   */
    945952  ASSERT((fmt != NULL), _("fmt != NULL"))
    946953  if (fmt == NULL)
     
    949956              _("ERROR: msg=<NULL format>, file=<%s>, line=<%ld>\n"),
    950957              file, line);
    951       SL_RET0(_("sh_error_handle"));
     958      goto exit_here;
    952959    }
    953960
     
    9951002       )
    9961003    {
    997       SL_RET0(_("sh_error_handle"));
     1004      goto exit_here;
    9981005    }
    9991006
    10001007  if ((severity & SH_ERR_NOT) != 0)
    10011008    {
    1002       SL_RET0(_("sh_error_handle"));
     1009      goto exit_here;
    10031010    }
    10041011
     
    10171024  lmsg->line     = line;
    10181025  lmsg->status   = status;
    1019   own_block = 0;
    1020 
    10211026
    10221027  /* Format the log message with timestamp etc.
    10231028   * Allocate lmsg->msg
    10241029   */
    1025   own_block = 1;
    10261030  va_start (vl, msg_id);
    10271031  (void) sh_error_string (lmsg, vl);
     
    13111315  SH_FREE( lmsg );
    13121316  own_block = 0;
     1317
     1318 exit_here:
     1319
     1320  SH_MUTEX_RECURSIVE_UNLOCK(mutex_err_handle);
    13131321
    13141322  /*@i@*/SL_RET0(_("sh_error_handle"));
Note: See TracChangeset for help on using the changeset viewer.