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>
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
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;
}
/* 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;