You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
1.3 KiB

From fedfd6685e5f81f0460beb4c448a30e7a6cfbd31 Mon Sep 17 00:00:00 2001
From: Yousong Zhou <yszhou4tech@gmail.com>
Date: Wed, 29 Apr 2015 14:21:12 +0800
Subject: [PATCH 202/210] xl2tpd-control: open control file with O_NONBLOCK.
Otherwise xl2tpd-control would block indefinitely in case xl2tpd is
not running.
---
xl2tpd-control.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/xl2tpd-control.c b/xl2tpd-control.c
index 9b6235d..973ee87 100644
--- a/xl2tpd-control.c
+++ b/xl2tpd-control.c
@@ -246,7 +246,7 @@ int main (int argc, char *argv[])
print_error (DEBUG_LEVEL, "command to be passed:\n%s\n", buf);
/* try to open control file for writing */
- int control_fd = open (control_filename, O_WRONLY, 0600);
+ int control_fd = open (control_filename, O_WRONLY | O_NONBLOCK, 0600);
if (control_fd < 0)
{
int errorno = errno;
@@ -265,6 +265,14 @@ int main (int argc, char *argv[])
}
return -1;
}
+
+ /* turn off O_NONBLOCK */
+ if (fcntl (control_fd, F_SETFL, O_WRONLY) == -1) {
+ print_error (ERROR_LEVEL,
+ "Can not turn off nonblocking mode for control_fd: %s\n",
+ strerror(errno));
+ return -2;
+ }
/* pass command to control pipe */
if (write (control_fd, buf, ftell (mesf)) < 0)
--
1.7.10.4