summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-28 07:34:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:04:53 -0500
commit34cd0662f0340720fa45dd16c82496cd76e92268 (patch)
treea26d18bed0118acdc2ae3f3bd3a64fb2af5abb98 /source4
parentc8c3a56b8bf0db89fdb8f548fe6016cb87d115ad (diff)
downloadsamba-34cd0662f0340720fa45dd16c82496cd76e92268.tar.gz
samba-34cd0662f0340720fa45dd16c82496cd76e92268.tar.bz2
samba-34cd0662f0340720fa45dd16c82496cd76e92268.zip
r3313: in socket_accept() make the new socket non-blocking unless SOCKET_FLAG_BLOCK is set.
(This used to be commit a2d92aa431e0e9752387eebe741d9e6f376f74d7)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/socket/socket_ipv4.c8
-rw-r--r--source4/lib/socket/socket_unix.c8
2 files changed, 16 insertions, 0 deletions
diff --git a/source4/lib/socket/socket_ipv4.c b/source4/lib/socket/socket_ipv4.c
index 4de0d8cebe..71e1c62235 100644
--- a/source4/lib/socket/socket_ipv4.c
+++ b/source4/lib/socket/socket_ipv4.c
@@ -141,6 +141,14 @@ static NTSTATUS ipv4_tcp_accept(struct socket_context *sock, struct socket_conte
return map_nt_error_from_unix(errno);
}
+ if (!(flags & SOCKET_FLAG_BLOCK)) {
+ int ret = set_blocking(new_fd, False);
+ if (ret == -1) {
+ close(new_fd);
+ return map_nt_error_from_unix(errno);
+ }
+ }
+
/* TODO: we could add a 'accept_check' hook here
* which get the black/white lists via socket_set_accept_filter()
* or something like that
diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c
index 3a3ce5fe8a..239e4eb069 100644
--- a/source4/lib/socket/socket_unix.c
+++ b/source4/lib/socket/socket_unix.c
@@ -136,6 +136,14 @@ static NTSTATUS unixdom_accept(struct socket_context *sock,
return unixdom_error(errno);
}
+ if (!(flags & SOCKET_FLAG_BLOCK)) {
+ int ret = set_blocking(new_fd, False);
+ if (ret == -1) {
+ close(new_fd);
+ return map_nt_error_from_unix(errno);
+ }
+ }
+
(*new_sock) = talloc_p(NULL, struct socket_context);
if (!(*new_sock)) {
close(new_fd);