Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-11-03 06:32:27 +0300
committerChristopher Faylor <me@cgf.cx>2001-11-03 06:32:27 +0300
commit243a041bd0164aa62813ac4ba5a1a02eb2db455b (patch)
treeaf591a485215fcd4578be09cfabe6ff75b0782fe
parent01432054cb24122d300f109d4d252a9c95835a9b (diff)
* 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.)
-rw-r--r--winsup/cygwin/ChangeLog20
-rw-r--r--winsup/cygwin/dll_init.h12
-rw-r--r--winsup/cygwin/fhandler.h2
-rw-r--r--winsup/cygwin/pipe.cc6
-rw-r--r--winsup/cygwin/security.h18
-rw-r--r--winsup/cygwin/select.cc23
-rw-r--r--winsup/cygwin/sigproc.cc46
-rw-r--r--winsup/cygwin/sigproc.h6
-rw-r--r--winsup/cygwin/sync.h8
-rw-r--r--winsup/cygwin/syscalls.cc4
10 files changed, 87 insertions, 58 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 14d77c050..a5192053c 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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>
* fhandler.h: Change Windows 'BOOL's to c++ 'bool's for all variables.
diff --git a/winsup/cygwin/dll_init.h b/winsup/cygwin/dll_init.h
index a5b33d572..bc9687bf7 100644
--- a/winsup/cygwin/dll_init.h
+++ b/winsup/cygwin/dll_init.h
@@ -73,12 +73,6 @@ public:
void detach (dll *);
void init ();
void load_after_fork (HANDLE, dll *);
- dll *istart (dll_type t)
- {
- hold_type = t;
- hold = &start;
- return inext ();
- }
dll *inext ()
{
while ((hold = hold->next))
@@ -86,6 +80,12 @@ public:
break;
return hold;
}
+ dll *istart (dll_type t)
+ {
+ hold_type = t;
+ hold = &start;
+ return inext ();
+ }
};
extern dll_list dlls;
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 76c3ff0bb..fa753cd19 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -371,7 +371,7 @@ class fhandler_base
rabuf = NULL;
}
void operator delete (void *);
- HANDLE get_guard () const {return NULL;}
+ virtual HANDLE get_guard () const {return NULL;}
};
class fhandler_socket: public fhandler_base
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index fed1add0f..904dbd27b 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -133,13 +133,11 @@ make_pipe (int fildes[2], unsigned int psize, int mode)
int res = -1;
cygheap_fdnew fdr;
- if (fdr < 0)
- /* saw an error */;
- else
+ if (fdr >= 0)
{
cygheap_fdnew fdw (fdr, false);
if (fdw < 0)
- set_errno (ENMFILE);
+ /* out of fds? */;
else if (!CreatePipe (&r, &w, sa, psize))
__seterrno ();
else
diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h
index 95f97b8ca..53c94c8f9 100644
--- a/winsup/cygwin/security.h
+++ b/winsup/cygwin/security.h
@@ -39,6 +39,15 @@ class cygsid {
}
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 (const PSID nsid) { *this = nsid; }
inline cygsid (const char *nstrsid) { *this = nstrsid; }
@@ -54,13 +63,6 @@ public:
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
{
if (!psid || !nsid)
@@ -77,8 +79,6 @@ public:
inline BOOL operator!= (const char *nsidstr) const
{ return !(*this == nsidstr); }
- inline operator const PSID () { return psid; }
-
void debug_print (const char *prefix = NULL) const
{
char buf[256];
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index 1ba3ef3d8..78d1aaabe 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -389,7 +389,7 @@ peek_pipe (select_record *s, int ignra)
fhandler_base *fh = s->fh;
HANDLE h;
- HANDLE guard_mutex = s->fh->get_guard ();
+ HANDLE guard_mutex = fh->get_guard ();
set_handle_or_return_if_not_open (h, s);
/* 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 ());
n = -1;
}
- else if (n && guard_mutex
- && WaitForSingleObject (guard_mutex, 0) != WAIT_OBJECT_0)
+ else if (n && guard_mutex)
{
- select_printf ("%s, couldn't get mutex %p, %E", fh->get_name (),
- guard_mutex);
- n = 0;
+ if (WaitForSingleObject (guard_mutex, 0) != WAIT_OBJECT_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)
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index fd5008abd..fdc7a6fef 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -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
proc_can_be_signalled (_pinfo *p)
{
@@ -939,29 +962,6 @@ getsem (_pinfo *p, const char *str, int init, int max)
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.
*/
static void __stdcall
diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h
index 493078b9d..dc67b6b08 100644
--- a/winsup/cygwin/sigproc.h
+++ b/winsup/cygwin/sigproc.h
@@ -73,9 +73,6 @@ public:
if (!oframe)
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))
{
if (!t.frame && t.id == GetCurrentThreadId ())
@@ -83,6 +80,9 @@ public:
else
st = NULL;
}
+
+ sigframe (): st (NULL) {}
+ sigframe (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0)) {init (t, ebp);}
~sigframe ()
{
unregister ();
diff --git a/winsup/cygwin/sync.h b/winsup/cygwin/sync.h
index 995d98ef6..a32dadb97 100644
--- a/winsup/cygwin/sync.h
+++ b/winsup/cygwin/sync.h
@@ -22,14 +22,16 @@ class muto
public:
class muto *next;
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) {return ::new muto; }
void operator delete (void *) {;} /* can't handle allocated mutos
currently */
- muto() {}
- /* The real constructor. */
- muto(int inh, const char *name);
~muto ();
int acquire (DWORD ms = INFINITE) __attribute__ ((regparm(1))); /* Acquire the lock. */
int release (); /* Release the lock. */
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index b11e6795b..b433c3dde 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -499,9 +499,7 @@ _open (const char *unix_path, int flags, ...)
fhandler_base *fh;
cygheap_fdnew fd;
- if (fd < 0)
- set_errno (ENMFILE);
- else
+ if (fd >= 0)
{
path_conv pc;
if (!(fh = cygheap->fdtab.build_fhandler_from_name (fd, unix_path,