Changeset 762


Ignore:
Timestamp:
07/14/06 01:11:45 (6 years ago)
Author:
wd
Message:

Add recursion protection to log.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ithildin-1.1/source/log.c

    r578 r762  
    8383} 
    8484 
     85/* Recursion protection for logged messages.  If we log_*() and then hook an 
     86 * event which generates a log_*() we can end up in serious trouble. :) */ 
     87#define LOG_RECURSE_MAX 10 
     88static uint32_t log_recursed; 
     89 
    8590void log_vmsg(enum logtypes type, const char *mod, const char *msg, 
    8691        va_list ap) { 
     
    9196        return; /* avoid doing anything for debug messages when we don't 
    9297                   want to */ 
     98 
     99    log_recursed++; 
     100    if (log_recursed == LOG_RECURSE_MAX) { 
     101        log_recursed--; 
     102        return; 
     103    } 
    93104 
    94105    vsnprintf(logmsg, LOG_MSG_MAXLEN, msg, ap); 
     
    115126            break; 
    116127    } 
     128 
     129    log_recursed--; 
    117130} 
    118131 
Note: See TracChangeset for help on using the changeset viewer.