* dll_init.h (class dll_list): Reorder functions to avoid compiler "can't
inline" warnings. * security.h (class cygsid): Ditto. * sigproc.cc (get_proc_lock): Ditto. * sigproc.h (class sigframe): Ditto. * sync.h (class muto): Ditto. * fhandler.h (fhandler_base::get_guard): Actually MAKE virtual as previously indicated. * pipe.cc (make_pipe): Remove extraneous set_errno. * syscalls.cc (_open): Ditto. * select.cc (peek_pipe): Need to check that there is still something to read from the pipe after acquiring the mutex since another process/thread could have eaten the input before we got to acquiring the lock. (Thanks to Nick Duffek for this inspiration.)
This commit is contained in:
parent
01432054cb
commit
243a041bd0
@ -1,3 +1,23 @@
|
|||||||
|
2001-11-02 Egor Duda <deo@logos-m.ru>
|
||||||
|
|
||||||
|
* dll_init.h (class dll_list): Reorder functions to avoid compiler
|
||||||
|
"can't inline" warnings.
|
||||||
|
* security.h (class cygsid): Ditto.
|
||||||
|
* sigproc.cc (get_proc_lock): Ditto.
|
||||||
|
* sigproc.h (class sigframe): Ditto.
|
||||||
|
* sync.h (class muto): Ditto.
|
||||||
|
|
||||||
|
2001-11-02 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
|
* fhandler.h (fhandler_base::get_guard): Actually MAKE virtual as
|
||||||
|
previously indicated.
|
||||||
|
* pipe.cc (make_pipe): Remove extraneous set_errno.
|
||||||
|
* syscalls.cc (_open): Ditto.
|
||||||
|
* select.cc (peek_pipe): Need to check that there is still something to
|
||||||
|
read from the pipe after acquiring the mutex since another
|
||||||
|
process/thread could have eaten the input before we got to acquiring
|
||||||
|
the lock. (Thanks to Nick Duffek for this inspiration.)
|
||||||
|
|
||||||
2001-11-01 Christopher Faylor <cgf@redhat.com>
|
2001-11-01 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* fhandler.h: Change Windows 'BOOL's to c++ 'bool's for all variables.
|
* fhandler.h: Change Windows 'BOOL's to c++ 'bool's for all variables.
|
||||||
|
@ -73,12 +73,6 @@ public:
|
|||||||
void detach (dll *);
|
void detach (dll *);
|
||||||
void init ();
|
void init ();
|
||||||
void load_after_fork (HANDLE, dll *);
|
void load_after_fork (HANDLE, dll *);
|
||||||
dll *istart (dll_type t)
|
|
||||||
{
|
|
||||||
hold_type = t;
|
|
||||||
hold = &start;
|
|
||||||
return inext ();
|
|
||||||
}
|
|
||||||
dll *inext ()
|
dll *inext ()
|
||||||
{
|
{
|
||||||
while ((hold = hold->next))
|
while ((hold = hold->next))
|
||||||
@ -86,6 +80,12 @@ public:
|
|||||||
break;
|
break;
|
||||||
return hold;
|
return hold;
|
||||||
}
|
}
|
||||||
|
dll *istart (dll_type t)
|
||||||
|
{
|
||||||
|
hold_type = t;
|
||||||
|
hold = &start;
|
||||||
|
return inext ();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern dll_list dlls;
|
extern dll_list dlls;
|
||||||
|
@ -371,7 +371,7 @@ class fhandler_base
|
|||||||
rabuf = NULL;
|
rabuf = NULL;
|
||||||
}
|
}
|
||||||
void operator delete (void *);
|
void operator delete (void *);
|
||||||
HANDLE get_guard () const {return NULL;}
|
virtual HANDLE get_guard () const {return NULL;}
|
||||||
};
|
};
|
||||||
|
|
||||||
class fhandler_socket: public fhandler_base
|
class fhandler_socket: public fhandler_base
|
||||||
|
@ -133,13 +133,11 @@ make_pipe (int fildes[2], unsigned int psize, int mode)
|
|||||||
int res = -1;
|
int res = -1;
|
||||||
|
|
||||||
cygheap_fdnew fdr;
|
cygheap_fdnew fdr;
|
||||||
if (fdr < 0)
|
if (fdr >= 0)
|
||||||
/* saw an error */;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
cygheap_fdnew fdw (fdr, false);
|
cygheap_fdnew fdw (fdr, false);
|
||||||
if (fdw < 0)
|
if (fdw < 0)
|
||||||
set_errno (ENMFILE);
|
/* out of fds? */;
|
||||||
else if (!CreatePipe (&r, &w, sa, psize))
|
else if (!CreatePipe (&r, &w, sa, psize))
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
else
|
else
|
||||||
|
@ -39,6 +39,15 @@ class cygsid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
inline operator const PSID () { return psid; }
|
||||||
|
|
||||||
|
inline const PSID operator= (cygsid &nsid)
|
||||||
|
{ return assign (nsid); }
|
||||||
|
inline const PSID operator= (const PSID nsid)
|
||||||
|
{ return assign (nsid); }
|
||||||
|
inline const PSID operator= (const char *nsidstr)
|
||||||
|
{ return getfromstr (nsidstr); }
|
||||||
|
|
||||||
inline cygsid () : psid ((PSID) sbuf) {}
|
inline cygsid () : psid ((PSID) sbuf) {}
|
||||||
inline cygsid (const PSID nsid) { *this = nsid; }
|
inline cygsid (const PSID nsid) { *this = nsid; }
|
||||||
inline cygsid (const char *nstrsid) { *this = nstrsid; }
|
inline cygsid (const char *nstrsid) { *this = nstrsid; }
|
||||||
@ -54,13 +63,6 @@ public:
|
|||||||
|
|
||||||
char *string (char *nsidstr) const;
|
char *string (char *nsidstr) const;
|
||||||
|
|
||||||
inline const PSID operator= (cygsid &nsid)
|
|
||||||
{ return assign (nsid); }
|
|
||||||
inline const PSID operator= (const PSID nsid)
|
|
||||||
{ return assign (nsid); }
|
|
||||||
inline const PSID operator= (const char *nsidstr)
|
|
||||||
{ return getfromstr (nsidstr); }
|
|
||||||
|
|
||||||
inline BOOL operator== (const PSID nsid) const
|
inline BOOL operator== (const PSID nsid) const
|
||||||
{
|
{
|
||||||
if (!psid || !nsid)
|
if (!psid || !nsid)
|
||||||
@ -77,8 +79,6 @@ public:
|
|||||||
inline BOOL operator!= (const char *nsidstr) const
|
inline BOOL operator!= (const char *nsidstr) const
|
||||||
{ return !(*this == nsidstr); }
|
{ return !(*this == nsidstr); }
|
||||||
|
|
||||||
inline operator const PSID () { return psid; }
|
|
||||||
|
|
||||||
void debug_print (const char *prefix = NULL) const
|
void debug_print (const char *prefix = NULL) const
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
@ -389,7 +389,7 @@ peek_pipe (select_record *s, int ignra)
|
|||||||
fhandler_base *fh = s->fh;
|
fhandler_base *fh = s->fh;
|
||||||
|
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
HANDLE guard_mutex = s->fh->get_guard ();
|
HANDLE guard_mutex = fh->get_guard ();
|
||||||
set_handle_or_return_if_not_open (h, s);
|
set_handle_or_return_if_not_open (h, s);
|
||||||
|
|
||||||
/* Don't perform complicated tests if we don't need to. */
|
/* Don't perform complicated tests if we don't need to. */
|
||||||
@ -438,12 +438,23 @@ peek_pipe (select_record *s, int ignra)
|
|||||||
select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ());
|
select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ());
|
||||||
n = -1;
|
n = -1;
|
||||||
}
|
}
|
||||||
else if (n && guard_mutex
|
else if (n && guard_mutex)
|
||||||
&& WaitForSingleObject (guard_mutex, 0) != WAIT_OBJECT_0)
|
|
||||||
{
|
{
|
||||||
select_printf ("%s, couldn't get mutex %p, %E", fh->get_name (),
|
if (WaitForSingleObject (guard_mutex, 0) != WAIT_OBJECT_0)
|
||||||
guard_mutex);
|
{
|
||||||
n = 0;
|
select_printf ("%s, couldn't get mutex %p, %E", fh->get_name (),
|
||||||
|
guard_mutex);
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
|
/* Now that we have the mutex, make sure that no one else has snuck
|
||||||
|
in and grabbed the data that we originally saw. */
|
||||||
|
if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))
|
||||||
|
{
|
||||||
|
select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ());
|
||||||
|
n = -1;
|
||||||
|
}
|
||||||
|
if (n <= 0)
|
||||||
|
ReleaseMutex (guard_mutex); /* Oops. We lost the race. */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
|
@ -179,6 +179,29 @@ wait_for_me ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get the sync_proc_subproc muto to control access to
|
||||||
|
* children, zombie arrays.
|
||||||
|
* Attempt to handle case where process is exiting as we try to grab
|
||||||
|
* the mutex.
|
||||||
|
*/
|
||||||
|
static BOOL
|
||||||
|
get_proc_lock (DWORD what, DWORD val)
|
||||||
|
{
|
||||||
|
Static int lastwhat = -1;
|
||||||
|
if (!sync_proc_subproc)
|
||||||
|
return FALSE;
|
||||||
|
if (sync_proc_subproc->acquire (WPSP))
|
||||||
|
{
|
||||||
|
lastwhat = what;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if (!sync_proc_subproc)
|
||||||
|
return FALSE;
|
||||||
|
system_printf ("Couldn't aquire sync_proc_subproc for(%d,%d), %E, last %d",
|
||||||
|
what, val, lastwhat);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL __stdcall
|
static BOOL __stdcall
|
||||||
proc_can_be_signalled (_pinfo *p)
|
proc_can_be_signalled (_pinfo *p)
|
||||||
{
|
{
|
||||||
@ -939,29 +962,6 @@ getsem (_pinfo *p, const char *str, int init, int max)
|
|||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the sync_proc_subproc muto to control access to
|
|
||||||
* children, zombie arrays.
|
|
||||||
* Attempt to handle case where process is exiting as we try to grab
|
|
||||||
* the mutex.
|
|
||||||
*/
|
|
||||||
static BOOL
|
|
||||||
get_proc_lock (DWORD what, DWORD val)
|
|
||||||
{
|
|
||||||
Static int lastwhat = -1;
|
|
||||||
if (!sync_proc_subproc)
|
|
||||||
return FALSE;
|
|
||||||
if (sync_proc_subproc->acquire (WPSP))
|
|
||||||
{
|
|
||||||
lastwhat = what;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
if (!sync_proc_subproc)
|
|
||||||
return FALSE;
|
|
||||||
system_printf ("Couldn't aquire sync_proc_subproc for(%d,%d), %E, last %d",
|
|
||||||
what, val, lastwhat);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove a zombie from zombies by swapping it with the last child in the list.
|
/* Remove a zombie from zombies by swapping it with the last child in the list.
|
||||||
*/
|
*/
|
||||||
static void __stdcall
|
static void __stdcall
|
||||||
|
@ -73,9 +73,6 @@ public:
|
|||||||
if (!oframe)
|
if (!oframe)
|
||||||
t.get_winapi_lock ();
|
t.get_winapi_lock ();
|
||||||
}
|
}
|
||||||
|
|
||||||
sigframe (): st (NULL) {}
|
|
||||||
sigframe (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0)) {init (t, ebp);}
|
|
||||||
inline void init (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0))
|
inline void init (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0))
|
||||||
{
|
{
|
||||||
if (!t.frame && t.id == GetCurrentThreadId ())
|
if (!t.frame && t.id == GetCurrentThreadId ())
|
||||||
@ -83,6 +80,9 @@ public:
|
|||||||
else
|
else
|
||||||
st = NULL;
|
st = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sigframe (): st (NULL) {}
|
||||||
|
sigframe (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0)) {init (t, ebp);}
|
||||||
~sigframe ()
|
~sigframe ()
|
||||||
{
|
{
|
||||||
unregister ();
|
unregister ();
|
||||||
|
@ -22,14 +22,16 @@ class muto
|
|||||||
public:
|
public:
|
||||||
class muto *next;
|
class muto *next;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
|
muto() {}
|
||||||
|
/* The real constructor. */
|
||||||
|
muto(int inh, const char *name);
|
||||||
|
|
||||||
void *operator new (size_t, void *p) {return p;}
|
void *operator new (size_t, void *p) {return p;}
|
||||||
void *operator new (size_t) {return ::new muto; }
|
void *operator new (size_t) {return ::new muto; }
|
||||||
void operator delete (void *) {;} /* can't handle allocated mutos
|
void operator delete (void *) {;} /* can't handle allocated mutos
|
||||||
currently */
|
currently */
|
||||||
|
|
||||||
muto() {}
|
|
||||||
/* The real constructor. */
|
|
||||||
muto(int inh, const char *name);
|
|
||||||
~muto ();
|
~muto ();
|
||||||
int acquire (DWORD ms = INFINITE) __attribute__ ((regparm(1))); /* Acquire the lock. */
|
int acquire (DWORD ms = INFINITE) __attribute__ ((regparm(1))); /* Acquire the lock. */
|
||||||
int release (); /* Release the lock. */
|
int release (); /* Release the lock. */
|
||||||
|
@ -499,9 +499,7 @@ _open (const char *unix_path, int flags, ...)
|
|||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
cygheap_fdnew fd;
|
cygheap_fdnew fd;
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd >= 0)
|
||||||
set_errno (ENMFILE);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
path_conv pc;
|
path_conv pc;
|
||||||
if (!(fh = cygheap->fdtab.build_fhandler_from_name (fd, unix_path,
|
if (!(fh = cygheap->fdtab.build_fhandler_from_name (fd, unix_path,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user