pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   #include "global.h" - RCSID("$Id: threads.c,v 1.125 2000/05/20 18:43:18 grubba Exp $"); + RCSID("$Id: threads.c,v 1.126 2000/05/21 18:19:35 grubba Exp $");      int num_threads = 1;   int threads_disabled = 0;      #ifdef _REENTRANT   #include "threads.h"   #include "array.h"   #include "mapping.h"   #include "object.h"   #include "pike_macros.h"
pike.git/src/threads.c:1376:      /* Thread farm code by Per    *    */   static struct farmer {    struct farmer *neighbour;    void *field;    void (*harvest)(void *);    THREAD_T me;    COND_T harvest_moon; + #ifdef HAVE_BROKEN_LINUX_THREAD_EUID +  int euid, egid; + #endif /* HAVE_BROKEN_LINUX_THREAD_EUID */   } *farmers;      static MUTEX_T rosie STATIC_MUTEX_INIT;         static int _num_farmers, _num_idle_farmers;      static TH_RETURN_TYPE farm(void *_a)   {    struct farmer *me = (struct farmer *)_a; -  +  + #ifdef HAVE_BROKEN_LINUX_THREAD_EUID +  /* Work-around for Linux's pthreads not propagating the +  * effective uid & gid. +  */ +  if (!geteuid()) { +  setegid(me->egid); +  seteuid(me->euid); +  } + #endif /* HAVE_BROKEN_LINUX_THREAD_EUID */ +     do    {   /* if(farmers == me) fatal("Ouch!\n"); */   /* fprintf(stderr, "farm_begin %p\n",me ); */    me->harvest( me->field );   /* fprintf(stderr, "farm_end %p\n", me); */       me->harvest = 0;    mt_lock( &rosie );    if( ++_num_idle_farmers > 16 )
pike.git/src/threads.c:1442:    fatal("new_farmer(): Out of memory!\n");    }       dmalloc_accept_leak(me);       _num_farmers++;    me->neighbour = 0;    me->field = args;    me->harvest = fun;    co_init( &me->harvest_moon ); +  + #ifdef HAVE_BROKEN_LINUX_THREAD_EUID +  me->euid = geteuid(); +  me->egid = getegid(); + #endif /* HAVE_BROKEN_LINUX_THREAD_EUID */ +     th_create_small(&me->me, farm, me);    return me;   }      void th_farm(void (*fun)(void *), void *here)   {    if(!fun) fatal("The farmers don't known how to handle empty fields\n");    mt_lock( &rosie );    if(farmers)    {