From: <tom...@us...> - 2012-01-26 22:54:50
|
Revision: 3347 http://razorbacktm.svn.sourceforge.net/razorbacktm/?rev=3347&view=rev Author: tomjudge Date: 2012-01-26 22:54:44 +0000 (Thu, 26 Jan 2012) Log Message: ----------- Make sure we release references to the threads we launch Modified Paths: -------------- dispatcher/trunk/src/console.c dispatcher/trunk/src/console_ssh.c dispatcher/trunk/src/transfer/ssh.c Modified: dispatcher/trunk/src/console.c =================================================================== --- dispatcher/trunk/src/console.c 2012-01-26 22:54:13 UTC (rev 3346) +++ dispatcher/trunk/src/console.c 2012-01-26 22:54:44 UTC (rev 3347) @@ -9,7 +9,6 @@ #include "configuration.h" -static struct Thread *sg_pThread; void Console_Telnet_Server (struct Thread *p_pThread); void Console_SSH_Server (struct Thread *p_pThread); @@ -17,6 +16,7 @@ bool Console_Initialize (struct RazorbackContext *p_pContext) { + struct Thread *thread; if (!Console_CLI_Initialize()) return false; @@ -24,23 +24,27 @@ if (g_telnetConsole.enable == 1) { - sg_pThread = + thread = Thread_Launch (Console_Telnet_Server, NULL, (char *) "Console Telnet Server", p_pContext); - if (sg_pThread == NULL) + if (thread == NULL) { rzb_log (LOG_ERR, "%s: Failed to launch telnet server thread", __func__); } + Thread_Destroy(thread); + thread = NULL; } if (g_sshConsole.enable == 1) { - sg_pThread = + thread = Thread_Launch (Console_SSH_Server, NULL, (char *) "Console SSH Server", p_pContext); - if (sg_pThread == NULL) + if (thread == NULL) { rzb_log (LOG_ERR, "%s: Failed to launch ssh server thread", __func__); } + Thread_Destroy(thread); + thread = NULL; } return true; @@ -58,6 +62,7 @@ struct Socket *l_pSocket; struct Socket *l_pAcceptSocket; struct ConsoleSession *session; + struct Thread *thread; if ((l_pAcceptSocket = Socket_Listen ((const uint8_t *) g_telnetConsole.bindAddress, g_telnetConsole.bindPort)) == NULL) @@ -81,8 +86,13 @@ session->socket = l_pSocket; session->quitCallback = Console_Telnet_Quit; rzb_log (LOG_DEBUG, "%s: Launching console thread", __func__); - Thread_Launch (Console_Thread, session, + thread = Thread_Launch (Console_Thread, session, (char *) "Console Session", p_pThread->pContext); + if (thread == NULL) + rzb_log(LOG_ERR, "%s: Failed to launch console thread", __func__); + else + Thread_Destroy(thread); + thread = NULL; } } Modified: dispatcher/trunk/src/console_ssh.c =================================================================== --- dispatcher/trunk/src/console_ssh.c 2012-01-26 22:54:13 UTC (rev 3346) +++ dispatcher/trunk/src/console_ssh.c 2012-01-26 22:54:44 UTC (rev 3347) @@ -134,7 +134,8 @@ Console_SSH_Quit(struct ConsoleSession *session) { struct SshConsoleSession *sshSession = (struct SshConsoleSession *)session->userdata; - Thread_Stop(sshSession->ioThread); + Thread_Interrupt(sshSession->ioThread); + Thread_Destroy(sshSession->ioThread); free(sshSession); free(session); } @@ -173,7 +174,7 @@ consoleSession->socket->iSocket = fds[1]; consoleSession->authenticated = true; consoleSession->userdata = sshSession; - + consoleSession->quitCallback = Console_SSH_Quit; ssh_callbacks_init(sshSession->chan_callbacks); sshSession->chan_callbacks->userdata = &fds[0]; sshSession->chan_callbacks->channel_data_function = copy_chan_to_fd; Modified: dispatcher/trunk/src/transfer/ssh.c =================================================================== --- dispatcher/trunk/src/transfer/ssh.c 2012-01-26 22:54:13 UTC (rev 3346) +++ dispatcher/trunk/src/transfer/ssh.c 2012-01-26 22:54:44 UTC (rev 3347) @@ -603,6 +603,7 @@ int shell=0; int r; int port = transferBindPort; + struct Thread *thread; if (!Database_Thread_Initialize()) { @@ -754,7 +755,7 @@ free(ses); continue; } - if (Thread_Launch (Transfer_SSH_Server_Session, ses, (char *) "Transfer SSH Server Session", &sg_rbContext) == NULL) + if ((thread = Thread_Launch (Transfer_SSH_Server_Session, ses, (char *) "Transfer SSH Server Session", &sg_rbContext)) == NULL) { rzb_log(LOG_ERR, "%s: Failed to launch session thread", __func__); ssh_channel_close(ses->chan); @@ -766,6 +767,8 @@ free(ses); continue; } + Thread_Destroy(thread); + thread = NULL; } ssh_bind_free(sshbind); ssh_finalize(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |