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:
authorCorinna Vinschen <corinna@vinschen.de>2002-06-04 20:38:13 +0400
committerCorinna Vinschen <corinna@vinschen.de>2002-06-04 20:38:13 +0400
commit4e1388472d90347bc80dc30a94312d74c2f1c8e1 (patch)
tree970b2d494a8daefbd32a16e4aa46be10fb5dd316
parent6bfca3cca518b043bf35ac90ad6dbc91da872de5 (diff)
* fhandler.h (class fhandler_socket): Add private method
fixup_after_fork (bool, HANDLE). * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Move functionality to new private method. Add closing parent socket if not called from dup(). Create method new calling private method with appropriate parameter. (fhandler_socket::fixup_after_exec): Call private method fixup_after_fork with appropriate parameter. (fhandler_socket::dup): Ditto.
-rw-r--r--winsup/cygwin/ChangeLog14
-rw-r--r--winsup/cygwin/fhandler.h2
-rw-r--r--winsup/cygwin/fhandler_socket.cc16
3 files changed, 28 insertions, 4 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 1285b795a..1836ff8e6 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,4 +1,16 @@
-2002-06-03 Corinna Vinschen <corinna@vinschen.de>
+2002-06-04 Corinna Vinschen <corinna@vinschen.de>
+
+ * fhandler.h (class fhandler_socket): Add private method
+ fixup_after_fork (bool, HANDLE).
+ * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Move
+ functionality to new private method. Add closing parent socket
+ if not called from dup(). Create method new calling private method
+ with appropriate parameter.
+ (fhandler_socket::fixup_after_exec): Call private method
+ fixup_after_fork with appropriate parameter.
+ (fhandler_socket::dup): Ditto.
+
+2002-06-04 Corinna Vinschen <corinna@vinschen.de>
* fhandler_dsp.cc (fhandler_dev_dsp::open): Set errno to EACCES if
requested mode isn't supported.
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index c5e17b101..3d8d7ef37 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -367,6 +367,8 @@ class fhandler_socket: public fhandler_base
struct _WSAPROTOCOL_INFOA *prot_info_ptr;
char *sun_path;
+ void fixup_after_fork (bool, HANDLE);
+
public:
fhandler_socket ();
~fhandler_socket ();
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index e0e5c6363..0f1f90bb7 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -184,7 +184,7 @@ fhandler_socket::fixup_before_fork_exec (DWORD win_proc_id)
extern "C" void __stdcall load_wsock32 ();
void
-fhandler_socket::fixup_after_fork (HANDLE parent)
+fhandler_socket::fixup_after_fork (bool dup, HANDLE parent)
{
SOCKET new_sock;
@@ -208,6 +208,10 @@ fhandler_socket::fixup_after_fork (HANDLE parent)
else
{
debug_printf ("WSASocket went fine new_sock %p, old_sock %p", new_sock, get_io_handle ());
+#if 1
+ if (!dup && new_sock != (SOCKET) get_socket ())
+ closesocket (get_socket ());
+#endif
set_io_handle ((HANDLE) new_sock);
}
@@ -216,11 +220,17 @@ fhandler_socket::fixup_after_fork (HANDLE parent)
}
void
+fhandler_socket::fixup_after_fork (HANDLE parent)
+{
+ fixup_after_fork (false, parent);
+}
+
+void
fhandler_socket::fixup_after_exec (HANDLE parent)
{
debug_printf ("here");
if (!get_close_on_exec ())
- fixup_after_fork (parent);
+ fixup_after_fork (false, parent);
#if 0
else if (!winsock2_active)
closesocket (get_socket ());
@@ -238,7 +248,7 @@ fhandler_socket::dup (fhandler_base *child)
fhs->fixup_before_fork_exec (GetCurrentProcessId ());
if (winsock2_active)
{
- fhs->fixup_after_fork (hMainProc);
+ fhs->fixup_after_fork (true, hMainProc);
return 0;
}
return fhandler_base::dup (child);