From: c vw Date: Wed, 26 Feb 2020 11:17:31 +0000 (+0100) Subject: Terminate new protocol receiving thread gracefully if X-Git-Url: https://git.rkrishnan.org/Site/listings/$rel_link?a=commitdiff_plain;h=a2c8f2e71da2395b7e90b0db2c1a1b39a19c64f0;p=pihpsdr.git Terminate new protocol receiving thread gracefully if exiting piHPSDR. --- diff --git a/new_protocol.c b/new_protocol.c index c679567..a851f61 100644 --- a/new_protocol.c +++ b/new_protocol.c @@ -1377,6 +1377,17 @@ g_print("new_protocol_thread\n"); buffer=malloc(NET_BUFFER_SIZE); bytesread=recvfrom(data_socket,buffer,NET_BUFFER_SIZE,0,(struct sockaddr*)&addr,&length); + + if (!running) { + // + // When leaving piHPSDR, it may happen that the protocol has been stopped while + // we were doing "rcvfrom". In this case, we do not want to "exit" but let the main + // thread exit gracefully, including writing the props files. + // + free(buffer); + break; + } + if(bytesread<0) { g_print("recvfrom socket failed for new_protocol_thread"); exit(-1);