mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 16:21:01 +00:00
nuke file descriptor leak..You don't need a whole new thread to hang up a friggen call
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1890 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -56,8 +56,6 @@ MyH323EndPoint *endPoint = NULL;
|
|||||||
/** PWLib entry point */
|
/** PWLib entry point */
|
||||||
MyProcess *localProcess = NULL;
|
MyProcess *localProcess = NULL;
|
||||||
|
|
||||||
/** H.323 listener */
|
|
||||||
H323ListenerTCP *tcpListener;
|
|
||||||
|
|
||||||
MyProcess::MyProcess(): PProcess("The NuFone Network's", "H.323 Channel Driver for Asterisk",
|
MyProcess::MyProcess(): PProcess("The NuFone Network's", "H.323 Channel Driver for Asterisk",
|
||||||
MAJOR_VERSION, MINOR_VERSION, BUILD_TYPE, BUILD_NUMBER)
|
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);
|
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_NAME OPAL_G7231_6k3"{sw}"
|
||||||
#define H323_G729 OPAL_G729 "{sw}"
|
#define H323_G729 OPAL_G729 "{sw}"
|
||||||
#define H323_G729A OPAL_G729A"{sw}"
|
#define H323_G729A OPAL_G729A"{sw}"
|
||||||
@@ -452,8 +430,13 @@ void MyH323EndPoint::OnConnectionCleared(H323Connection & connection, const PStr
|
|||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
if (h323debug)
|
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(connection.IsEstablished())
|
||||||
if (h323debug)
|
if (h323debug)
|
||||||
cout << " -- Call duration " << setprecision(0) << setw(5) << (PTime() - connection.GetConnectionStartTime()) << endl;
|
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)
|
if (!listenPort)
|
||||||
listenPort = 1720;
|
listenPort = 1720;
|
||||||
|
|
||||||
|
/** H.323 listener */
|
||||||
|
H323ListenerTCP *tcpListener;
|
||||||
|
|
||||||
tcpListener = new H323ListenerTCP(*endPoint, interfaceAddress, (WORD)listenPort);
|
tcpListener = new H323ListenerTCP(*endPoint, interfaceAddress, (WORD)listenPort);
|
||||||
|
|
||||||
if (!endPoint->StartListener(tcpListener)) {
|
if (!endPoint->StartListener(tcpListener)) {
|
||||||
@@ -984,6 +970,12 @@ void h323_set_id(char *id)
|
|||||||
endPoint->SetLocalUserName(h323id);
|
endPoint->SetLocalUserName(h323id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void h323_show_tokens(void)
|
||||||
|
{
|
||||||
|
cout << "Current call tokens: " << setprecision(2) << endPoint->GetAllConnections() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Establish Gatekeeper communiations, if so configured,
|
/** Establish Gatekeeper communiations, if so configured,
|
||||||
* register aliases for the H.323 endpoint to respond to.
|
* register aliases for the H.323 endpoint to respond to.
|
||||||
*/
|
*/
|
||||||
@@ -1077,8 +1069,7 @@ int h323_clear_call(const char *call_token)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearCallThread *clearCallThread = new ClearCallThread(call_token);
|
endPoint->ClearCall(PString(call_token));
|
||||||
clearCallThread->WaitForTermination();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
@@ -1118,6 +1109,14 @@ int h323_show_codec(int fd, int argc, char *argv[])
|
|||||||
return 0;
|
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 :( */
|
/* alas, this doesn't work :( */
|
||||||
void h323_native_bridge(const char *token, char *them, char *capability)
|
void h323_native_bridge(const char *token, char *them, char *capability)
|
||||||
|
@@ -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;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -178,6 +178,7 @@ extern "C" {
|
|||||||
int h323_set_gk(int, char *, char *);
|
int h323_set_gk(int, char *, char *);
|
||||||
|
|
||||||
void h323_set_id(char *);
|
void h323_set_id(char *);
|
||||||
|
void h323_show_tokens(void);
|
||||||
|
|
||||||
/* H323 listener related funcions */
|
/* H323 listener related funcions */
|
||||||
int h323_start_listener(int, struct sockaddr_in);
|
int h323_start_listener(int, struct sockaddr_in);
|
||||||
@@ -191,6 +192,7 @@ extern "C" {
|
|||||||
int h323_make_call(char *host, call_details_t *cd, call_options_t);
|
int h323_make_call(char *host, call_details_t *cd, call_options_t);
|
||||||
int h323_clear_call(const char *);
|
int h323_clear_call(const char *);
|
||||||
int h323_answering_call(const char *token, int);
|
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[]);
|
int h323_show_codec(int fd, int argc, char *argv[]);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user