aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/server.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/server/server.c b/src/server/server.c
index 1e52e97..46c860f 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -300,10 +300,11 @@ int add_service(char *name,
}
struct sockaddr_in addr_in;
+ addr_in.sin_port = 0;
socklen_t addr_in_size = sizeof(addr_in);
- getsockname(c->fd, (struct sockaddr *)&addr_in, &addr_in_size);
- LOG_INFO("Listening on port %hu for %s connections",
- ntohs(addr_in.sin_port), name);
+ if (getsockname(c->fd, (struct sockaddr *)&addr_in, &addr_in_size) == 0)
+ LOG_INFO("Listening on port %hu for %s connections",
+ ntohs(addr_in.sin_port), name);
} else if (c->type == CONNECTION_STDINOUT) {
c->fd = fileno(stdin);