MT#62181 global: fix AmThread/AmEventQueue order

Classes that inherit from both AmThread and AmEventHandler must inherit
from AmEventQueue first and from AmThread after. This is needed so that
the AmThread dtor is called first, which will trigger the thread to shut
down, which in turn makes sure nothing is waiting on the AmEventQueue's
condition variable.

Otherwise, if AmEventQueue is destroyed first while the corresponding
thread is still running and waiting on the condition variable, it will
be a deadlock.

With this, sems finally can shut down cleanly without having to be
killed by systemd.

Change-Id: I914455763b517c96561acb0b64fce26f127f44bc
mr13.3.1
Richard Fuchs 1 year ago
parent 06edeb7ce0
commit 8d0c121afc

@ -97,8 +97,8 @@ class DBRegAgent;
// separate thread for REGISTER sending, which can block for rate limiting
class DBRegAgentProcessorThread
: public AmThread,
public AmEventQueue,
: public AmEventQueue,
public AmThread,
public AmEventHandler
{
@ -126,8 +126,8 @@ class RegTimer;
class DBRegAgent
: public AmDynInvokeFactory,
public AmDynInvoke,
public AmThread,
public AmEventQueue,
public AmThread,
public AmEventHandler
{

@ -93,8 +93,8 @@ struct DiameterServerConnection {
};
class ServerConnection
: public AmThread,
public AmEventQueue,
: public AmEventQueue,
public AmThread,
public AmEventHandler
{
struct timeval connect_ts;

@ -24,8 +24,8 @@ class EventProxySession
};
class SystemDSM
: public AmThread,
public AmEventQueue,
: public AmEventQueue,
public AmThread,
public AmEventHandler,
public DSMSession

@ -44,7 +44,7 @@
#include <map>
class JsonRPCServerLoop
: public AmThread, public AmEventQueue, public AmEventHandler
: public AmEventQueue, public AmThread, public AmEventHandler
{
static RpcServerThreadpool threadpool;
static ev_async async_w;

@ -36,7 +36,7 @@
#include "RpcPeer.h"
class RpcServerThread
: public AmThread, public AmEventQueue, public AmEventHandler
: public AmEventQueue, public AmThread, public AmEventHandler
{
char rcvbuf[MAX_RPC_MSG_SIZE];

@ -96,8 +96,8 @@ struct DIMethodProxy : public XmlRpcServerMethod
};
class XMLRPC2DIServer
: public AmThread,
public AmEventQueue,
: public AmEventQueue,
public AmThread,
public AmEventHandler
{
XmlRpcServer* s;

@ -107,8 +107,8 @@ class AmCallWatcherGarbageCollector;
* reporting the status change.
*/
class AmCallWatcher
: public AmThread,
public AmEventQueue,
: public AmEventQueue,
public AmThread,
public AmEventHandler
{
public:

@ -66,10 +66,10 @@ class AmDtmfEvent;
*/
class AmSession :
public virtual AmObject,
public AmEventQueue,
#ifndef SESSION_THREADPOOL
public AmThread,
#endif
public AmEventQueue,
public AmEventHandler,
public AmSipDialogEventHandler,
public AmMediaSession,

Loading…
Cancel
Save