]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: AF_LOCAL: fix fcntl and dup if O_PATH is set
authorKen Brown <kbrown@cornell.edu>
Sat, 25 Jan 2020 18:08:00 +0000 (13:08 -0500)
committerKen Brown <kbrown@cornell.edu>
Thu, 30 Jan 2020 14:43:19 +0000 (09:43 -0500)
Make fhandler_socket_local::dup and fhandler_socket_local::fcntl (a
new method) call fhandler_base::dup and fhandler_base::fcntl if O_PATH
is set.

We're viewing the socket as a disk file here, but there's no need to
implement the actions of fhandler_disk_file::dup and
fhandler_disk_file::fcntl, which do nothing useful in this case beyond
what the fhandler_base methods do.  (The extra actions are only useful
when I/O is going to be done on the file.)

winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_socket_local.cc

index c54780ef6c9bdb2758c25c25a7a3997f5ea0a8e2..1b477f633f7a672dd22a2581bcbeda28377c5a34 100644 (file)
@@ -836,6 +836,7 @@ class fhandler_socket_local: public fhandler_socket_wsock
 
   int open (int flags, mode_t mode = 0);
   int close ();
+  int fcntl (int cmd, intptr_t);
   int __reg2 fstat (struct stat *buf);
   int __reg2 fstatvfs (struct statvfs *buf);
   int __reg1 fchmod (mode_t newmode);
index 76815a6118bb08ae963c41e50e084985e7a5c0a2..8bfba225a31f3a4647fbd400c5999741c0ee14f8 100644 (file)
@@ -628,6 +628,11 @@ fhandler_socket_local::af_local_set_secret (char *buf)
 int
 fhandler_socket_local::dup (fhandler_base *child, int flags)
 {
+  if (get_flags () & O_PATH)
+    /* We're viewing the socket as a disk file, but fhandler_base::dup
+       suffices here. */
+    return fhandler_base::dup (child, flags);
+
   fhandler_socket_local *fhs = (fhandler_socket_local *) child;
   fhs->set_sun_path (get_sun_path ());
   fhs->set_peer_sun_path (get_peer_sun_path ());
@@ -654,6 +659,17 @@ fhandler_socket_local::close ()
     return fhandler_socket_wsock::close ();
 }
 
+int
+fhandler_socket_local::fcntl (int cmd, intptr_t arg)
+{
+  if (get_flags () & O_PATH)
+    /* We're viewing the socket as a disk file, but
+       fhandler_base::fcntl suffices here. */
+    return fhandler_base::fcntl (cmd, arg);
+  else
+    return fhandler_socket_wsock::fcntl (cmd, arg);
+}
+
 int __reg2
 fhandler_socket_local::fstat (struct stat *buf)
 {
This page took 0.03714 seconds and 5 git commands to generate.