Two things to fix:
* async requester bug
* GTK/GLIB idle loop wake up
URL/HTTP/FTP/SocketServer/SocketClient seems to work (well, they work
on my computer).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2541
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
wxPendingEventsLocker->Leave();
#ifdef __WXGTK__
wxPendingEventsLocker->Leave();
#ifdef __WXGTK__
- if (g_isIdle)
- wxapp_install_idle_handler();
+// if (g_isIdle)
+// wxapp_install_idle_handler();
m_socket->OnRequest(wxSocketBase::EVT_READ);
} else {
m_socket->OnRequest(wxSocketBase::EVT_LOST);
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.
FD_ZERO(&sockrd_set);
FD_ZERO(&sockwr_set);
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 ((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();
if (FD_ISSET(m_fd, &sockwr_set))
ProcessWriteEvent();
+ m_internal->ReleaseData();
+
#if wxUSE_THREADS
#ifdef Yield
#undef Yield
#if wxUSE_THREADS
#ifdef Yield
#undef Yield
+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
void wxSocketInternal::AcquireFD()
{
#if wxUSE_THREADS
m_end_requester.Lock();
if (m_invalid_requester) {
m_end_requester.Unlock();
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);
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();
// 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();
// Finish the destruction of the requester.
m_thread_requester->Delete();
void wxSocketInternal::QueueRequest(SockRequest *request, bool async)
{
#if wxUSE_THREADS
void wxSocketInternal::QueueRequest(SockRequest *request, bool async)
{
#if wxUSE_THREADS
if (m_invalid_requester)
ResumeRequester();
if (m_invalid_requester)
ResumeRequester();
-*/
- m_thread_requester = new SocketRequester(m_socket, this);
if (async) {
m_request_locker.Lock();
if (async) {
m_request_locker.Lock();
m_request_locker.Lock();
if ((request->type & wxSocketBase::REQ_WAIT) != 0) {
m_request_locker.Lock();
if ((request->type & wxSocketBase::REQ_WAIT) != 0) {
}
request->done = TRUE;
m_request_locker.Unlock();
}
request->done = TRUE;
m_request_locker.Unlock();
-// }
- delete m_thread_requester;
- m_thread_requester = NULL;
if (m_type != SOCK_SERVER)
flags &= ~REQ_ACCEPT;
if (m_type != SOCK_SERVER)
flags &= ~REQ_ACCEPT;
+ m_internal->AcquireData();
+ m_internal->ReleaseData();
if (m_neededreq == 0)
m_internal->StopWaiter();
else
if (m_neededreq == 0)
m_internal->StopWaiter();
else
buf->timeout = 1000;
buf_timed_out = FALSE;
buf->timeout = 1000;
buf_timed_out = FALSE;
+ if ((m_flags & SPEED) != 0)
m_internal->QueueRequest(buf, FALSE);
else
m_internal->QueueRequest(buf, FALSE);
else
+ if ((m_flags & NOWAIT) != 0)
m_internal->QueueRequest(buf, TRUE);
else
m_internal->QueueRequest(buf, TRUE);
m_internal->QueueRequest(buf, TRUE);
else
m_internal->QueueRequest(buf, TRUE);