From 7c995f4eb779dce19c1773454b576a690fd63dbb Mon Sep 17 00:00:00 2001 From: hbeni Date: Tue, 16 Feb 2021 00:20:01 +0100 Subject: [PATCH 1/2] Fix #78: deadlock on udp-server shutdown - Commented mumAPI.log references in UDP shutdown - ignore "first contact" gui msg in case the first packet is a SHUTDOWN one --- client/mumble-plugin/lib/io_UDPServer.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/client/mumble-plugin/lib/io_UDPServer.cpp b/client/mumble-plugin/lib/io_UDPServer.cpp index 831c9413..31dd4ed7 100644 --- a/client/mumble-plugin/lib/io_UDPServer.cpp +++ b/client/mumble-plugin/lib/io_UDPServer.cpp @@ -516,8 +516,8 @@ bool fgcom_udp_shutdowncmd = false; bool udpServerRunning = false; void fgcom_spawnUDPServer() { pluginLog("[UDP-server] server starting"); - int fgcom_UDPServer_sockfd; - char buffer[MAXLINE]; + int fgcom_UDPServer_sockfd; + char buffer[MAXLINE]; struct sockaddr_in servaddr, cliaddr; #ifdef MINGW_WIN64 @@ -616,23 +616,25 @@ void fgcom_spawnUDPServer() { clientHost = inet_ntoa(cliaddr.sin_addr); std::string clientHost_str = std::string(clientHost); - // Print info to client, so we know what ports are in use - if (firstdata.count(clientPort) == 0 && sizeof(buffer) > 4) { - firstdata[clientPort] = true; - mumAPI.log(ownPluginID, std::string("UDP server connection established from "+clientHost_str+":"+std::to_string(clientPort)).c_str()); - } - // Allow the udp server to be shut down when receiving SHUTDOWN command if (strstr(buffer, "SHUTDOWN") && fgcom_udp_shutdowncmd) { pluginLog("[UDP-server] shutdown command recieved, server stopping now"); fgcom_udp_shutdowncmd = false; close(fgcom_UDPServer_sockfd); - mumAPI.log(ownPluginID, std::string("UDP server at port "+std::to_string(fgcom_udp_port_used)+" stopped").c_str()); + //mumAPI.log(ownPluginID, std::string("UDP server at port "+std::to_string(fgcom_udp_port_used)+" stopped").c_str()); + // ^^ note: as long as the mumAPI is synchronuous/blocking, we cannot emit that message: it causes mumble's main thread to block/deadlock. break; } else { // let the incoming data be handled + // Print info to client, so we know what ports are in use + if (firstdata.count(clientPort) == 0 && sizeof(buffer) > 4) { + firstdata[clientPort] = true; + pluginLog("[UDP-server] server connection established from "+clientHost_str+":"+std::to_string(clientPort)); + mumAPI.log(ownPluginID, std::string("UDP server connection established from "+clientHost_str+":"+std::to_string(clientPort)).c_str()); + } + std::map updates; // so we can send updates to remotes updates = fgcom_udp_parseMsg(buffer, clientPort, clientHost_str); From ac0ffe1b8f2aa267ebc56f02a0dd2d981c25d9b0 Mon Sep 17 00:00:00 2001 From: hbeni Date: Wed, 17 Feb 2021 12:32:16 +0100 Subject: [PATCH 2/2] Moved restore of old PTT overwrite state to fgcom_setPluginActive() --- client/mumble-plugin/fgcom-mumble.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/mumble-plugin/fgcom-mumble.cpp b/client/mumble-plugin/fgcom-mumble.cpp index cf4b3785..8036949a 100644 --- a/client/mumble-plugin/fgcom-mumble.cpp +++ b/client/mumble-plugin/fgcom-mumble.cpp @@ -109,6 +109,9 @@ void fgcom_setPluginActive(bool active) { // restore old transmission mode merr = mumAPI.requestLocalUserTransmissionMode(ownPluginID, fgcom_prevTransmissionMode); + + // disable PTT overwrite + merr = mumAPI.requestMicrophoneActivationOvewrite(ownPluginID, false); } fgcom_inSpecialChannel = active; @@ -190,7 +193,6 @@ void fgcom_handlePTT() { // plugin deactivation will already handle setting the old transmission mode, // so the mic will be open according to that... pluginDbg("Handling PTT state: PLUGIN NOT ACTIVE"); - mumAPI.requestMicrophoneActivationOvewrite(ownPluginID, false); } }