diff options
author | scottc <scottc> | 2002-07-03 16:01:44 +0000 |
---|---|---|
committer | scottc <scottc> | 2002-07-03 16:01:44 +0000 |
commit | 6f7fadc9fc4c4a24ae81585a5c57ddd065e8a4a1 (patch) | |
tree | 035105e83f2e44f493678ffd2bcbf60265a5612b | |
parent | e96c80d0e1fa4130f6f4b764f86e7de12fc1512e (diff) | |
download | gdb-6f7fadc9fc4c4a24ae81585a5c57ddd065e8a4a1.tar.gz |
Merged changes from HEAD
-rw-r--r-- | winsup/cygwin/ChangeLog | 25 | ||||
-rw-r--r-- | winsup/cygwin/autoload.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/cygheap.cc | 26 | ||||
-rw-r--r-- | winsup/cygwin/dtable.cc | 29 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_dsp.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 90 | ||||
-rw-r--r-- | winsup/cygwin/net.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/pipe.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/sec_helper.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/tty.cc | 2 |
10 files changed, 121 insertions, 61 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c33246d74b4..ac1bc6116ee 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,17 @@ 2002-07-03 Conrad Scott <conrad.scott@dsl.pipex.com> + * tty.cc (tty::common_init): Reverse logic of cygserver check in + call to SetKernelObjectSecurity. + +2002-07-03 Thomas Pfaff <tpfaff@gmx.net> + + * autoload.cc (WSAEventSelect): Define new autoload function. + (WSAEnumNetworkEvents): Ditto. + * fhandler_socket.cc (fhandler_socket::accept): If socket is + in blocking mode wait for incoming connection and signal. + +2002-07-03 Conrad Scott <conrad.scott@dsl.pipex.com> + * dcrt0.cc: Only check for cygserver if and when required. (dll_crt0_1): Remove call to `cygserver_init ()'. * fhandler_tty.cc (fhandler_tty_slave::open): Change the cygserver @@ -114,6 +126,19 @@ (client_shmmgr::instance): Allocate a new shmmgr on the heap, rather than using a local static object. +2002-07-02 Christopher Faylor <cgf@redhat.com> + + * cygheap.cc (init_cheap): Rearrange error message. + (cygheap_fixup_in_child): Ditto. + * dtable.cc: Remove if 0'ed code. + * fhandler_dsp.cc (fhandler_dev_dsp::open): Force binmode. + * sec_helper.cc (cygsid::get_id): Use system_printf for error message. + * tty.cc (tty::common_init): Ditto. + +2002-07-02 Christopher Faylor <cgf@redhat.com> + + * net.cc (cygwin_getpeername): Defend against NULL pointer dereference. + 2002-07-02 Egor Duda <deo@logos-m.ru> * include/cygwin/version.h: Bump API minor version. diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc index 5c14ff11551..05141e53faa 100644 --- a/winsup/cygwin/autoload.cc +++ b/winsup/cygwin/autoload.cc @@ -480,6 +480,8 @@ LoadDLLfuncEx (WSASendTo, 36, ws2_32, 1) LoadDLLfuncEx (WSASetEvent, 4, ws2_32, 1) LoadDLLfuncEx (WSASocketA, 24, ws2_32, 1) LoadDLLfuncEx (WSAWaitForMultipleEvents, 20, ws2_32, 1) +LoadDLLfuncEx (WSAEventSelect, 12, ws2_32, 1) +LoadDLLfuncEx (WSAEnumNetworkEvents, 12, ws2_32, 1) LoadDLLfuncEx (GetIfTable, 12, iphlpapi, 1) LoadDLLfuncEx (GetIpAddrTable, 12, iphlpapi, 1) diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index f74a97a57d9..bc3f6350351 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -57,9 +57,9 @@ init_cheap () MEMORY_BASIC_INFORMATION m; if (!VirtualQuery ((LPCVOID) &_cygheap_start, &m, sizeof m)) system_printf ("couldn't get memory info, %E"); - small_printf ("AllocationBase %p, BaseAddress %p, RegionSize %p, State %p\n", - m.AllocationBase, m.BaseAddress, m.RegionSize, m.State); - api_fatal ("Couldn't reserve space for cygwin's heap, %E"); + system_printf ("Couldn't reserve space for cygwin's heap, %E"); + api_fatal ("AllocationBase %p, BaseAddress %p, RegionSize %p, State %p\n", + m.AllocationBase, m.BaseAddress, m.RegionSize, m.State); } cygheap_max = cygheap + 1; } @@ -125,16 +125,16 @@ cygheap_fixup_in_child (bool execed) DWORD n = (DWORD) cygheap_max - (DWORD) cygheap; /* Reserve cygwin heap in same spot as parent */ if (!VirtualAlloc (cygheap, CYGHEAPSIZE, MEM_RESERVE, PAGE_NOACCESS)) - { - MEMORY_BASIC_INFORMATION m; - memset (&m, 0, sizeof m); - if (!VirtualQuery ((LPCVOID) cygheap, &m, sizeof m)) - system_printf ("couldn't get memory info, %E"); - - small_printf ("m.AllocationBase %p, m.BaseAddress %p, m.RegionSize %p, m.State %p\n", - m.AllocationBase, m.BaseAddress, m.RegionSize, m.State); - api_fatal ("Couldn't reserve space for cygwin's heap (%p <%p>) in child, %E", cygheap, newaddr); - } + { + MEMORY_BASIC_INFORMATION m; + memset (&m, 0, sizeof m); + if (!VirtualQuery ((LPCVOID) cygheap, &m, sizeof m)) + system_printf ("couldn't get memory info, %E"); + + system_printf ("Couldn't reserve space for cygwin's heap (%p <%p>) in child, %E", cygheap, newaddr); + api_fatal ("m.AllocationBase %p, m.BaseAddress %p, m.RegionSize %p, m.State %p\n", + m.AllocationBase, m.BaseAddress, m.RegionSize, m.State); + } /* Allocate same amount of memory as parent */ if (!VirtualAlloc (cygheap, n, MEM_COMMIT, PAGE_READWRITE)) diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index bc7a86ee0cd..bb9db8a4a8d 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -197,8 +197,7 @@ dtable::release (int fd) } } -extern "C" -int +extern "C" int cygwin_attach_handle_to_fd (char *name, int fd, HANDLE handle, mode_t bin, DWORD myaccess) { @@ -691,31 +690,6 @@ dtable::vfork_child_fixup () return; } -#if 0 -static char * -handle_to_fn (HANDLE h, char *posix_fn) -{ - IO_STATUS_BLOCK io; - FILE_NAME_INFORMATION ntfn; - - io.Status = 0; - io.Information = 0; - - SetLastError (0); - DWORD res = NtQueryInformationFile (h, &io, &ntfn, sizeof (ntfn), 9); - if (res || GetLastError () == ERROR_PROC_NOT_FOUND) - { - strcpy (posix_fn, "some disk file"); - return posix_fn; - } - ntfn.FileName[ntfn.FileNameLength / sizeof (WCHAR)] = 0; - - char win32_fn[MAX_PATH + 100]; - sys_wcstombs (win32_fn, ntfn.FileName, ntfn.FileNameLength); - cygwin_conv_to_full_posix_path (win32_fn, posix_fn); - return posix_fn; -} -#else #define DEVICE_PREFIX "\\device\\" #define DEVICE_PREFIX_LEN sizeof(DEVICE_PREFIX) - 1 #define REMOTE "\\Device\\LanmanRedirector\\" @@ -814,4 +788,3 @@ handle_to_fn (HANDLE h, char *posix_fn) cygwin_conv_to_full_posix_path (w32, posix_fn); return posix_fn; } -#endif diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc index f809b93cc53..fad4319004c 100644 --- a/winsup/cygwin/fhandler_dsp.cc +++ b/winsup/cygwin/fhandler_dsp.cc @@ -438,7 +438,7 @@ fhandler_dev_dsp::open (path_conv *, int flags, mode_t mode) return 0; } - set_flags (flags & ~O_TEXT, O_BINARY); + set_flags ((flags & ~O_TEXT) | O_BINARY); if (!s_audio) s_audio = new (audio_buf) Audio; diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 24e68566e8f..ffae6b1b82a 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -469,6 +469,7 @@ int fhandler_socket::accept (struct sockaddr *peer, int *len) { int res = -1; + WSAEVENT ev[2] = { WSA_INVALID_EVENT, signal_arrived }; BOOL secret_check_failed = FALSE; BOOL in_progress = FALSE; @@ -492,7 +493,58 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) if (len && ((unsigned) *len < sizeof (struct sockaddr_in))) *len = sizeof (struct sockaddr_in); - res = ::accept (get_socket (), peer, len); // can't use a blocking call inside a lock + if (!is_nonblocking()) + { + ev[0] = WSACreateEvent (); + + if (ev[0] != WSA_INVALID_EVENT && + !WSAEventSelect (get_socket (), ev[0], FD_ACCEPT)) + { + WSANETWORKEVENTS sock_event; + int wait_result; + + wait_result = WSAWaitForMultipleEvents (2, ev, FALSE, WSA_INFINITE, + FALSE); + if (wait_result == WSA_WAIT_EVENT_0) + WSAEnumNetworkEvents (get_socket (), ev[0], &sock_event); + + /* Unset events for listening socket and + switch back to blocking mode */ + WSAEventSelect (get_socket (), ev[0], 0 ); + ioctlsocket (get_socket (), FIONBIO, 0); + + switch (wait_result) + { + case WSA_WAIT_EVENT_0: + if (sock_event.lNetworkEvents & FD_ACCEPT) + { + if (sock_event.iErrorCode[FD_ACCEPT_BIT]) + { + WSASetLastError (sock_event.iErrorCode[FD_ACCEPT_BIT]); + set_winsock_errno (); + res = -1; + goto done; + } + } + /* else; : Should never happen since FD_ACCEPT is the only event + that has been selected */ + break; + case WSA_WAIT_EVENT_0 + 1: + debug_printf ("signal received during accept"); + set_errno (EINTR); + res = -1; + goto done; + case WSA_WAIT_FAILED: + default: /* Should never happen */ + WSASetLastError (WSAEFAULT); + set_winsock_errno (); + res = -1; + goto done; + } + } + } + + res = ::accept (get_socket (), peer, len); if ((SOCKET) res == (SOCKET) INVALID_SOCKET && WSAGetLastError () == WSAEWOULDBLOCK) @@ -525,24 +577,30 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) closesocket (res); set_errno (ECONNABORTED); res = -1; - return res; + goto done; } } - cygheap_fdnew res_fd; - if (res_fd < 0) - /* FIXME: what is correct errno? */; - else if ((SOCKET) res == (SOCKET) INVALID_SOCKET) - set_winsock_errno (); - else - { - fhandler_socket* res_fh = fdsock (res_fd, get_name (), res); - if (get_addr_family () == AF_LOCAL) - res_fh->set_sun_path (get_sun_path ()); - res_fh->set_addr_family (get_addr_family ()); - res_fh->set_socket_type (get_socket_type ()); - res = res_fd; - } + { + cygheap_fdnew res_fd; + if (res_fd < 0) + /* FIXME: what is correct errno? */; + else if ((SOCKET) res == (SOCKET) INVALID_SOCKET) + set_winsock_errno (); + else + { + fhandler_socket* res_fh = fdsock (res_fd, get_name (), res); + if (get_addr_family () == AF_LOCAL) + res_fh->set_sun_path (get_sun_path ()); + res_fh->set_addr_family (get_addr_family ()); + res_fh->set_socket_type (get_socket_type ()); + res = res_fd; + } + } + +done: + if (ev[0] != WSA_INVALID_EVENT) + WSACloseEvent (ev[0]); return res; } diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index c54dc7eed31..870bf7865e2 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -1131,7 +1131,7 @@ cygwin_getpeername (int fd, struct sockaddr *name, int *len) if (fh) res = fh->getpeername (name, len); - syscall_printf ("%d = getpeername %d", res, fh->get_socket ()); + syscall_printf ("%d = getpeername %d", res, (fh ? fh->get_socket () : -1)); return res; } diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc index 9313f085ccf..4b07aded510 100644 --- a/winsup/cygwin/pipe.cc +++ b/winsup/cygwin/pipe.cc @@ -8,6 +8,8 @@ This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ +/* FIXME: Should this really be fhandler_pipe.cc? */ + #include "winsup.h" #include <unistd.h> #include <errno.h> diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc index 5c7eb26d2cb..e7377b617bd 100644 --- a/winsup/cygwin/sec_helper.cc +++ b/winsup/cygwin/sec_helper.cc @@ -149,7 +149,7 @@ cygsid::get_id (BOOL search_grp, int *type) if (!IsValidSid (psid)) { __seterrno (); - small_printf ("IsValidSid failed with %E"); + system_printf ("IsValidSid failed with %E"); return -1; } diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc index 3a479978069..709da44a098 100644 --- a/winsup/cygwin/tty.cc +++ b/winsup/cygwin/tty.cc @@ -403,7 +403,7 @@ tty::common_init (fhandler_pty_master *ptym) if (cygserver_running == CYGSERVER_UNKNOWN) cygserver_init (); - if (cygserver_running == CYGSERVER_OK + if (cygserver_running != CYGSERVER_OK && !SetKernelObjectSecurity (hMainProc, DACL_SECURITY_INFORMATION, get_null_sd ())) |