* wxSocket seems to work with the async requester turned off.

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
This commit is contained in:
Guilhem Lavaux 1999-05-23 16:09:45 +00:00
parent 6bc8a1c80b
commit 48da7d0ba8
3 changed files with 34 additions and 17 deletions

View File

@ -553,8 +553,8 @@ bool wxEvtHandler::ProcessThreadEvent(wxEvent& event)
wxPendingEventsLocker->Leave();
#ifdef __WXGTK__
if (g_isIdle)
wxapp_install_idle_handler();
// if (g_isIdle)
// wxapp_install_idle_handler();
#endif
return TRUE;

View File

@ -114,6 +114,7 @@ void SocketWaiter::ProcessReadEvent()
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);
}
}
@ -141,6 +142,8 @@ void *SocketWaiter::Entry()
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)
@ -156,6 +159,8 @@ void *SocketWaiter::Entry()
if (FD_ISSET(m_fd, &sockwr_set))
ProcessWriteEvent();
m_internal->ReleaseData();
#if wxUSE_THREADS
#ifdef Yield
#undef Yield
@ -387,6 +392,20 @@ void wxSocketInternal::EndRequest(SockRequest *req)
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
@ -433,21 +452,23 @@ void wxSocketInternal::StopRequester()
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();
@ -494,13 +515,10 @@ void wxSocketInternal::StopWaiter()
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();
@ -522,7 +540,6 @@ void wxSocketInternal::QueueRequest(SockRequest *request, bool async)
}
}
} else {
*/
m_request_locker.Lock();
if ((request->type & wxSocketBase::REQ_WAIT) != 0) {
@ -543,9 +560,7 @@ void wxSocketInternal::QueueRequest(SockRequest *request, bool async)
}
request->done = TRUE;
m_request_locker.Unlock();
// }
delete m_thread_requester;
m_thread_requester = NULL;
}
#endif
}

View File

@ -543,7 +543,9 @@ void wxSocketBase::SetNotify(wxRequestNotify flags)
if (m_type != SOCK_SERVER)
flags &= ~REQ_ACCEPT;
m_internal->AcquireData();
m_neededreq = flags;
m_internal->ReleaseData();
if (m_neededreq == 0)
m_internal->StopWaiter();
else
@ -691,10 +693,10 @@ void wxSocketBase::WantBuffer(char *buffer, size_t nbytes,
buf->timeout = 1000;
buf_timed_out = FALSE;
if (m_flags & SPEED)
if ((m_flags & SPEED) != 0)
m_internal->QueueRequest(buf, FALSE);
else
if (m_flags & NOWAIT)
if ((m_flags & NOWAIT) != 0)
m_internal->QueueRequest(buf, TRUE);
else
m_internal->QueueRequest(buf, TRUE);