@@ -35,9 +35,6 @@ const int MAX_MESSAGE_LENGTH = 64000;
3535 #include < unistd.h>
3636#endif
3737
38- NetworkEvents::ZMQContext* NetworkEvents::sharedContext = nullptr ;
39- CriticalSection NetworkEvents::sharedContextLock{};
40-
4138NetworkEvents::NetworkEvents ()
4239 : GenericProcessor (" Network Events" )
4340 , Thread (" NetworkThread" )
@@ -79,6 +76,7 @@ String NetworkEvents::getCurrPortString() const
7976
8077void NetworkEvents::restartConnection ()
8178{
79+ requestedPort = boundPort.load ();
8280 makeNewSocket = true ;
8381}
8482
@@ -430,21 +428,15 @@ String NetworkEvents::getPortString(uint16 port)
430428
431429/* ** ZMQContext ***/
432430
433- NetworkEvents::ZMQContext::ZMQContext (const ScopedLock& lock )
431+ NetworkEvents::ZMQContext::ZMQContext ()
434432#ifdef ZEROMQ
435433 : context(zmq_ctx_new())
436434#endif
437- {
438- // sharedContextLock should already be held here
439- sharedContext = this ;
440- }
435+ {}
441436
442- // ZMQContext is a ReferenceCountedObject with a pointer in each instance's
443- // socket pointer, so this only happens when the last instance is destroyed.
437+ // only happens when the last SharedResourcePointer is destroyed.
444438NetworkEvents::ZMQContext::~ZMQContext ()
445439{
446- ScopedLock lock (sharedContextLock);
447- sharedContext = nullptr ;
448440#ifdef ZEROMQ
449441 zmq_ctx_destroy (context);
450442#endif
@@ -471,20 +463,6 @@ NetworkEvents::Responder::Responder(uint16 port)
471463 , boundPort (0 )
472464 , lastErrno (0 )
473465{
474- {
475- ScopedLock lock (sharedContextLock);
476- if (sharedContext == nullptr )
477- {
478- // first one, create the context
479- context = new ZMQContext (lock);
480- }
481- else
482- {
483- // use already-created context
484- context = sharedContext;
485- }
486- }
487-
488466#ifdef ZEROMQ
489467 socket = context->createSocket ();
490468 if (!socket)
0 commit comments