Ticket #12886: gtk-socket-thread-safe-hack.patch

File gtk-socket-thread-safe-hack.patch, 2.6 KB (added by chrisstankevitz, 8 years ago)

updated patch that does not change public interface. Makes only unix NOWAIT Notify(false) calls thread-safe.

  • src/unix/sockunix.cpp

     
    9999
    100100void wxSocketImplUnix::DoEnableEvents(int flags, bool enable)
    101101{
     102    if (m_threadsafe && enable)
     103    {
     104      return;
     105    }
     106
    102107    wxSocketManager * const manager = wxSocketManager::Get();
    103108    if (!manager)
    104109        return;
     
    241246        OnStateChange(wxSOCKET_LOST);
    242247}
    243248
     249void wxSocketImplUnix::MakeThreadSafe(bool ThreadSafe)
     250{
     251    m_threadsafe = ThreadSafe;
     252
     253    if ( m_fd != INVALID_SOCKET )
     254        DoEnableEvents(wxSOCKET_INPUT_FLAG | wxSOCKET_OUTPUT_FLAG, !m_threadsafe);
     255}
     256
    244257#endif  /* wxUSE_SOCKETS */
  • src/common/socket.cpp

     
    16301630                  "wxSOCKET_NOWAIT doesn't make sense" );
    16311631
    16321632    m_flags = flags;
     1633
     1634    if (m_impl)
     1635        m_impl->MakeThreadSafe((m_flags & wxSOCKET_NOWAIT) && !m_notify);
    16331636}
    16341637
    16351638
     
    17031706void wxSocketBase::Notify(bool notify)
    17041707{
    17051708    m_notify = notify;
     1709
     1710    if (m_impl)
     1711        m_impl->MakeThreadSafe((m_flags & wxSOCKET_NOWAIT) && !m_notify);
    17061712}
    17071713
    17081714void wxSocketBase::SetNotify(wxSocketEventFlags flags)
  • include/wx/unix/private/sockunix.h

     
    3333    {
    3434        m_fds[0] =
    3535        m_fds[1] = -1;
     36
     37        m_threadsafe = false;
    3638    }
    3739
    3840    virtual wxSocketError GetLastError() const;
     
    6062    virtual void OnExceptionWaiting();
    6163    virtual bool IsOk() const { return m_fd != INVALID_SOCKET; }
    6264
     65    virtual void MakeThreadSafe(bool ThreadSafe);
     66
    6367private:
    6468    virtual void DoClose()
    6569    {
     
    9094    // with the socket
    9195    int m_fds[2];
    9296
     97    bool m_threadsafe;
     98
    9399private:
    94100    // notify the associated wxSocket about a change in socket state and shut
    95101    // down the socket if the event is wxSOCKET_LOST
  • include/wx/private/socket.h

     
    277277    // no pending connections as our sockets are non-blocking)
    278278    wxSocketImpl *Accept(wxSocketBase& wxsocket);
    279279
     280    virtual void MakeThreadSafe(bool WXUNUSED(ThreadSafe)) {}
    280281
    281282    // notifications
    282283    // -------------