Branch: Tag:

2002-02-05

2002-02-05 19:15:23 by Martin Stjernholm <mast@lysator.liu.se>

Fixed calls to check_threads_etc in many places where we wait a while and
can be interrupted by signals.

Rev: src/backend.cmod:1.23
Rev: src/builtin_functions.c:1.420
Rev: src/dlopen.c:1.29
Rev: src/modules/CommonLog/clf.c:1.7
Rev: src/modules/Image/font.c:1.70
Rev: src/modules/Pipe/pipe.c:1.47
Rev: src/modules/files/efuns.c:1.110
Rev: src/modules/files/file.c:1.232
Rev: src/modules/files/socket.c:1.59
Rev: src/modules/files/udp.c:1.29
Rev: src/modules/system/system.c:1.120
Rev: src/object.c:1.197
Rev: src/signal_handler.c:1.216
Rev: src/threads.c:1.178

1:   #include "global.h" - RCSID("$Id: threads.c,v 1.177 2001/12/16 02:49:44 mast Exp $"); + RCSID("$Id: threads.c,v 1.178 2002/02/05 19:15:23 mast Exp $");      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;
21:   #include "pike_types.h"   #include "operators.h"   #include "bignum.h" + #include "signal_handler.h"      #include <errno.h>   
821:    tmp = th_create(& OBJ2THREAD(arg->id)->id,    new_thread_func,    arg); +  if (tmp == EINTR) check_threads_etc();    } while( tmp == EINTR );       if(!tmp)
1010:    free_object(o);    Pike_error("Cannot wait for mutexes when threads are disabled!\n");    } -  SWAP_OUT_CURRENT_THREAD(); +     do    { -  +  SWAP_OUT_CURRENT_THREAD();    THREADS_FPRINTF(1, (stderr,"WAITING TO LOCK m:%08x\n",(unsigned int)m));    co_wait_interpreter(& m->condition); -  }while(m->key); +     SWAP_IN_CURRENT_THREAD(); -  +  check_threads_etc(); +  }while(m->key);    }    m->key=o;    OB2KEY(o)->mut=m;
1268:    /* Wait and allow mutex operations */    SWAP_OUT_CURRENT_THREAD();    co_wait_interpreter(c); +  SWAP_IN_CURRENT_THREAD();       /* Lock mutex */ -  while(mut->key) +  while(mut->key) { +  SWAP_OUT_CURRENT_THREAD();    co_wait_interpreter(& mut->condition); -  +  SWAP_IN_CURRENT_THREAD(); +  check_threads_etc(); +  }    mut->key=key;    OB2KEY(key)->mut=mut;    -  SWAP_IN_CURRENT_THREAD(); +     pop_n_elems(args);    return;    }
1398:    Pike_error("Cannot wait for threads when threads are disabled!\n");    }    +  while(th->status != THREAD_EXITED) {    SWAP_OUT_CURRENT_THREAD(); -  -  while(th->status != THREAD_EXITED) +     co_wait_interpreter(&th->status_change); -  +     SWAP_IN_CURRENT_THREAD(); -  +  check_threads_etc(); +  }       low_object_index_no_free(Pike_sp,    Pike_fp->current_object,