From ea32c119a6dcb99b6c7c99137212dca4d97add09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Mon, 13 Apr 1998 16:28:24 +0200 Subject: [PATCH] Somewhat improved threads_disabled handling. Rev: src/program.c:1.77 --- src/program.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/src/program.c b/src/program.c index 268b268b39..681fb6580e 100644 --- a/src/program.c +++ b/src/program.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: program.c,v 1.76 1998/04/10 22:24:21 hubbe Exp $"); +RCSID("$Id: program.c,v 1.77 1998/04/13 14:28:24 grubba Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -392,6 +392,24 @@ void fixate_program(void) new_program->flags |= PROGRAM_FIXED; } +/* + * Error handler. + * + * This function should not normally be called, + * but is here for safety reasons. + */ +void restore_threads_disabled(void *arg) +{ + fprintf(stderr, "restore_threads_disabled(): threads_disabled:%d, compilation_depth:%d\n", threads_disabled, compilation_depth); +#ifdef DEBUG + fatal("restore_threads_disabled() called\n"); +#endif /* DEBUG */ + + if (threads_disabled) + threads_disabled--; + co_signal(&threads_disabled_change); +} + /* * Start building a new program */ @@ -404,6 +422,8 @@ void low_start_new_program(struct program *p, threads_disabled++; compilation_depth++; + /* fprintf(stderr, "low_start_new_program(): compilation_depth:%d\n", compilation_depth); */ + if(!p) { p=ALLOC_STRUCT(program); @@ -510,6 +530,7 @@ void low_start_new_program(struct program *p, void start_new_program(void) { + /* fprintf(stderr, "start_new_program(): threads_disabled:%d, compilation_depth:%d\n", threads_disabled, compilation_depth); */ low_start_new_program(0,0,0); } @@ -837,6 +858,9 @@ struct program *end_first_pass(int finish) compilation_depth--; threads_disabled--; co_signal(&threads_disabled_change); + + /* fprintf(stderr, "end_first_pass(): compilation_depth:%d\n", compilation_depth); */ + free_all_nodes(); return prog; } @@ -1889,10 +1913,10 @@ static int get_small_number(char **q) void start_line_numbering(void) { if(last_file) - { - free_string(last_file); - last_file=0; - } + { + free_string(last_file); + last_file=0; + } last_pc=last_line=0; } @@ -2004,6 +2028,7 @@ struct program *compile(struct pike_string *prog) struct lex save_lex; int save_depth=compilation_depth; void yyparse(void); + ONERROR just_in_case; save_lex=lex; @@ -2012,6 +2037,11 @@ struct program *compile(struct pike_string *prog) lex.current_file=make_shared_string("-"); lex.pragmas=0; + threads_disabled++; + SET_ONERROR(just_in_case, restore_threads_disabled, NULL); + + /* fprintf(stderr, "compile() Enter: threads_disabled:%d, compilation_depth:%d\n", threads_disabled, compilation_depth); */ + start_new_program(); compilation_depth=0; @@ -2034,6 +2064,11 @@ struct program *compile(struct pike_string *prog) p=end_program(); } + threads_disabled--; + fprintf(stderr, "compile() Leave: threads_disabled:%d, compilation_depth:%d\n", threads_disabled, compilation_depth); + co_signal(&threads_disabled_change); + + UNSET_ONERROR(just_in_case); free_string(lex.current_file); lex=save_lex; -- GitLab