server: Fix various error paths if startup fails
Don't segfault or use heap after free if osmo-remsim-server cannot fully initialize, e.g. due to ports already in use. Change-Id: I558e6a0ea089a779f916aa5576341d1c55da1271
This commit is contained in:
parent
a9bb9a9348
commit
a04ff860c1
|
@ -139,7 +139,6 @@ out_eventfd:
|
|||
close(g_event_ofd.fd);
|
||||
out_rps:
|
||||
talloc_free(g_rps->slotmaps);
|
||||
talloc_free(g_rps);
|
||||
out_rspro:
|
||||
rspro_server_destroy(g_rps);
|
||||
|
||||
|
|
|
@ -512,6 +512,7 @@ int rest_api_init(void *ctx, uint16_t port)
|
|||
|
||||
if (ulfius_start_framework(&g_instance) != U_OK) {
|
||||
LOGP(DREST, LOGL_FATAL, "Cannot start REST API on port %u\n", port);
|
||||
ulfius_clean_instance(&g_instance);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -854,6 +854,11 @@ struct rspro_server *rspro_server_create(void *ctx, const char *host, uint16_t p
|
|||
pthread_rwlock_unlock(&srv->rwlock);
|
||||
|
||||
srv->link = ipa_server_link_create(ctx, NULL, host, port, accept_cb, srv);
|
||||
if (!srv->link) {
|
||||
talloc_free(srv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ipa_server_link_open(srv->link);
|
||||
|
||||
return srv;
|
||||
|
@ -865,5 +870,6 @@ void rspro_server_destroy(struct rspro_server *srv)
|
|||
|
||||
ipa_server_link_destroy(srv->link);
|
||||
srv->link = NULL;
|
||||
pthread_rwlock_destroy(&srv->rwlock);
|
||||
talloc_free(srv);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue