Better error handling on CLI initialization.
Signed-off-by: Benjamin Cama <benoar@dolka.fr>
This commit is contained in:
parent
0f85bdecab
commit
5382473b0e
1 changed files with 10 additions and 2 deletions
12
cli.c
12
cli.c
|
|
@ -287,10 +287,18 @@ void init_cli(char *hostname)
|
||||||
addr.sin_port = htons(23);
|
addr.sin_port = htons(23);
|
||||||
if (bind(clifd, (void *) &addr, sizeof(addr)) < 0)
|
if (bind(clifd, (void *) &addr, sizeof(addr)) < 0)
|
||||||
{
|
{
|
||||||
LOG(0, 0, 0, "Error listening on cli port 23: %s\n", strerror(errno));
|
LOG(0, 0, 0, "Error binding cli on port 23: %s\n", strerror(errno));
|
||||||
|
close(clifd);
|
||||||
|
clifd = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (listen(clifd, 10) < 0)
|
||||||
|
{
|
||||||
|
LOG(0, 0, 0, "Error listening on cli port 23: %s\n", strerror(errno));
|
||||||
|
close(clifd);
|
||||||
|
clifd = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
listen(clifd, 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cli_do(int sockfd)
|
void cli_do(int sockfd)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue