remove m_use_events from Unix wxSocket implementation, we always need asynchronous socket notifications now (and this was always the case under Windows anyhow), even if we don't always generate wx events corresponding to them
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57569 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -267,9 +267,6 @@ public:
|
|||||||
// named) OnRequest() method
|
// named) OnRequest() method
|
||||||
void NotifyOnStateChange(wxSocketNotify event);
|
void NotifyOnStateChange(wxSocketNotify event);
|
||||||
|
|
||||||
// FIXME: this one probably isn't needed here at all
|
|
||||||
virtual void Notify(bool WXUNUSED(notify)) { }
|
|
||||||
|
|
||||||
// TODO: make these fields protected and provide accessors for those of
|
// TODO: make these fields protected and provide accessors for those of
|
||||||
// them that wxSocketBase really needs
|
// them that wxSocketBase really needs
|
||||||
//protected:
|
//protected:
|
||||||
|
@@ -26,7 +26,6 @@ public:
|
|||||||
m_fds[0] =
|
m_fds[0] =
|
||||||
m_fds[1] = -1;
|
m_fds[1] = -1;
|
||||||
|
|
||||||
m_use_events = false;
|
|
||||||
m_enabledCallbacks = 0;
|
m_enabledCallbacks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,8 +34,6 @@ public:
|
|||||||
|
|
||||||
int Read(void *buffer, int size);
|
int Read(void *buffer, int size);
|
||||||
int Write(const void *buffer, int size);
|
int Write(const void *buffer, int size);
|
||||||
//attach or detach from main loop
|
|
||||||
void Notify(bool flag);
|
|
||||||
|
|
||||||
// wxFDIOHandler methods
|
// wxFDIOHandler methods
|
||||||
virtual void OnReadWaiting();
|
virtual void OnReadWaiting();
|
||||||
@@ -73,27 +70,16 @@ private:
|
|||||||
EnableEvents();
|
EnableEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable or disable notifications for socket input/output events but only
|
// enable or disable notifications for socket input/output events
|
||||||
// if m_use_events is true; do nothing otherwise
|
void EnableEvents() { DoEnableEvents(true); }
|
||||||
virtual void EnableEvents()
|
void DisableEvents() { DoEnableEvents(false);
|
||||||
{
|
|
||||||
if ( m_use_events )
|
|
||||||
DoEnableEvents(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisableEvents()
|
// really enable or disable socket input/output events
|
||||||
{
|
|
||||||
if ( m_use_events )
|
|
||||||
DoEnableEvents(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// really enable or disable socket input/output events, regardless of
|
|
||||||
// m_use_events value
|
|
||||||
void DoEnableEvents(bool enable);
|
void DoEnableEvents(bool enable);
|
||||||
|
|
||||||
|
|
||||||
// enable or disable events for the given event if m_use_events; do nothing
|
// enable or disable events for the given event
|
||||||
// otherwise
|
|
||||||
//
|
//
|
||||||
// notice that these functions also update m_detected: EnableEvent() clears
|
// notice that these functions also update m_detected: EnableEvent() clears
|
||||||
// the corresponding bit in it and DisableEvent() sets it
|
// the corresponding bit in it and DisableEvent() sets it
|
||||||
@@ -107,9 +93,6 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// true if socket should fire events
|
|
||||||
bool m_use_events;
|
|
||||||
|
|
||||||
// descriptors for input and output event notification channels associated
|
// descriptors for input and output event notification channels associated
|
||||||
// with the socket
|
// with the socket
|
||||||
int m_fds[2];
|
int m_fds[2];
|
||||||
|
@@ -667,7 +667,7 @@ bool wxSocketBase::Destroy()
|
|||||||
// Shutdown and close the socket
|
// Shutdown and close the socket
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
// Supress events from now on
|
// Suppress events from now on
|
||||||
Notify(false);
|
Notify(false);
|
||||||
|
|
||||||
// schedule this object for deletion
|
// schedule this object for deletion
|
||||||
@@ -1540,8 +1540,6 @@ void wxSocketBase::OnRequest(wxSocketNotify notification)
|
|||||||
void wxSocketBase::Notify(bool notify)
|
void wxSocketBase::Notify(bool notify)
|
||||||
{
|
{
|
||||||
m_notify = notify;
|
m_notify = notify;
|
||||||
if (m_impl)
|
|
||||||
m_impl->Notify(notify);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSocketBase::SetNotify(wxSocketEventFlags flags)
|
void wxSocketBase::SetNotify(wxSocketEventFlags flags)
|
||||||
@@ -1632,7 +1630,6 @@ wxSocketServer::wxSocketServer(const wxSockAddress& addr_man,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup the socket as server
|
// Setup the socket as server
|
||||||
m_impl->Notify(m_notify);
|
|
||||||
m_impl->SetLocal(addr_man.GetAddress());
|
m_impl->SetLocal(addr_man.GetAddress());
|
||||||
|
|
||||||
if (GetFlags() & wxSOCKET_REUSEADDR) {
|
if (GetFlags() & wxSOCKET_REUSEADDR) {
|
||||||
@@ -1818,9 +1815,6 @@ bool wxSocketClient::DoConnect(const wxSockAddress& addr_man,
|
|||||||
m_impl->SetPeer(addr_man.GetAddress());
|
m_impl->SetPeer(addr_man.GetAddress());
|
||||||
const wxSocketError err = m_impl->CreateClient();
|
const wxSocketError err = m_impl->CreateClient();
|
||||||
|
|
||||||
//this will register for callbacks - must be called after m_impl->m_fd was initialized
|
|
||||||
m_impl->Notify(m_notify);
|
|
||||||
|
|
||||||
if (err != wxSOCKET_NOERROR)
|
if (err != wxSOCKET_NOERROR)
|
||||||
{
|
{
|
||||||
if (err == wxSOCKET_WOULDBLOCK)
|
if (err == wxSOCKET_WOULDBLOCK)
|
||||||
@@ -1879,7 +1873,6 @@ wxDatagramSocket::wxDatagramSocket( const wxSockAddress& addr,
|
|||||||
if (!m_impl)
|
if (!m_impl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_impl->Notify(m_notify);
|
|
||||||
// Setup the socket as non connection oriented
|
// Setup the socket as non connection oriented
|
||||||
m_impl->SetLocal(addr.GetAddress());
|
m_impl->SetLocal(addr.GetAddress());
|
||||||
if (flags & wxSOCKET_REUSEADDR)
|
if (flags & wxSOCKET_REUSEADDR)
|
||||||
|
@@ -535,20 +535,10 @@ wxSocketImpl *wxSocketImplUnix::WaitConnection(wxSocketBase& wxsocket)
|
|||||||
#else
|
#else
|
||||||
ioctl(connection->m_fd, FIONBIO, &arg);
|
ioctl(connection->m_fd, FIONBIO, &arg);
|
||||||
#endif
|
#endif
|
||||||
if (m_use_events)
|
|
||||||
connection->Notify(true);
|
|
||||||
|
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSocketImplUnix::Notify(bool flag)
|
|
||||||
{
|
|
||||||
if (flag == m_use_events)
|
|
||||||
return;
|
|
||||||
m_use_events = flag;
|
|
||||||
DoEnableEvents(flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxSocketImplUnix::DoEnableEvents(bool flag)
|
void wxSocketImplUnix::DoEnableEvents(bool flag)
|
||||||
{
|
{
|
||||||
wxSocketManager * const manager = wxSocketManager::Get();
|
wxSocketManager * const manager = wxSocketManager::Get();
|
||||||
@@ -672,12 +662,9 @@ int wxSocketImplUnix::Read(void *buffer, int size)
|
|||||||
if ((ret == 0) && m_stream)
|
if ((ret == 0) && m_stream)
|
||||||
{
|
{
|
||||||
/* Make sure wxSOCKET_LOST event gets sent and shut down the socket */
|
/* Make sure wxSOCKET_LOST event gets sent and shut down the socket */
|
||||||
if (m_use_events)
|
m_detected = wxSOCKET_LOST_FLAG;
|
||||||
{
|
OnReadWaiting();
|
||||||
m_detected = wxSOCKET_LOST_FLAG;
|
return 0;
|
||||||
OnReadWaiting();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (ret == -1)
|
else if (ret == -1)
|
||||||
{
|
{
|
||||||
@@ -754,20 +741,14 @@ int wxSocketImplUnix::Write(const void *buffer, int size)
|
|||||||
|
|
||||||
void wxSocketImplUnix::EnableEvent(wxSocketNotify event)
|
void wxSocketImplUnix::EnableEvent(wxSocketNotify event)
|
||||||
{
|
{
|
||||||
if (m_use_events)
|
m_detected &= ~(1 << event);
|
||||||
{
|
wxSocketManager::Get()->Install_Callback(this, event);
|
||||||
m_detected &= ~(1 << event);
|
|
||||||
wxSocketManager::Get()->Install_Callback(this, event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSocketImplUnix::DisableEvent(wxSocketNotify event)
|
void wxSocketImplUnix::DisableEvent(wxSocketNotify event)
|
||||||
{
|
{
|
||||||
if (m_use_events)
|
m_detected |= (1 << event);
|
||||||
{
|
wxSocketManager::Get()->Uninstall_Callback(this, event);
|
||||||
m_detected |= (1 << event);
|
|
||||||
wxSocketManager::Get()->Uninstall_Callback(this, event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxSocketImplUnix::Recv_Stream(void *buffer, int size)
|
int wxSocketImplUnix::Recv_Stream(void *buffer, int size)
|
||||||
|
Reference in New Issue
Block a user