* cygheap.cc (cygheap_root::set): Avoid treating '/' specially.

* fhandler.cc (fhandler_base::fcntl): Only set specific O_NDELAY style flag
passed in from application.
* fhandler_socket.cc (fhandler_socket::fcntl): Ditto.
* fhandler.h: Set constant for future use.
* winsup.h: Define OLD_O_NDELAY only for old programs.
* include/cygwin/version.h: Define CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK.
This commit is contained in:
Christopher Faylor 2001-08-07 00:01:42 +00:00
parent 386abb05d9
commit 96a3f4ae68
9 changed files with 57 additions and 30 deletions

View File

@ -1,3 +1,15 @@
Mon Aug 6 19:58:43 2001 Christopher Faylor <cgf@cygnus.com>
* cygheap.cc (cygheap_root::set): Avoid treating '/' specially.
* fhandler.cc (fhandler_base::fcntl): Only set specific O_NDELAY style
flag passed in from application.
* fhandler_socket.cc (fhandler_socket::fcntl): Ditto.
* fhandler.h: Set constant for future use.
* winsup.h: Define OLD_O_NDELAY only for old programs.
* include/cygwin/version.h: Define
CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK.
Sat Aug 4 16:52:03 2001 Christopher Faylor <cgf@cygnus.com> Sat Aug 4 16:52:03 2001 Christopher Faylor <cgf@cygnus.com>
Throughout, change check for running under Windows NT to 'iswinnt'. Throughout, change check for running under Windows NT to 'iswinnt'.

View File

@ -330,6 +330,15 @@ cstrdup1 (const char *s)
void void
cygheap_root::set (const char *posix, const char *native) cygheap_root::set (const char *posix, const char *native)
{ {
if (*posix == '/' && posix[1] == '\0')
{
if (m)
{
cfree (m);
m = NULL;
}
return;
}
if (!m) if (!m)
m = (struct cygheap_root_mount_info *) ccalloc (HEAP_MOUNT, 1, sizeof (*m)); m = (struct cygheap_root_mount_info *) ccalloc (HEAP_MOUNT, 1, sizeof (*m));
strcpy (m->posix_path, posix); strcpy (m->posix_path, posix);

View File

@ -18,6 +18,7 @@ details. */
#include "cygerrno.h" #include "cygerrno.h"
#include "perprocess.h" #include "perprocess.h"
#include "security.h" #include "security.h"
#include "cygwin/version.h"
#include "fhandler.h" #include "fhandler.h"
#include "dtable.h" #include "dtable.h"
#include "cygheap.h" #include "cygheap.h"
@ -1084,15 +1085,13 @@ int fhandler_base::fcntl (int cmd, void *arg)
* ignored as well. * ignored as well.
*/ */
const int allowed_flags = O_APPEND | O_NONBLOCK | OLD_O_NDELAY; const int allowed_flags = O_APPEND | O_NONBLOCK | OLD_O_NDELAY;
int new_flags = (int) arg & allowed_flags;
/* Care for the old O_NDELAY flag. If one of the flags is set, /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
both flags are set. */ Set only the flag that has been passed in. If both are set, just
int new_flags = (int) arg; record O_NONBLOCK. */
if (new_flags & (O_NONBLOCK | OLD_O_NDELAY)) if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
new_flags |= O_NONBLOCK | OLD_O_NDELAY; new_flags = O_NONBLOCK;
set_flags ((get_flags () & ~allowed_flags) | new_flags);
int flags = get_flags () & ~allowed_flags;
set_flags (flags | (new_flags & allowed_flags));
} }
res = 0; res = 0;
break; break;

View File

@ -57,7 +57,7 @@ enum
FH_WBINSET = 0x00010000, /* binary write mode has been explicitly set */ FH_WBINSET = 0x00010000, /* binary write mode has been explicitly set */
FH_APPEND = 0x00020000, /* always append */ FH_APPEND = 0x00020000, /* always append */
FH_ASYNC = 0x00040000, /* async I/O */ FH_ASYNC = 0x00040000, /* async I/O */
FH_HADEOF = 0x00080000, /* EOF seen */ FH_SIGCLOSE = 0x00080000, /* signal handler should close fd on interrupt */
FH_SYMLINK = 0x00100000, /* is a symlink */ FH_SYMLINK = 0x00100000, /* is a symlink */
FH_EXECABL = 0x00200000, /* file looked like it would run: FH_EXECABL = 0x00200000, /* file looked like it would run:

View File

@ -24,6 +24,8 @@
#include <winsock2.h> #include <winsock2.h>
#include "cygerrno.h" #include "cygerrno.h"
#include "security.h" #include "security.h"
#include "cygwin/version.h"
#include "perprocess.h"
#include "fhandler.h" #include "fhandler.h"
#include "dtable.h" #include "dtable.h"
#include "cygheap.h" #include "cygheap.h"
@ -412,17 +414,18 @@ fhandler_socket::fcntl (int cmd, void *arg)
{ {
/* Care for the old O_NDELAY flag. If one of the flags is set, /* Care for the old O_NDELAY flag. If one of the flags is set,
both flags are set. */ both flags are set. */
int new_flags = (int) arg; const int allowed_flags = O_NONBLOCK | OLD_O_NDELAY;
if (new_flags & (O_NONBLOCK | OLD_O_NDELAY))
new_flags |= O_NONBLOCK | OLD_O_NDELAY; /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
request = (new_flags & O_NONBLOCK) ? 1 : 0; Set only the flag that has been passed in. If both are set, just
current = (get_flags () & O_NONBLOCK) ? 1 : 0; record O_NONBLOCK. */
if (request != current && (res = ioctl (FIONBIO, &request))) int new_flags = (int) arg & allowed_flags;
if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
new_flags = O_NONBLOCK;
current = get_flags () & allowed_flags;
if (!!current != !!new_flags && (res = ioctl (FIONBIO, &request)))
break; break;
if (request) set_flags ((get_flags () & ~allowed_flags) | new_flags);
set_flags (get_flags () | O_NONBLOCK | OLD_O_NDELAY);
else
set_flags (get_flags () & ~(O_NONBLOCK | OLD_O_NDELAY));
break; break;
} }
default: default:

