[newlib-cygwin] Cygwin: fhandler_socket: Add derived fcntl methods

Corinna Vinschen corinna@sourceware.org
Thu Feb 22 16:01:00 GMT 2018


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9c593d9b39e9ad5bb02a02ace5418c3ef98aa59f

commit 9c593d9b39e9ad5bb02a02ace5418c3ef98aa59f
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Thu Feb 22 16:37:12 2018 +0100

    Cygwin: fhandler_socket: Add derived fcntl methods
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler.h               |  7 +++++--
 winsup/cygwin/fhandler_socket.cc       | 12 ------------
 winsup/cygwin/fhandler_socket_inet.cc  | 26 ++++++++++++++++++++++++++
 winsup/cygwin/fhandler_socket_local.cc | 26 ++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 14 deletions(-)

diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 18de57c..bf06668 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -602,8 +602,9 @@ class fhandler_socket: public fhandler_base
   virtual ssize_t __stdcall write (const void *ptr, size_t len) = 0;
   virtual ssize_t __stdcall writev (const struct iovec *, int iovcnt, ssize_t tot = -1) = 0;
 
-  int ioctl (unsigned int cmd, void *);
-  int fcntl (int cmd, intptr_t);
+  virtual int ioctl (unsigned int cmd, void *);
+  virtual int fcntl (int cmd, intptr_t);
+
   off_t lseek (off_t, int)
   { 
     set_errno (ESPIPE);
@@ -671,6 +672,7 @@ class fhandler_socket_inet: public fhandler_socket
   ssize_t __stdcall write (const void *ptr, size_t len);
   ssize_t __stdcall writev (const struct iovec *, int iovcnt, ssize_t tot = -1);
   int ioctl (unsigned int cmd, void *);
+  int fcntl (int cmd, intptr_t);
 
   /* from here on: CLONING */
   fhandler_socket_inet (void *) {}
@@ -760,6 +762,7 @@ class fhandler_socket_local: public fhandler_socket
   ssize_t __stdcall write (const void *ptr, size_t len);
   ssize_t __stdcall writev (const struct iovec *, int iovcnt, ssize_t tot = -1);
   int ioctl (unsigned int cmd, void *);
+  int fcntl (int cmd, intptr_t);
 
   int __reg2 fstat (struct stat *buf);
   int __reg2 fstatvfs (struct statvfs *buf);
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index dfcb8d4..b1a5136 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -911,18 +911,6 @@ fhandler_socket::fcntl (int cmd, intptr_t arg)
 
   switch (cmd)
     {
-    case F_SETOWN:
-      {
-	pid_t pid = (pid_t) arg;
-	LOCK_EVENTS;
-	wsock_events->owner = pid;
-	UNLOCK_EVENTS;
-	debug_printf ("owner set to %d", pid);
-      }
-      break;
-    case F_GETOWN:
-      res = wsock_events->owner;
-      break;
     case F_SETFL:
       {
 	/* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
diff --git a/winsup/cygwin/fhandler_socket_inet.cc b/winsup/cygwin/fhandler_socket_inet.cc
index d5fe393..b2bc193 100644
--- a/winsup/cygwin/fhandler_socket_inet.cc
+++ b/winsup/cygwin/fhandler_socket_inet.cc
@@ -1285,3 +1285,29 @@ fhandler_socket_inet::ioctl (unsigned int cmd, void *p)
   syscall_printf ("%d = ioctl_socket(%x, %p)", res, cmd, p);
   return res;
 }
+
+int
+fhandler_socket_inet::fcntl (int cmd, intptr_t arg)
+{
+  int res = 0;
+
+  switch (cmd)
+    {
+    case F_SETOWN:
+      {
+	pid_t pid = (pid_t) arg;
+	LOCK_EVENTS;
+	wsock_events->owner = pid;
+	UNLOCK_EVENTS;
+	debug_printf ("owner set to %d", pid);
+      }
+      break;
+    case F_GETOWN:
+      res = wsock_events->owner;
+      break;
+    default:
+      res = fhandler_socket::fcntl (cmd, arg);
+      break;
+    }
+  return res;
+}
diff --git a/winsup/cygwin/fhandler_socket_local.cc b/winsup/cygwin/fhandler_socket_local.cc
index bf34377..0649fa0 100644
--- a/winsup/cygwin/fhandler_socket_local.cc
+++ b/winsup/cygwin/fhandler_socket_local.cc
@@ -1964,3 +1964,29 @@ fhandler_socket_local::ioctl (unsigned int cmd, void *p)
   syscall_printf ("%d = ioctl_socket(%x, %p)", res, cmd, p);
   return res;
 }
+
+int
+fhandler_socket_local::fcntl (int cmd, intptr_t arg)
+{
+  int res = 0;
+
+  switch (cmd)
+    {
+    case F_SETOWN:
+      {
+	pid_t pid = (pid_t) arg;
+	LOCK_EVENTS;
+	wsock_events->owner = pid;
+	UNLOCK_EVENTS;
+	debug_printf ("owner set to %d", pid);
+      }
+      break;
+    case F_GETOWN:
+      res = wsock_events->owner;
+      break;
+    default:
+      res = fhandler_socket::fcntl (cmd, arg);
+      break;
+    }
+  return res;
+}



More information about the Cygwin-cvs mailing list