Changeset 340c3e7


Ignore:
Timestamp:
Oct 3, 2009, 10:12:06 AM (12 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
8830f79f
Parents:
40bda84
git-author:
Nelson Elhage <nelhage@mit.edu> (09/12/09 19:47:59)
git-committer:
Nelson Elhage <nelhage@mit.edu> (10/03/09 10:12:06)
Message:
owl_function_error: Bail out early in the case of recursive errors.

owl_function_adminmsg triggers a lot of code, and so it is possible that
whatever caused an error will also cause owl_function_adminmsg to error
out. Watch for recursive calls to owl_function_error, and bail out early
to prevent infinite looping.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    rb0a6ea0 r340c3e7  
    33973397void owl_function_error(const char *fmt, ...)
    33983398{
     3399  static int in_error = 0;
    33993400  va_list ap;
    34003401  char *buff;
    34013402  const char *nl;
    34023403
     3404  if (++in_error > 2) {
     3405    /* More than two nested errors, bail immediately. */
     3406    in_error--;
     3407    return;
     3408  }
     3409
    34033410  va_start(ap, fmt);
    3404 
    34053411  buff = g_strdup_vprintf(fmt, ap);
     3412  va_end(ap);
     3413
    34063414  owl_function_debugmsg("ERROR: %s", buff);
     3415  owl_function_log_err(buff);
     3416
    34073417  nl = strchr(buff, '\n');
    3408   if(nl && *(nl + 1)) {
     3418
     3419  /*
     3420    Showing admin messages triggers a lot of code. If we have a
     3421    recursive error call, that's the most likely candidate, so
     3422    suppress the call in that case, to try to avoid infinite looping.
     3423  */
     3424
     3425  if(nl && *(nl + 1) && in_error == 1) {
    34093426    /* Multiline error */
    34103427    owl_function_adminmsg("ERROR", buff);
     
    34123429    owl_function_makemsg("[Error] %s", buff);
    34133430  }
    3414   owl_function_log_err(buff);
    3415   va_end(ap);
     3431
    34163432  owl_free(buff);
     3433
     3434  in_error--;
    34173435}
    34183436
Note: See TracChangeset for help on using the changeset viewer.