From: Volker Lendecke Date: Fri, 20 Mar 2020 10:31:15 +0000 (+0100) Subject: lib: Remove unused SOCKET_FLAG_BLOCK X-Git-Tag: ldb-2.2.0~1225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f52f531771d6a25b2e363384bf94a9fa14334e1b;p=thirdparty%2Fsamba.git lib: Remove unused SOCKET_FLAG_BLOCK Nobody in the code set this flag, so remove it Signed-off-by: Volker Lendecke Reviewed-by: Stefan Metzmacher --- diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c index d7535bf357a..26f23f56653 100644 --- a/source4/lib/socket/socket.c +++ b/source4/lib/socket/socket.c @@ -79,15 +79,14 @@ _PUBLIC_ NTSTATUS socket_create_with_ops(TALLOC_CTX *mem_ctx, const struct socke send calls on non-blocking sockets will randomly recv/send less data than requested */ - if (!(flags & SOCKET_FLAG_BLOCK) && - type == SOCKET_TYPE_STREAM && + if (type == SOCKET_TYPE_STREAM && getenv("SOCKET_TESTNONBLOCK") != NULL) { (*new_sock)->flags |= SOCKET_FLAG_TESTNONBLOCK; } /* we don't do a connect() on dgram sockets, so need to set non-blocking at socket create time */ - if (!(flags & SOCKET_FLAG_BLOCK) && type == SOCKET_TYPE_DGRAM) { + if (type == SOCKET_TYPE_DGRAM) { set_blocking(socket_get_fd(*new_sock), false); } diff --git a/source4/lib/socket/socket.h b/source4/lib/socket/socket.h index a492bc10367..d0fb5e0bfca 100644 --- a/source4/lib/socket/socket.h +++ b/source4/lib/socket/socket.h @@ -98,7 +98,6 @@ enum socket_state { SOCKET_STATE_SERVER_ERROR }; -#define SOCKET_FLAG_BLOCK 0x00000001 #define SOCKET_FLAG_PEEK 0x00000002 #define SOCKET_FLAG_TESTNONBLOCK 0x00000004 #define SOCKET_FLAG_ENCRYPT 0x00000008 /* This socket diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c index 2aba491e06c..762ec3d48c4 100644 --- a/source4/lib/socket/socket_ip.c +++ b/source4/lib/socket/socket_ip.c @@ -81,11 +81,9 @@ static NTSTATUS ip_connect_complete(struct socket_context *sock, uint32_t flags) return map_nt_error_from_unix_common(error); } - if (!(flags & SOCKET_FLAG_BLOCK)) { - ret = set_blocking(sock->fd, false); - if (ret == -1) { - return map_nt_error_from_unix_common(errno); - } + ret = set_blocking(sock->fd, false); + if (ret == -1) { + return map_nt_error_from_unix_common(errno); } sock->state = SOCKET_STATE_CLIENT_CONNECTED; @@ -201,11 +199,9 @@ static NTSTATUS ipv4_listen(struct socket_context *sock, } } - if (!(flags & SOCKET_FLAG_BLOCK)) { - ret = set_blocking(sock->fd, false); - if (ret == -1) { - return map_nt_error_from_unix_common(errno); - } + ret = set_blocking(sock->fd, false); + if (ret == -1) { + return map_nt_error_from_unix_common(errno); } sock->state= SOCKET_STATE_SERVER_LISTEN; @@ -217,7 +213,7 @@ static NTSTATUS ipv4_accept(struct socket_context *sock, struct socket_context * { struct sockaddr_in cli_addr; socklen_t cli_addr_len = sizeof(cli_addr); - int new_fd; + int new_fd, ret; if (sock->type != SOCKET_TYPE_STREAM) { return NT_STATUS_INVALID_PARAMETER; @@ -228,13 +224,12 @@ static NTSTATUS ipv4_accept(struct socket_context *sock, struct socket_context * return map_nt_error_from_unix_common(errno); } - if (!(sock->flags & SOCKET_FLAG_BLOCK)) { - int ret = set_blocking(new_fd, false); - if (ret == -1) { - close(new_fd); - return map_nt_error_from_unix_common(errno); - } + ret = set_blocking(new_fd, false); + if (ret == -1) { + close(new_fd); + return map_nt_error_from_unix_common(errno); } + smb_set_close_on_exec(new_fd); @@ -731,11 +726,9 @@ static NTSTATUS ipv6_listen(struct socket_context *sock, } } - if (!(flags & SOCKET_FLAG_BLOCK)) { - ret = set_blocking(sock->fd, false); - if (ret == -1) { - return map_nt_error_from_unix_common(errno); - } + ret = set_blocking(sock->fd, false); + if (ret == -1) { + return map_nt_error_from_unix_common(errno); } sock->state= SOCKET_STATE_SERVER_LISTEN; @@ -747,7 +740,7 @@ static NTSTATUS ipv6_tcp_accept(struct socket_context *sock, struct socket_conte { struct sockaddr_in6 cli_addr; socklen_t cli_addr_len = sizeof(cli_addr); - int new_fd; + int new_fd, ret; if (sock->type != SOCKET_TYPE_STREAM) { return NT_STATUS_INVALID_PARAMETER; @@ -758,12 +751,10 @@ static NTSTATUS ipv6_tcp_accept(struct socket_context *sock, struct socket_conte return map_nt_error_from_unix_common(errno); } - if (!(sock->flags & SOCKET_FLAG_BLOCK)) { - int ret = set_blocking(new_fd, false); - if (ret == -1) { - close(new_fd); - return map_nt_error_from_unix_common(errno); - } + ret = set_blocking(new_fd, false); + if (ret == -1) { + close(new_fd); + return map_nt_error_from_unix_common(errno); } smb_set_close_on_exec(new_fd); diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 6876e395ed6..d4946d88eeb 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -84,11 +84,9 @@ static NTSTATUS unixdom_connect_complete(struct socket_context *sock, uint32_t f return map_nt_error_from_unix_common(error); } - if (!(flags & SOCKET_FLAG_BLOCK)) { - ret = set_blocking(sock->fd, false); - if (ret == -1) { - return map_nt_error_from_unix_common(errno); - } + ret = set_blocking(sock->fd, false); + if (ret == -1) { + return map_nt_error_from_unix_common(errno); } sock->state = SOCKET_STATE_CLIENT_CONNECTED; @@ -163,11 +161,9 @@ static NTSTATUS unixdom_listen(struct socket_context *sock, } } - if (!(flags & SOCKET_FLAG_BLOCK)) { - ret = set_blocking(sock->fd, false); - if (ret == -1) { - return unixdom_error(errno); - } + ret = set_blocking(sock->fd, false); + if (ret == -1) { + return unixdom_error(errno); } sock->state = SOCKET_STATE_SERVER_LISTEN; @@ -181,7 +177,7 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, { struct sockaddr_un cli_addr; socklen_t cli_addr_len = sizeof(cli_addr); - int new_fd; + int new_fd, ret; if (sock->type != SOCKET_TYPE_STREAM) { return NT_STATUS_INVALID_PARAMETER; @@ -192,12 +188,10 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, return unixdom_error(errno); } - if (!(sock->flags & SOCKET_FLAG_BLOCK)) { - int ret = set_blocking(new_fd, false); - if (ret == -1) { - close(new_fd); - return map_nt_error_from_unix_common(errno); - } + ret = set_blocking(new_fd, false); + if (ret == -1) { + close(new_fd); + return map_nt_error_from_unix_common(errno); } smb_set_close_on_exec(new_fd);