From c78254fcd1c8d88fbc258d2a50ee925c282c5c64 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 22 Feb 2023 18:41:22 +0100 Subject: [PATCH] Split server stop() and join() For consistency with the other components, call stop() and join() separately. This allows to stop all components, then join them all. --- app/src/scrcpy.c | 4 ++++ app/src/server.c | 3 +++ app/src/server.h | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index afd04d6d..e96fa187 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -698,6 +698,10 @@ end: sc_file_pusher_destroy(&s->file_pusher); } + if (server_started) { + sc_server_join(&s->server); + } + sc_server_destroy(&s->server); return ret; diff --git a/app/src/server.c b/app/src/server.c index c9164972..413f02ee 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -909,7 +909,10 @@ sc_server_stop(struct sc_server *server) { sc_cond_signal(&server->cond_stopped); sc_intr_interrupt(&server->intr); sc_mutex_unlock(&server->mutex); +} +void +sc_server_join(struct sc_server *server) { sc_thread_join(&server->thread, NULL); } diff --git a/app/src/server.h b/app/src/server.h index d6b1401e..c05b1e5b 100644 --- a/app/src/server.h +++ b/app/src/server.h @@ -108,6 +108,10 @@ sc_server_start(struct sc_server *server); void sc_server_stop(struct sc_server *server); +// join the server thread +void +sc_server_join(struct sc_server *server); + // close and release sockets void sc_server_destroy(struct sc_server *server);