Cygwin: fhandler_socket: Add derived fcntl methods

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2018-02-22 16:37:12 +01:00
parent 79598f94f7
commit 9c593d9b39
4 changed files with 57 additions and 14 deletions

View File

@ -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);

View File

@ -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.

View File

@ -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;
}

View File

@ -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;
}