View File

@ -82,6 +82,10 @@ details. */
#define CYGWIN_VERSION_CHECK_FOR_S_IEXEC \ #define CYGWIN_VERSION_CHECK_FOR_S_IEXEC \
(CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) >= \ (CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) >= \
36) 36)
#define CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK \
(CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) <= \
28)
/* We used to use the DLL major/minor to track /* We used to use the DLL major/minor to track
non-backward-compatible interface changes to the API. Now we non-backward-compatible interface changes to the API. Now we
use an API major/minor number for this purpose. */ use an API major/minor number for this purpose. */

View File

@ -904,9 +904,9 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
struct sockaddr_in peer_dummy; struct sockaddr_in peer_dummy;
int len_dummy; int len_dummy;
if (!peer) if (!peer)
peer = (struct sockaddr *) &peer_dummy; peer = (struct sockaddr *) &peer_dummy;
if (!len) if (!len)
{ {
len_dummy = sizeof (struct sockaddr_in); len_dummy = sizeof (struct sockaddr_in);
len = &len_dummy; len = &len_dummy;
} }

View File

@ -1,6 +1,6 @@
/* pipe.cc: pipe for Cygwin. /* pipe.cc: pipe for Cygwin.
Copyright 1996, 1998, 1999, 2000 Cygnus Solutions. Copyright 1996, 1998, 1999, 2000, 2001 Cygnus Solutions.
This file is part of Cygwin. This file is part of Cygwin.
@ -22,7 +22,7 @@ details. */
static int static int
make_pipe (int fildes[2], unsigned int psize, int mode) make_pipe (int fildes[2], unsigned int psize, int mode)
{ {
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," make_pipe"); SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "make_pipe");
HANDLE r, w; HANDLE r, w;
int fdr = -1, fdw = -1; int fdr = -1, fdw = -1;
@ -37,8 +37,8 @@ make_pipe (int fildes[2], unsigned int psize, int mode)
__seterrno (); __seterrno ();
else else
{ {
fhandler_base *fhr = cygheap->fdtab.build_fhandler (fdr, FH_PIPER, "/dev/piper"); fhandler_pipe *fhr = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdr, FH_PIPER, "/dev/piper");
fhandler_base *fhw = cygheap->fdtab.build_fhandler (fdw, FH_PIPEW, "/dev/pipew"); fhandler_pipe *fhw = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdw, FH_PIPEW, "/dev/pipew");
int binmode = mode & O_TEXT ? 0 : 1; int binmode = mode & O_TEXT ? 0 : 1;
fhr->init (r, GENERIC_READ, binmode); fhr->init (r, GENERIC_READ, binmode);
@ -56,7 +56,7 @@ make_pipe (int fildes[2], unsigned int psize, int mode)
} }
syscall_printf ("%d = make_pipe ([%d, %d], %d, %p)", res, fdr, fdw, psize, mode); syscall_printf ("%d = make_pipe ([%d, %d], %d, %p)", res, fdr, fdw, psize, mode);
ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," make_pipe"); ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "make_pipe");
return res; return res;
} }
@ -81,11 +81,11 @@ int
dup (int fd) dup (int fd)
{ {
int res; int res;
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," dup"); SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup");
res = dup2 (fd, cygheap->fdtab.find_unused_handle ()); res = dup2 (fd, cygheap->fdtab.find_unused_handle ());
ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," dup"); ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup");
return res; return res;
} }

View File

@ -250,7 +250,7 @@ extern SYSTEM_INFO system_info;
/* newlib used to define O_NDELAY differently from O_NONBLOCK. Now it /* newlib used to define O_NDELAY differently from O_NONBLOCK. Now it
properly defines both to be the same. Unfortunately, we have to properly defines both to be the same. Unfortunately, we have to
behave properly the old version, too, to accomodate older executables. */ behave properly the old version, too, to accomodate older executables. */
#define OLD_O_NDELAY 4 #define OLD_O_NDELAY (CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK ? 4 : 0)
/* The title on program start. */ /* The title on program start. */
extern char *old_title; extern char *old_title;