server/server: Remove all exit() calls

With this patch OpenOCD shuts down properly when errors occur in the
server instead of just calling exit().

Change-Id: I2ae1a6153dafc88667951cab9152941cb487be85
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/3223
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
This commit is contained in:
Marc Schink
2016-01-24 20:58:24 +01:00
committed by Freddie Chopin
parent 99db18a995
commit b43b95e460
3 changed files with 52 additions and 23 deletions

View File

@@ -624,9 +624,8 @@ int telnet_init(char *banner)
return ERROR_OK;
}
struct telnet_service *telnet_service;
telnet_service = malloc(sizeof(struct telnet_service));
struct telnet_service *telnet_service =
malloc(sizeof(struct telnet_service));
if (!telnet_service) {
LOG_ERROR("Failed to allocate telnet service.");
@@ -635,13 +634,16 @@ int telnet_init(char *banner)
telnet_service->banner = banner;
return add_service("telnet",
telnet_port,
CONNECTION_LIMIT_UNLIMITED,
telnet_new_connection,
telnet_input,
telnet_connection_closed,
int ret = add_service("telnet", telnet_port, CONNECTION_LIMIT_UNLIMITED,
telnet_new_connection, telnet_input, telnet_connection_closed,
telnet_service);
if (ret != ERROR_OK) {
free(telnet_service);
return ret;
}
return ERROR_OK;
}
/* daemon configuration command telnet_port */