This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
2008-12-17 Thomas Schwinge <tschwinge@gnu.org>
* sysdeps/mach/hurd/socket.c (__socket): Handle SOCK_CLOEXEC
and SOCK_NONBLOCK.
* sysdeps/mach/hurd/socketpair.c (__socketpair): Likewise.
diff --git a/sysdeps/mach/hurd/socket.c b/sysdeps/mach/hurd/socket.c
index a707ed9..8b065b1 100644
--- a/sysdeps/mach/hurd/socket.c
+++ b/sysdeps/mach/hurd/socket.c
@@ -34,6 +34,11 @@ __socket (domain, type, protocol)
{
error_t err;
socket_t sock, server;
+ int flags = sock_to_o_flags (type & ~SOCK_TYPE_MASK);
+ type &= SOCK_TYPE_MASK;
+
+ if (flags & ~(O_CLOEXEC | O_NONBLOCK))
+ return __hurd_fail (EINVAL);
/* Find the socket server for DOMAIN. */
server = _hurd_socket_server (domain, 0);
@@ -59,10 +64,16 @@ __socket (domain, type, protocol)
|| err == MIG_BAD_ID || err == EOPNOTSUPP)
err = EPFNOSUPPORT;
+ if (! err)
+ {
+ if (flags & O_NONBLOCK)
+ err = __io_set_some_openmodes (sock, O_NONBLOCK);
+ }
+
if (err)
return __hurd_fail (err);
- return _hurd_intern_fd (sock, O_IGNORE_CTTY, 1);
+ return _hurd_intern_fd (sock, O_IGNORE_CTTY | flags, 1);
}
weak_alias (__socket, socket)
diff --git a/sysdeps/mach/hurd/socketpair.c b/sysdeps/mach/hurd/socketpair.c
index b124d20..54b8ff1 100644
--- a/sysdeps/mach/hurd/socketpair.c
+++ b/sysdeps/mach/hurd/socketpair.c
@@ -35,6 +35,11 @@ __socketpair (int domain, int type, int protocol, int fds[2])
error_t err;
socket_t server, sock1, sock2;
int d1, d2;
+ int flags = sock_to_o_flags (type & ~SOCK_TYPE_MASK);
+ type &= SOCK_TYPE_MASK;
+
+ if (flags & ~(O_CLOEXEC | O_NONBLOCK))
+ return __hurd_fail (EINVAL);
if (fds == NULL)
return __hurd_fail (EINVAL);
@@ -57,6 +62,11 @@ __socketpair (int domain, int type, int protocol, int fds[2])
return -1;
err = __socket_create (server, type, protocol, &sock1);
}
+ if (! err)
+ {
+ if (flags & O_NONBLOCK)
+ err = __io_set_some_openmodes (sock1, O_NONBLOCK);
+ }
if (err)
return __hurd_fail (err);
if (err = __socket_create (server, type, protocol, &sock2))
@@ -64,7 +74,11 @@ __socketpair (int domain, int type, int protocol, int fds[2])
__mach_port_deallocate (__mach_task_self (), sock1);
return __hurd_fail (err);
}
- if (err = __socket_connect2 (sock1, sock2))
+ if (flags & O_NONBLOCK)
+ err = __io_set_some_openmodes (sock2, O_NONBLOCK);
+ if (! err)
+ err = __socket_connect2 (sock1, sock2);
+ if (err)
{
__mach_port_deallocate (__mach_task_self (), sock1);
__mach_port_deallocate (__mach_task_self (), sock2);
@@ -73,13 +87,13 @@ __socketpair (int domain, int type, int protocol, int fds[2])
/* Put the sockets into file descriptors. */
- d1 = _hurd_intern_fd (sock1, O_IGNORE_CTTY, 1);
+ d1 = _hurd_intern_fd (sock1, O_IGNORE_CTTY | flags, 1);
if (d1 < 0)
{
__mach_port_deallocate (__mach_task_self (), sock2);
return -1;
}
- d2 = _hurd_intern_fd (sock2, O_IGNORE_CTTY, 1);
+ d2 = _hurd_intern_fd (sock2, O_IGNORE_CTTY | flags, 1);
if (d2 < 0)
{
err = errno;
To discuss:
In __socket, do we need special err massaging after the
__io_set_some_openmodes call?
In __socketcall, should we do err massaging after the second
__socket_create calls, like it is done in __socket?
Again in __socketcall, analogous to the __socket question, do we need
special err massaging after the two __io_set_some_openmodes calls?
Attachment:
signature.asc
Description: Digital signature
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |