[Asterisk-cvs] asterisk/channels/h323 ast_h323.cpp,1.29,1.30 ast_h323.h,1.14,1.15 chan_h323.h,1.14,1.15

jeremy at lists.digium.com jeremy at lists.digium.com
Tue Jan 6 10:51:43 CST 2004


Update of /usr/cvsroot/asterisk/channels/h323
In directory mongoose.digium.com:/tmp/cvs-serv26870

Modified Files:
	ast_h323.cpp ast_h323.h chan_h323.h 
Log Message:
nuke file descriptor leak..You don't need a whole new thread to hang up a friggen call


Index: ast_h323.cpp
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/ast_h323.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- ast_h323.cpp	24 Dec 2003 22:36:57 -0000	1.29
+++ ast_h323.cpp	6 Jan 2004 16:43:24 -0000	1.30
@@ -56,8 +56,6 @@
 /** 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 @@
 	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 @@
 			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 @@
 	if (!listenPort)
 		listenPort = 1720;
 	
+	/** H.323 listener */  
+	H323ListenerTCP *tcpListener;
+
 	tcpListener = new H323ListenerTCP(*endPoint, interfaceAddress, (WORD)listenPort);
 
 	if (!endPoint->StartListener(tcpListener)) {
@@ -984,6 +970,12 @@
 	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 @@
 		return 1;
 	}
 
-	ClearCallThread	*clearCallThread = new ClearCallThread(call_token);
-	clearCallThread->WaitForTermination();
-	
+        endPoint->ClearCall(PString(call_token));
+
 	return 0;
 };
 
@@ -1118,6 +1109,14 @@
 	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)

Index: ast_h323.h
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/ast_h323.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- ast_h323.h	24 Dec 2003 22:36:57 -0000	1.14
+++ ast_h323.h	6 Jan 2004 16:43:24 -0000	1.15
@@ -330,23 +330,3 @@
 };
 
 
-/** 
- * 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;
-};
-
-

Index: chan_h323.h
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/chan_h323.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- chan_h323.h	24 Dec 2003 22:36:57 -0000	1.14
+++ chan_h323.h	6 Jan 2004 16:43:24 -0000	1.15
@@ -178,6 +178,7 @@
 	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 @@
 	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
 }




More information about the svn-commits mailing list