From 96fb12f2f663d1913a599123e3388650c6d0f05a Mon Sep 17 00:00:00 2001 From: jeremy Date: Tue, 6 Jan 2004 16:43:24 +0000 Subject: nuke file descriptor leak..You don't need a whole new thread to hang up a friggen call git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1890 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/h323/ast_h323.cpp | 51 +++++++++++++++++++++++----------------------- channels/h323/ast_h323.h | 20 ------------------ channels/h323/chan_h323.h | 4 +++- 3 files changed, 28 insertions(+), 47 deletions(-) diff --git a/channels/h323/ast_h323.cpp b/channels/h323/ast_h323.cpp index 3a822c806..73973e0d6 100755 --- a/channels/h323/ast_h323.cpp +++ b/channels/h323/ast_h323.cpp @@ -56,8 +56,6 @@ MyH323EndPoint *endPoint = NULL; /** PWLib entry point */ MyProcess *localProcess = NULL; -/** H.323 listener */ -H323ListenerTCP *tcpListener; MyProcess::MyProcess(): PProcess("The NuFone Network's", "H.323 Channel Driver for Asterisk", MAJOR_VERSION, MINOR_VERSION, BUILD_TYPE, BUILD_NUMBER) @@ -79,26 +77,6 @@ void MyProcess::Main() PTrace::Initialise(0, NULL, PTrace::Timestamp | PTrace::Thread | PTrace::FileAndLine); } -ClearCallThread::ClearCallThread(const char *tc) : PThread(10000, PThread::NoAutoDeleteThread) -{ - token = tc; - Resume(); -} - -ClearCallThread::~ClearCallThread() -{ - if (h323debug) - cout << " == ClearCall thread going down." << endl; - return; -} - -void ClearCallThread::Main() -{ - endPoint->ClearCall(token); - return; -} - - #define H323_NAME OPAL_G7231_6k3"{sw}" #define H323_G729 OPAL_G729 "{sw}" #define H323_G729A OPAL_G729A"{sw}" @@ -452,8 +430,13 @@ void MyH323EndPoint::OnConnectionCleared(H323Connection & connection, const PStr break; default : if (h323debug) - cout << " -- Call with " << remoteName << " completed" << endl; + cout << " -- Call with " << remoteName << " completed (" << connection.GetCallEndReason() << ")" << endl; + } + + cout << " -- Call with " << remoteName << " completed (" << connection.GetCallEndReason() << ")" << endl; + + if(connection.IsEstablished()) if (h323debug) cout << " -- Call duration " << setprecision(0) << setw(5) << (PTime() - connection.GetConnectionStartTime()) << endl; @@ -920,6 +903,9 @@ int h323_start_listener(int listenPort, struct sockaddr_in bindaddr) if (!listenPort) listenPort = 1720; + /** H.323 listener */ + H323ListenerTCP *tcpListener; + tcpListener = new H323ListenerTCP(*endPoint, interfaceAddress, (WORD)listenPort); if (!endPoint->StartListener(tcpListener)) { @@ -984,6 +970,12 @@ void h323_set_id(char *id) endPoint->SetLocalUserName(h323id); } +void h323_show_tokens(void) +{ + cout << "Current call tokens: " << setprecision(2) << endPoint->GetAllConnections() << endl; +} + + /** Establish Gatekeeper communiations, if so configured, * register aliases for the H.323 endpoint to respond to. */ @@ -1077,9 +1069,8 @@ int h323_clear_call(const char *call_token) return 1; } - ClearCallThread *clearCallThread = new ClearCallThread(call_token); - clearCallThread->WaitForTermination(); - + endPoint->ClearCall(PString(call_token)); + return 0; }; @@ -1118,6 +1109,14 @@ int h323_show_codec(int fd, int argc, char *argv[]) return 0; } +int h323_soft_hangup(const char *data) +{ + PString token(data); + BOOL result; + + result = endPoint->ClearCall(token); + return result; +} /* alas, this doesn't work :( */ void h323_native_bridge(const char *token, char *them, char *capability) diff --git a/channels/h323/ast_h323.h b/channels/h323/ast_h323.h index 5c0c2b4a9..00494c486 100755 --- a/channels/h323/ast_h323.h +++ b/channels/h323/ast_h323.h @@ -330,23 +330,3 @@ class MyProcess : public PProcess { }; -/** - * This class handles the termination of a call. - * Note that OpenH323 Library requires that the termination - * of a call should be done inside a separate thread of execution. - */ -class ClearCallThread : public PThread { - - PCLASSINFO(ClearCallThread, PThread); - - public: - ClearCallThread(const char *tc); - ~ClearCallThread(); - - void Main(); - - protected: - PString token; -}; - - diff --git a/channels/h323/chan_h323.h b/channels/h323/chan_h323.h index c330dd883..f152e6a39 100755 --- a/channels/h323/chan_h323.h +++ b/channels/h323/chan_h323.h @@ -178,6 +178,7 @@ extern "C" { int h323_set_gk(int, char *, char *); void h323_set_id(char *); + void h323_show_tokens(void); /* H323 listener related funcions */ int h323_start_listener(int, struct sockaddr_in); @@ -191,9 +192,10 @@ extern "C" { int h323_make_call(char *host, call_details_t *cd, call_options_t); int h323_clear_call(const char *); int h323_answering_call(const char *token, int); + int h323_soft_hangup(const char *data); int h323_show_codec(int fd, int argc, char *argv[]); - + #ifdef __cplusplus } -- cgit v1.2.3