mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-10 01:32:16 +00:00
server: improve error handling
We should pass up errors instead of aborting. Do that at least
for bind() failures which actually happen in real live due to the
tcp port being busy.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit aafd8eea74)
This commit is contained in:
parent
8a7e6fef27
commit
14fef1954f
@ -2975,8 +2975,8 @@ static int reds_init_socket(const char *addr, int portnr, int family)
|
||||
}
|
||||
close(slisten);
|
||||
}
|
||||
red_error("%s: binding socket to %s:%d failed\n", __FUNCTION__,
|
||||
addr, portnr);
|
||||
red_printf("%s: binding socket to %s:%d failed\n", __FUNCTION__,
|
||||
addr, portnr);
|
||||
freeaddrinfo(res);
|
||||
return -1;
|
||||
|
||||
@ -2990,10 +2990,13 @@ listen:
|
||||
return slisten;
|
||||
}
|
||||
|
||||
static void reds_init_net()
|
||||
static int reds_init_net(void)
|
||||
{
|
||||
if (spice_port != -1) {
|
||||
reds->listen_socket = reds_init_socket(spice_addr, spice_port, spice_family);
|
||||
if (-1 == reds->listen_socket) {
|
||||
return -1;
|
||||
}
|
||||
reds->listen_watch = core->watch_add(reds->listen_socket,
|
||||
SPICE_WATCH_EVENT_READ,
|
||||
reds_accept, NULL);
|
||||
@ -3005,6 +3008,9 @@ static void reds_init_net()
|
||||
if (spice_secure_port != -1) {
|
||||
reds->secure_listen_socket = reds_init_socket(spice_addr, spice_secure_port,
|
||||
spice_family);
|
||||
if (-1 == reds->secure_listen_socket) {
|
||||
return -1;
|
||||
}
|
||||
reds->secure_listen_watch = core->watch_add(reds->secure_listen_socket,
|
||||
SPICE_WATCH_EVENT_READ,
|
||||
reds_accept_ssl_connection, NULL);
|
||||
@ -3012,6 +3018,7 @@ static void reds_init_net()
|
||||
red_error("set fd handle failed");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void load_dh_params(SSL_CTX *ctx, char *file)
|
||||
@ -3709,12 +3716,13 @@ static void init_vd_agent_resources()
|
||||
|
||||
const char *version_string = VERSION;
|
||||
|
||||
static void do_spice_init(SpiceCoreInterface *core_interface)
|
||||
static int do_spice_init(SpiceCoreInterface *core_interface)
|
||||
{
|
||||
red_printf("starting %s", version_string);
|
||||
|
||||
if (core_interface->base.major_version != SPICE_INTERFACE_CORE_MAJOR) {
|
||||
red_error("bad core interface version");
|
||||
red_printf("bad core interface version");
|
||||
goto err;
|
||||
}
|
||||
core = core_interface;
|
||||
reds->listen_socket = -1;
|
||||
@ -3773,7 +3781,9 @@ static void do_spice_init(SpiceCoreInterface *core_interface)
|
||||
}
|
||||
core->timer_start(reds->mm_timer, MM_TIMER_GRANULARITY_MS);
|
||||
|
||||
reds_init_net();
|
||||
if (reds_init_net() < 0) {
|
||||
goto err;
|
||||
}
|
||||
if (reds->secure_listen_socket != -1) {
|
||||
reds_init_ssl();
|
||||
}
|
||||
@ -3785,6 +3795,10 @@ static void do_spice_init(SpiceCoreInterface *core_interface)
|
||||
|
||||
reds->mouse_mode = SPICE_MOUSE_MODE_SERVER;
|
||||
atexit(reds_exit);
|
||||
return 0;
|
||||
|
||||
err:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* new interface */
|
||||
@ -3799,12 +3813,14 @@ __visible__ SpiceServer *spice_server_new(void)
|
||||
|
||||
__visible__ int spice_server_init(SpiceServer *s, SpiceCoreInterface *core)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ASSERT(reds == s);
|
||||
do_spice_init(core);
|
||||
ret = do_spice_init(core);
|
||||
if (default_renderer) {
|
||||
red_dispatcher_add_renderer(default_renderer);
|
||||
}
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__visible__ void spice_server_destroy(SpiceServer *s)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user