Skip to content

Commit c78ad63

Browse files
committed
Terminate the server on stop
On user request to quit, two kinds of blocking calls must be interrupted on the server: 1. the reads from and writes to the socket; 2. the call to MediaCodec.dequeueOutputBuffer(). The former case was handled by calling shutdown() on the socket from the client, but the latter was not managed. There is no easy way to wake this call properly, so just terminate the process from the client (i.e. send SIGTERM on Linux) instead.
1 parent b61310a commit c78ad63

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

app/src/server.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,10 @@ socket_t server_connect_to(struct server *server, const char *serial, Uint32 tim
143143
void server_stop(struct server *server, const char *serial) {
144144
SDL_assert(server->process != PROCESS_NONE);
145145

146-
if (server->device_socket != INVALID_SOCKET) {
147-
// shutdown the socket to finish the device process gracefully
148-
if (!net_shutdown(server->device_socket, SHUT_RDWR)) {
149-
LOGW("Cannot shutdown socket");
150-
}
146+
if (!cmd_terminate(server->process)) {
147+
LOGW("Cannot terminate server");
151148
}
152149

153-
LOGD("Waiting the server to complete execution on the device...");
154150
cmd_simple_wait(server->process, NULL); // ignore exit code
155151
LOGD("Server terminated");
156152

0 commit comments

Comments
 (0)