From 62088a3c3b9a945b0b2cbc78c74f83c51ee046aa Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 27 Dec 2008 22:03:34 +0000 Subject: [PATCH] wxSocketImpl::Shutdown() doesn't need to be virtual, its implementation can the same in Unix and Win32 versions (events are already disabled by Close() so there is no need to do it again explicitly under Unix) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57611 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/private/socket.h | 6 +++++- include/wx/unix/private/sockunix.h | 2 -- src/unix/sockunix.cpp | 20 ++++++++------------ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/include/wx/private/socket.h b/include/wx/private/socket.h index b830d957ad..d546a91acc 100644 --- a/include/wx/private/socket.h +++ b/include/wx/private/socket.h @@ -250,7 +250,11 @@ public: // it was indeed created void Close(); - virtual void Shutdown(); + // shuts down the writing end of the socket and closes it, this is a more + // graceful way to close + // + // does nothing if the socket wasn't created + void Shutdown(); // IO operations diff --git a/include/wx/unix/private/sockunix.h b/include/wx/unix/private/sockunix.h index 11e512ec15..d51d75f130 100644 --- a/include/wx/unix/private/sockunix.h +++ b/include/wx/unix/private/sockunix.h @@ -31,8 +31,6 @@ public: virtual wxSocketError GetLastError() const; - virtual void Shutdown(); - virtual int Read(void *buffer, int size); virtual int Write(const void *buffer, int size); diff --git a/src/unix/sockunix.cpp b/src/unix/sockunix.cpp index 28aa7ed7db..30a417ecc3 100644 --- a/src/unix/sockunix.cpp +++ b/src/unix/sockunix.cpp @@ -174,6 +174,10 @@ int _System soclose(int); # define GSOCKET_MSG_NOSIGNAL 0 #endif /* MSG_NOSIGNAL */ +// ---------------------------------------------------------------------------- +// implementation of thread-safe/reentrant functions if they're missing +// ---------------------------------------------------------------------------- + #if wxUSE_THREADS && (defined(HAVE_GETHOSTBYNAME) || defined(HAVE_GETSERVBYNAME)) # include "wx/thread.h" #endif @@ -424,6 +428,10 @@ struct servent *wxGetservbyname_r(const char *port, const char *protocol, return se; } +// ============================================================================ +// wxSocketImpl implementation +// ============================================================================ + /* static */ wxSocketImpl *wxSocketImpl::Create(wxSocketBase& wxsocket) { @@ -431,18 +439,6 @@ wxSocketImpl *wxSocketImpl::Create(wxSocketBase& wxsocket) } -/* - * Disallow further read/write operations on this socket, close - * the fd and disable all callbacks. - */ -void wxSocketImplUnix::Shutdown() -{ - /* Don't allow events to fire after socket has been closed */ - DisableEvents(); - - wxSocketImpl::Shutdown(); -} - wxSocketError wxSocketImplUnix::GetLastError() const { switch ( errno ) -- 2.45.2