mirror of
https://github.com/samba-team/samba.git
synced 2025-01-27 14:04:05 +03:00
unix_msg: add flag to prepare_socket_nonblock()
This allows prepare_socket_nonblock() to be called to set a socket to non-blocking (as before) as well as blocking. This will be used in a subsequent commit. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
d2b0694666
commit
bb526a61d1
@ -80,7 +80,7 @@ static void unix_dgram_recv_handler(struct poll_watch *w, int fd, short events,
|
||||
void *private_data);
|
||||
|
||||
/* Set socket non blocking. */
|
||||
static int prepare_socket_nonblock(int sock)
|
||||
static int prepare_socket_nonblock(int sock, bool nonblock)
|
||||
{
|
||||
int flags;
|
||||
#ifdef O_NONBLOCK
|
||||
@ -97,7 +97,11 @@ static int prepare_socket_nonblock(int sock)
|
||||
if (flags == -1) {
|
||||
return errno;
|
||||
}
|
||||
flags |= FLAG_TO_SET;
|
||||
if (nonblock) {
|
||||
flags |= FLAG_TO_SET;
|
||||
} else {
|
||||
flags &= ~FLAG_TO_SET;
|
||||
}
|
||||
if (fcntl(sock, F_SETFL, flags) == -1) {
|
||||
return errno;
|
||||
}
|
||||
@ -127,7 +131,7 @@ static int prepare_socket_cloexec(int sock)
|
||||
/* Set socket non blocking and close on exec. */
|
||||
static int prepare_socket(int sock)
|
||||
{
|
||||
int ret = prepare_socket_nonblock(sock);
|
||||
int ret = prepare_socket_nonblock(sock, true);
|
||||
|
||||
if (ret) {
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user