diff --git a/src/backend.c b/src/backend.c index 6888606c410d187166cbc17e60667442bb892e84..0dd97402caf0ec3b4113e4c6aec759fca9da6e0a 100644 --- a/src/backend.c +++ b/src/backend.c @@ -191,10 +191,14 @@ void backend() while(first_object) { next_timeout.tv_usec = 0; +#if 0 next_timeout.tv_sec = 7 * 24 * 60 * 60; /* See you in a week */ +#else + next_timeout.tv_sec = 15; /* See you in a week */ +#endif my_add_timeval(&next_timeout, ¤t_time); - call_callback(& backend_callbacks); + call_callback(& backend_callbacks, (void *)0); sets=selectors; alloca(0); /* Do garbage collect */ @@ -204,6 +208,13 @@ void backend() GETTIMEOFDAY(¤t_time); my_subtract_timeval(&next_timeout, ¤t_time); + + if(next_timeout.tv_sec < 0) + { + next_timeout.tv_usec = 0; + next_timeout.tv_sec = 0; + } + i=select(max_fd+1, &sets.read, &sets.write, 0, &next_timeout); GETTIMEOFDAY(¤t_time); @@ -236,6 +247,7 @@ void backend() } } + call_callback(& backend_callbacks, (void *)1); } UNSETJMP(back); diff --git a/src/modules/call_out/call_out.c b/src/modules/call_out/call_out.c index 74ee5cb654f0cb46b3c1ae3331f4381a85316105..64f7cca89a3fcae596ea55681cb1d979ebc8d8db 100644 --- a/src/modules/call_out/call_out.c +++ b/src/modules/call_out/call_out.c @@ -181,43 +181,52 @@ void f_call_out(INT32 args) new_call_out(args,sp-args); } -void do_call_outs(struct callback *ignored, void *ignored_too) +void do_call_outs(struct callback *ignored, void *ignored_too, void *arg) { call_out *c; int args; time_t tmp; verify_call_outs(); - tmp=(time_t)TIME(0); - while(num_pending_calls && - my_timercmp(&pending_calls[0]->tv,<=,¤t_time)) + if(arg) { - /* unlink call out */ - c=pending_calls[0]; - pending_calls++; - num_pending_calls--; - - if(c->caller) free_object(c->caller); - - args=c->args->size; - push_array_items(c->args); - free((char *)c); - check_destructed(sp-args); - if(sp[-args].type!=T_INT) + tmp=(time_t)TIME(0); + while(num_pending_calls && + my_timercmp(&pending_calls[0]->tv,<=,¤t_time)) { - f_call_function(args); - pop_stack(); - }else{ - pop_n_elems(args); + /* unlink call out */ + c=pending_calls[0]; + pending_calls++; + num_pending_calls--; + + if(c->caller) free_object(c->caller); + + args=c->args->size; + push_array_items(c->args); + free((char *)c); + check_destructed(sp-args); + if(sp[-args].type!=T_INT) + { + f_call_function(args); + pop_stack(); + }else{ + pop_n_elems(args); + } + verify_call_outs(); + + if(tmp != (time_t) TIME(0)) break; + } + } + else /* if(arg) */ + { + if(num_pending_calls) + { + if(my_timercmp(& pending_calls[0]->tv, < , &next_timeout)) + { + next_timeout = pending_calls[0]->tv; + } } - verify_call_outs(); - - if(tmp != (time_t) TIME(0)) break; } - - if(num_pending_calls) - if(my_timercmp(& pending_calls[0]->tv, < , &next_timeout)) - next_timeout = pending_calls[0]->tv; } static int find_call_out(struct svalue *fun)