m_socket->OnRequest(wxSocketBase::EVT_READ);
} else {
m_socket->OnRequest(wxSocketBase::EVT_LOST);
+ m_internal->ReleaseData(); // In that case, we mustn't forget to unlock the mutex.
Exit(NULL);
}
}
FD_ZERO(&sockrd_set);
FD_ZERO(&sockwr_set);
+ m_internal->AcquireData();
+
if ((m_socket->NeededReq() & READ_MASK) != 0)
FD_SET(m_fd, &sockrd_set);
if ((m_socket->NeededReq() & WRITE_MASK) != 0)
if (FD_ISSET(m_fd, &sockwr_set))
ProcessWriteEvent();
+ m_internal->ReleaseData();
+
#if wxUSE_THREADS
#ifdef Yield
#undef Yield
delete node;
}
+void wxSocketInternal::AcquireData()
+{
+#if wxUSE_THREADS
+ m_socket_locker.Lock();
+#endif
+}
+
+void wxSocketInternal::ReleaseData()
+{
+#if wxUSE_THREADS
+ m_socket_locker.Unlock();
+#endif
+}
+
void wxSocketInternal::AcquireFD()
{
#if wxUSE_THREADS
m_end_requester.Lock();
if (m_invalid_requester) {
m_end_requester.Unlock();
- delete m_thread_requester;
- m_thread_requester = NULL;
- m_invalid_requester = FALSE;
+ if (m_thread_requester) {
+ delete m_thread_requester;
+ m_thread_requester = NULL;
+ }
+ m_invalid_requester = TRUE;
return;
}
m_end_requester.Unlock();
wxASSERT(m_thread_requester != NULL);
- m_socket_locker.Lock();
+ m_request_locker.Lock();
// Send a signal to the requester.
m_socket_cond.Signal();
- m_socket_locker.Unlock();
+ m_request_locker.Unlock();
// Finish the destruction of the requester.
m_thread_requester->Delete();
void wxSocketInternal::QueueRequest(SockRequest *request, bool async)
{
#if wxUSE_THREADS
-/*
if (m_invalid_requester)
ResumeRequester();
-*/
- m_thread_requester = new SocketRequester(m_socket, this);
-/*
+ async = FALSE;
if (async) {
m_request_locker.Lock();
}
}
} else {
-*/
m_request_locker.Lock();
if ((request->type & wxSocketBase::REQ_WAIT) != 0) {
}
request->done = TRUE;
m_request_locker.Unlock();
-// }
- delete m_thread_requester;
- m_thread_requester = NULL;
+ }
#endif
}