~ubuntu-branches/ubuntu/saucy/filezilla/saucy-proposed

« back to all changes in this revision

Viewing changes to src/engine/socket.cpp

  • Committer: Package Import Robot
  • Author(s): Adrien Cunin
  • Date: 2012-12-07 17:17:17 UTC
  • mfrom: (1.1.31)
  • Revision ID: package-import@ubuntu.com-20121207171717-nt6as62u4pa1uv11
Tags: 3.6.0.2-1ubuntu1
* Merge from Debian experimental. Remaining Ubuntu change:
   - Added debian/patches/11_use-decimal-si-by-default.patch in order to
     comply with UnitsPolicy

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
// Apparently it is too hard for the richest company in the
54
54
// world to add this simple function with a service pack...
55
55
 
56
 
extern "C" 
 
56
extern "C"
57
57
{
58
58
        typedef int (WINAPI *t_getaddrinfo)(const char *nodename, const char *servname,
59
59
                                                const struct addrinfo *hints, struct addrinfo **res);
445
445
        {
446
446
                if (!already_locked)
447
447
                        m_sync.Lock();
448
 
                        
 
448
 
449
449
                if (!m_started || m_finished)
450
450
                {
451
451
                        if (!already_locked)
503
503
 
504
504
                        return 0;
505
505
                }
506
 
                
 
506
 
507
507
#if defined(SO_NOSIGPIPE) && !defined(MSG_NOSIGNAL)
508
508
                // We do not want SIGPIPE if writing to socket.
509
509
                const int value = 1;
759
759
        {
760
760
                m_waiting |= wait;
761
761
 
762
 
                while (true)
 
762
                for (;;)
763
763
                {
764
764
#ifdef __WXMSW__
765
765
                        int wait_events = FD_CLOSE;
859
859
                        int res = select(max, &readfds, &writefds, 0, 0);
860
860
 
861
861
                        m_sync.Lock();
862
 
                        
 
862
 
863
863
                        if (res > 0 && FD_ISSET(m_pipe[0], &readfds))
864
864
                        {
865
865
                                char buffer[100];
937
937
                        return;
938
938
                if (m_triggered & WAIT_READ)
939
939
                {
 
940
                        if (m_pSocket->m_synchronous_read_cb)
 
941
                                m_pSocket->m_synchronous_read_cb->cb();
940
942
                        CSocketEvent *evt = new CSocketEvent(m_pSocket->m_pEvtHandler, m_pSocket, CSocketEvent::read, m_triggered_errors[1]);
941
943
                        CSocketEventDispatcher::Get().SendEvent(evt);
942
944
                        m_triggered &= ~WAIT_READ;
981
983
        virtual ExitCode Entry()
982
984
        {
983
985
                m_sync.Lock();
984
 
                while (true)
 
986
                for (;;)
985
987
                {
986
988
                        if (!IdleLoop())
987
989
                        {
1077
1079
 
1078
1080
        // Thread waits for instructions
1079
1081
        bool m_threadwait;
 
1082
 
 
1083
        CCallback* m_synchronous_read_cb;
1080
1084
};
1081
1085
 
1082
1086
CSocket::CSocket(CSocketEventHandler* pEvtHandler)
1083
1087
        : m_pEvtHandler(pEvtHandler)
 
1088
        , m_synchronous_read_cb()
1084
1089
{
1085
1090
#ifdef ERRORCODETEST
1086
1091
        CErrorCodeTest test;
1793
1798
 
1794
1799
int CSocket::GetRemotePort(int& error)
1795
1800
{
1796
 
        sockaddr_u addr;                
 
1801
        sockaddr_u addr;
1797
1802
        socklen_t addr_len = sizeof(addr);
1798
1803
        error = getpeername(m_fd, &addr.sockaddr, &addr_len);
1799
1804
        if (error)
1832
1837
#endif
1833
1838
                return 0;
1834
1839
        }
1835
 
        
 
1840
 
1836
1841
#if defined(SO_NOSIGPIPE) && !defined(MSG_NOSIGNAL)
1837
1842
        // We do not want SIGPIPE if writing to socket.
1838
1843
        const int value = 1;
1957
1962
 
1958
1963
        return 0;
1959
1964
}
 
1965
 
 
1966
void CSocket::SetSynchronousReadCallback(CCallback* cb)
 
1967
{
 
1968
        if (m_pSocketThread)
 
1969
                m_pSocketThread->m_sync.Lock();
 
1970
 
 
1971
        m_synchronous_read_cb = cb;
 
1972
 
 
1973
        if (m_pSocketThread)
 
1974
                m_pSocketThread->m_sync.Unlock();
 
1975
}