Branch: Tag:

2002-01-30

2002-01-30 22:06:04 by Marcus Comstedt <marcus@mc.pp.se>

Handle exceptions in pike_module_init and pike_module_exit properly.

Rev: src/dynamic_load.c:1.58

15:   # include "main.h"   # include "constants.h"    - RCSID("$Id: dynamic_load.c,v 1.57 2001/11/26 14:54:07 grubba Exp $"); + RCSID("$Id: dynamic_load.c,v 1.58 2002/01/30 22:06:04 marcus Exp $");      #else /* TESTING */   
332:   #define CAST_TO_FUN(X) ((modfun)X)   #endif /* NO_CAST_TO_FUN */    + static void cleanup_compilation_depth(int *save_depth_p) + { +  free_program(end_program()); +  compilation_depth=*save_depth_p; + } +    /*! @decl int load_module(string module_name)    *!    *! Load a binary module.
359:    struct module_list *new_module;    const char *module_name;    +  ONERROR err; +     int save_depth=compilation_depth;       if(sp[-args].type != T_STRING)
420: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG    { struct svalue *save_sp=sp;   #endif +  SET_ONERROR(err, cleanup_compilation_depth, &save_depth);    (*(modfun)init)(); -  +  UNSET_ONERROR(err);   #ifdef PIKE_DEBUG    if(sp != save_sp)    fatal("load_module(%s) left %ld droppings on stack!\n",
455: Inside #if defined(USE_DYNAMIC_MODULES)
  {   #ifdef USE_DYNAMIC_MODULES    struct module_list *tmp; +  JMP_BUF recovery;    for (tmp = dynamic_module_list; tmp; tmp = tmp->next) -  +  { +  if(SETJMP(recovery)) +  call_handle_error(); +  else    (*tmp->exit)(); -  +  UNSETJMP(recovery); +  }   #endif   }