summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-12-31 17:40:23 +0100
committerFelix Fietkau <nbd@openwrt.org>2012-12-31 17:40:23 +0100
commitb6d9114baa1f8323084001fd4bc44fb08f7f1b35 (patch)
treea1da9ac31d61dac1c337bedcff29805061c9ff54 /main.c
parent57fc4cd7ff5918af11eb4b5f6ad765c89432b210 (diff)
exit if no sockets could be bound
Diffstat (limited to 'main.c')
-rw-r--r--main.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/main.c b/main.c
index 1172640..09c66c4 100644
--- a/main.c
+++ b/main.c
@@ -98,7 +98,7 @@ static void uh_config_parse(void)
fclose(c);
}
-static void add_listener_arg(char *arg, bool tls)
+static int add_listener_arg(char *arg, bool tls)
{
char *host = NULL;
char *port = arg;
@@ -110,7 +110,8 @@ static void add_listener_arg(char *arg, bool tls)
port = s + 1;
*s = 0;
}
- uh_socket_bind(host, port, tls);
+
+ return uh_socket_bind(host, port, tls);
}
static int usage(const char *name)
@@ -174,6 +175,7 @@ int main(int argc, char **argv)
char *port;
int opt, ch;
int cur_fd;
+ int bound = 0;
init_defaults();
signal(SIGPIPE, SIG_IGN);
@@ -186,7 +188,7 @@ int main(int argc, char **argv)
tls = true;
/* fall through */
case 'p':
- add_listener_arg(optarg, tls);
+ bound += add_listener_arg(optarg, tls);
break;
case 'h':
@@ -289,6 +291,11 @@ int main(int argc, char **argv)
uh_config_parse();
+ if (!bound) {
+ fprintf(stderr, "Error: No sockets bound, unable to continue\n");
+ return 1;
+ }
+
/* fork (if not disabled) */
if (!nofork) {
switch (fork()) {