summaryrefslogtreecommitdiffstats
path: root/src/OSSupport
diff options
context:
space:
mode:
Diffstat (limited to 'src/OSSupport')
-rw-r--r--src/OSSupport/Event.cpp13
-rw-r--r--src/OSSupport/Event.h4
-rw-r--r--src/OSSupport/TCPLinkImpl.cpp28
3 files changed, 8 insertions, 37 deletions
diff --git a/src/OSSupport/Event.cpp b/src/OSSupport/Event.cpp
index be2803451..02f1fdbcc 100644
--- a/src/OSSupport/Event.cpp
+++ b/src/OSSupport/Event.cpp
@@ -62,16 +62,3 @@ void cEvent::Set(void)
-void cEvent::SetAll(void)
-{
- {
- std::unique_lock<std::mutex> Lock(m_Mutex);
- m_ShouldContinue = true;
- }
- m_CondVar.notify_all();
-}
-
-
-
-
-
diff --git a/src/OSSupport/Event.h b/src/OSSupport/Event.h
index 94f062123..44da0c97b 100644
--- a/src/OSSupport/Event.h
+++ b/src/OSSupport/Event.h
@@ -30,10 +30,6 @@ public:
If there was no thread waiting, the next call to Wait() will not block. */
void Set(void);
- /** Sets the event - releases all threads that have been waiting in Wait().
- If there was no thread waiting, the next call to Wait() will not block. */
- void SetAll(void);
-
/** Waits for the event until either it is signalled, or the (relative) timeout is passed.
Returns true if the event was signalled, false if the timeout was hit or there was an error. */
bool Wait(unsigned a_TimeoutMSec);
diff --git a/src/OSSupport/TCPLinkImpl.cpp b/src/OSSupport/TCPLinkImpl.cpp
index b15b6282f..0432ca973 100644
--- a/src/OSSupport/TCPLinkImpl.cpp
+++ b/src/OSSupport/TCPLinkImpl.cpp
@@ -88,8 +88,9 @@ cTCPLinkImplPtr cTCPLinkImpl::Connect(const AString & a_Host, UInt16 a_Port, cTC
// Success
return res;
}
+
// Failure
- cNetworkSingleton::Get().RemoveLink(res.get());
+ res->Close();
return nullptr;
}
@@ -99,8 +100,9 @@ cTCPLinkImplPtr cTCPLinkImpl::Connect(const AString & a_Host, UInt16 a_Port, cTC
// Success
return res;
}
+
// Failure
- cNetworkSingleton::Get().RemoveLink(res.get());
+ res->Close();
return nullptr;
}
@@ -214,6 +216,7 @@ void cTCPLinkImpl::EventCallback(bufferevent * a_BufferEvent, short a_What, void
{
ASSERT(a_Self != nullptr);
cTCPLinkImplPtr Self = static_cast<cTCPLinkImpl *>(a_Self)->m_Self;
+ ASSERT(Self != nullptr);
// If an error is reported, call the error callback:
if (a_What & BEV_EVENT_ERROR)
@@ -232,16 +235,9 @@ void cTCPLinkImpl::EventCallback(bufferevent * a_BufferEvent, short a_What, void
else
{
Self->m_Callbacks->OnError(err, evutil_socket_error_to_string(err));
- if (Self->m_Server == nullptr)
- {
- cNetworkSingleton::Get().RemoveLink(Self.get());
- }
- else
- {
- Self->m_Server->RemoveLink(Self.get());
- }
}
- Self->m_Self.reset();
+
+ Self->Close();
return;
}
@@ -263,15 +259,7 @@ void cTCPLinkImpl::EventCallback(bufferevent * a_BufferEvent, short a_What, void
if (a_What & BEV_EVENT_EOF)
{
Self->m_Callbacks->OnRemoteClosed();
- if (Self->m_Server != nullptr)
- {
- Self->m_Server->RemoveLink(Self.get());
- }
- else
- {
- cNetworkSingleton::Get().RemoveLink(Self.get());
- }
- Self->m_Self.reset();
+ Self->Close();
return;
}