Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/network/socket/qnativesocketengine_unix.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the QtNetwork module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4141
    4242//#define QNATIVESOCKETENGINE_DEBUG
    43 
    4443#include "qnativesocketengine_p.h"
     44
    4545#include "qiodevice.h"
    4646#include "qhostaddress.h"
     
    6363#include <qstring.h>
    6464#include <ctype.h>
     65
     66
     67
     68
     69
     70
     71
    6572#endif
    6673
     
    101108static void qt_ignore_sigpipe()
    102109{
     110
    103111    // Set to ignore SIGPIPE once only.
    104112    static QBasicAtomicInt atom = Q_BASIC_ATOMIC_INITIALIZER(0);
     
    109117        ::sigaction(SIGPIPE, &noaction, 0);
    110118    }
     119
     120
     121
     122
    111123}
    112124
     
    115127    \a port and \a addr if they are non-null.
    116128*/
    117 static inline void qt_socket_getPortAndAddress(struct sockaddr *sa, quint16 *port, QHostAddress *addr)
     129static inline void qt_socket_getPortAndAddress(, quint16 *port, QHostAddress *addr)
    118130{
    119131#if !defined(QT_NO_IPV6)
    120     if (sa->sa_family == AF_INET6) {
    121         struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa;
     132    if (s->a.sa_family == AF_INET6) {
    122133        Q_IPV6ADDR tmp;
    123         memcpy(&tmp, &sa6->sin6_addr.s6_addr, sizeof(tmp));
     134        memcpy(&tmp, &s6_addr, sizeof(tmp));
    124135        if (addr) {
    125136            QHostAddress tmpAddress;
     
    128139#ifndef QT_NO_IPV6IFNAME
    129140            char scopeid[IFNAMSIZ];
    130             if (::if_indextoname(sa6->sin6_scope_id, scopeid) > 0) {
     141            if (::if_indextoname(s) {
    131142                addr->setScopeId(QLatin1String(scopeid));
    132143            } else
    133144#endif
    134             addr->setScopeId(QString::number(sa6->sin6_scope_id));
     145            addr->setScopeId(QString::number(ssin6_scope_id));
    135146        }
    136147        if (port)
    137             *port = ntohs(sa6->sin6_port);
     148            *port = ntohs(ssin6_port);
    138149        return;
    139150    }
    140151#endif
    141     struct sockaddr_in *sa4 = (struct sockaddr_in *)sa;
    142152    if (port)
    143         *port = ntohs(sa4->sin_port);
     153        *port = ntohs(ssin_port);
    144154    if (addr) {
    145155        QHostAddress tmpAddress;
    146         tmpAddress.setAddress(ntohl(sa4->sin_addr.s_addr));
     156        tmpAddress.setAddress(ntohl(ssin_addr.s_addr));
    147157        *addr = tmpAddress;
    148158    }
     
    164174#endif
    165175    int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM;
    166     int socket = qt_socket_socket(protocol, type, 0);
     176#ifdef Q_OS_SYMBIAN
     177    int socket = ::socket(protocol, type, 0);
     178#else
     179        int socket = qt_safe_socket(protocol, type, 0);
     180#endif
    167181
    168182    if (socket <= 0) {
     
    191205    // Ensure that the socket is closed on exec*().
    192206    ::fcntl(socket, F_SETFD, FD_CLOEXEC);
     207
    193208    socketDescriptor = socket;
    194209    return true;
     
    205220
    206221    int n = -1;
     222
     223
    207224    switch (opt) {
    208225    case QNativeSocketEngine::ReceiveBufferSocketOption:
     
    224241        n = SO_OOBINLINE;
    225242        break;
     243
     244
     245
     246
     247
     248
     249
    226250    }
    227251
    228252    int v = -1;
    229253    QT_SOCKOPTLEN_T len = sizeof(v);
    230     if (getsockopt(socketDescriptor, SOL_SOCKET, n, (char *) &v, &len) != -1)
     254    if (, n, (char *) &v, &len) != -1)
    231255        return v;
     256
    232257    return -1;
    233258}
     
    244269
    245270    int n = 0;
     271
     272
    246273    switch (opt) {
    247274    case QNativeSocketEngine::ReceiveBufferSocketOption:
     
    256283    case QNativeSocketEngine::NonBlockingSocketOption: {
    257284        // Make the socket nonblocking.
     285
    258286        int flags = ::fcntl(socketDescriptor, F_GETFL, 0);
    259287        if (flags == -1) {
     
    269297            return false;
    270298        }
    271 
     299#else // Q_OS_VXWORKS
     300        int onoff = 1;
     301#ifdef Q_OS_SYMBIAN
     302        if (::ioctl(socketDescriptor, FIONBIO, &onoff) < 0) {
     303#else
     304        if (qt_safe_ioctl(socketDescriptor, FIONBIO, &onoff) < 0) {
     305#endif
     306#ifdef QNATIVESOCKETENGINE_DEBUG
     307            perror("QNativeSocketEnginePrivate::setOption(): ioctl(FIONBIO, 1) failed");
     308#endif
     309            return false;
     310        }
     311#endif // Q_OS_VXWORKS
    272312        return true;
    273313    }
    274314    case QNativeSocketEngine::AddressReusable:
    275 #ifdef SO_REUSEPORT
     315#if
    276316        n = SO_REUSEPORT;
    277317#else
     
    284324        n = SO_OOBINLINE;
    285325        break;
    286     }
    287 
    288     return ::setsockopt(socketDescriptor, SOL_SOCKET, n, (char *) &v, sizeof(v)) == 0;
     326    case QNativeSocketEngine::LowDelayOption:
     327        level = IPPROTO_TCP;
     328        n = TCP_NODELAY;
     329        break;
     330    case QNativeSocketEngine::KeepAliveOption:
     331        n = SO_KEEPALIVE;
     332        break;
     333    }
     334
     335    return ::setsockopt(socketDescriptor, level, n, (char *) &v, sizeof(v)) == 0;
    289336}
    290337
    291338bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16 port)
    292339{
     340
     341
     342
     343
    293344    struct sockaddr_in sockAddrIPv4;
    294345    struct sockaddr *sockAddrPtr = 0;
     
    328379        // unreachable
    329380    }
    330 
    331     int connectResult = QT_SOCKET_CONNECT(socketDescriptor, sockAddrPtr, sockAddrSize);
     381#ifdef Q_OS_SYMBIAN
     382    int connectResult = ::connect(socketDescriptor, sockAddrPtr, sockAddrSize);
     383#else
     384    int connectResult = qt_safe_connect(socketDescriptor, sockAddrPtr, sockAddrSize);
     385#endif
    332386    if (connectResult == -1) {
    333387        switch (errno) {
     
    433487
    434488    int bindResult = QT_SOCKET_BIND(socketDescriptor, sockAddrPtr, sockAddrSize);
     489
    435490    if (bindResult < 0) {
    436491        switch(errno) {
     
    469524bool QNativeSocketEnginePrivate::nativeListen(int backlog)
    470525{
    471     if (qt_socket_listen(socketDescriptor, backlog) < 0) {
     526#ifdef Q_OS_SYMBIAN
     527    if (::listen(socketDescriptor, backlog) < 0) {
     528#else
     529    if (qt_safe_listen(socketDescriptor, backlog) < 0) {
     530#endif
    472531        switch (errno) {
    473532        case EADDRINUSE:
     
    496555int QNativeSocketEnginePrivate::nativeAccept()
    497556{
    498     int acceptedDescriptor = qt_socket_accept(socketDescriptor, 0, 0);
    499 #if defined (QNATIVESOCKETENGINE_DEBUG)
    500     qDebug("QNativeSocketEnginePrivate::nativeAccept() == %i", acceptedDescriptor);
    501 #endif
    502     // Ensure that the socket is closed on exec*()
    503     ::fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC);
     557#ifdef Q_OS_SYMBIAN
     558    int acceptedDescriptor = ::accept(socketDescriptor, 0, 0);
     559#else
     560    int acceptedDescriptor = qt_safe_accept(socketDescriptor, 0, 0);
     561#endif
     562    //check if we have vaild descriptor at all
     563    if(acceptedDescriptor > 0) {
     564        // Ensure that the socket is closed on exec*()
     565        ::fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC);
     566    }
     567#ifdef Q_OS_SYMBIAN
     568    else {
     569        qWarning("QNativeSocketEnginePrivate::nativeAccept() - acceptedDescriptor <= 0");
     570    }
     571#endif
     572
    504573    return acceptedDescriptor;
    505574}
     
    507576qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const
    508577{
    509     /*
    510       Apparently, there is not consistency among different operating
    511       systems on how to use FIONREAD.
    512 
    513       FreeBSD, Linux and Solaris all expect the 3rd argument to
    514       ioctl() to be an int, which is normally 32-bit even on 64-bit
    515       machines.
    516 
    517       IRIX, on the other hand, expects a size_t, which is 64-bit on
    518       64-bit machines.
    519 
    520       So, the solution is to use size_t initialized to zero to make
    521       sure all bits are set to zero, preventing underflow with the
    522       FreeBSD/Linux/Solaris ioctls.
    523     */
    524     size_t nbytes = 0;
     578    int nbytes = 0;
    525579    // gives shorter than true amounts on Unix domain sockets.
    526580    qint64 available = 0;
    527     if (::ioctl(socketDescriptor, FIONREAD, (char *) &nbytes) >= 0)
    528         available = (qint64) *((int *) &nbytes);
     581#ifdef Q_OS_SYMBIAN
     582        if (::ioctl(socketDescriptor, FIONREAD, (char *) &nbytes) >= 0)
     583#else
     584    if (qt_safe_ioctl(socketDescriptor, FIONREAD, (char *) &nbytes) >= 0)
     585#endif
     586        available = (qint64) nbytes;
    529587
    530588#if defined (QNATIVESOCKETENGINE_DEBUG)
     
    537595{
    538596    // Create a sockaddr struct and reset its port number.
    539 #if !defined(QT_NO_IPV6)
    540     struct sockaddr_storage storage;
    541     sockaddr_in6 *storagePtrIPv6 = reinterpret_cast<sockaddr_in6 *>(&storage);
    542     storagePtrIPv6->sin6_port = 0;
    543 #else
    544     struct sockaddr storage;
    545 #endif
    546     sockaddr *storagePtr = reinterpret_cast<sockaddr *>(&storage);
    547     storagePtr->sa_family = 0;
    548 
    549     sockaddr_in *storagePtrIPv4 = reinterpret_cast<sockaddr_in *>(&storage);
    550     storagePtrIPv4->sin_port = 0;
     597    qt_sockaddr storage;
    551598    QT_SOCKLEN_T storageSize = sizeof(storage);
     599
    552600
    553601    // Peek 0 bytes into the next message. The size of the message may
     
    556604    do {
    557605        char c;
    558         readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, storagePtr, &storageSize);
     606        readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, , &storageSize);
    559607    } while (readBytes == -1 && errno == EINTR);
    560608
     
    570618}
    571619
     620
     621
     622
     623
     624
     625
     626
     627
    572628qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
    573629{
    574630    QVarLengthArray<char, 8192> udpMessagePeekBuffer(8192);
    575631    ssize_t recvResult = -1;
     632
    576633    for (;;) {
    577634        // the data written to udpMessagePeekBuffer is discarded, so
     
    579636        // so.
    580637        recvResult = ::recv(socketDescriptor, udpMessagePeekBuffer.data(),
    581                             udpMessagePeekBuffer.size(), MSG_PEEK);
     638            udpMessagePeekBuffer.size(), MSG_PEEK);
    582639        if (recvResult == -1 && errno == EINTR)
    583640            continue;
     
    595652    return qint64(recvResult);
    596653}
    597 
     654#endif
    598655qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxSize,
    599656                                                    QHostAddress *address, quint16 *port)
    600657{
    601 #if !defined(QT_NO_IPV6)
    602     struct sockaddr_storage aa;
    603 #else
    604     struct sockaddr_in aa;
    605 #endif
     658    qt_sockaddr aa;
    606659    memset(&aa, 0, sizeof(aa));
    607660    QT_SOCKLEN_T sz;
     
    612665        char c;
    613666        recvFromResult = ::recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1,
    614                                     0, (struct sockaddr *)&aa, &sz);
     667                                    0, a, &sz);
    615668    } while (recvFromResult == -1 && errno == EINTR);
    616669
     
    618671        setError(QAbstractSocket::NetworkError, ReceiveDatagramErrorString);
    619672    } else if (port || address) {
    620         qt_socket_getPortAndAddress((struct sockaddr *) &aa, port, address);
     673        qt_socket_getPortAndAddress(&aa, port, address);
    621674    }
    622675
     
    641694    struct sockaddr_in6 sockAddrIPv6;
    642695    if (host.protocol() == QAbstractSocket::IPv6Protocol) {
    643         memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
    644         sockAddrIPv6.sin6_family = AF_INET6;
    645         sockAddrIPv6.sin6_port = htons(port);
    646 
    647         Q_IPV6ADDR tmp = host.toIPv6Address();
    648         memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &tmp, sizeof(tmp));
    649         sockAddrSize = sizeof(sockAddrIPv6);
    650         sockAddrPtr = (struct sockaddr *)&sockAddrIPv6;
     696memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
     697sockAddrIPv6.sin6_family = AF_INET6;
     698sockAddrIPv6.sin6_port = htons(port);
     699
     700Q_IPV6ADDR tmp = host.toIPv6Address();
     701memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &tmp, sizeof(tmp));
     702sockAddrSize = sizeof(sockAddrIPv6);
     703sockAddrPtr = (struct sockaddr *)&sockAddrIPv6;
    651704    } else
    652705#endif
    653706    if (host.protocol() == QAbstractSocket::IPv4Protocol) {
    654         memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
    655         sockAddrIPv4.sin_family = AF_INET;
    656         sockAddrIPv4.sin_port = htons(port);
    657         sockAddrIPv4.sin_addr.s_addr = htonl(host.toIPv4Address());
    658         sockAddrSize = sizeof(sockAddrIPv4);
    659         sockAddrPtr = (struct sockaddr *)&sockAddrIPv4;
     707memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
     708sockAddrIPv4.sin_family = AF_INET;
     709sockAddrIPv4.sin_port = htons(port);
     710sockAddrIPv4.sin_addr.s_addr = htonl(host.toIPv4Address());
     711sockAddrSize = sizeof(sockAddrIPv4);
     712sockAddrPtr = (struct sockaddr *)&sockAddrIPv4;
    660713    }
    661714
    662715    // ignore the SIGPIPE signal
    663716    qt_ignore_sigpipe();
    664 
    665     ssize_t sentBytes;
    666     do {
    667         sentBytes = ::sendto(socketDescriptor, data, len,
    668                              0, sockAddrPtr, sockAddrSize);
    669     } while (sentBytes == -1 && errno == EINTR);
     717#ifdef Q_OS_SYMBIAN
     718    ssize_t sentBytes = ::sendto(socketDescriptor, data, len,
     719                                       0, sockAddrPtr, sockAddrSize);
     720#else
     721    ssize_t sentBytes = qt_safe_sendto(socketDescriptor, data, len,
     722                                       0, sockAddrPtr, sockAddrSize);
     723#endif
    670724
    671725    if (sentBytes < 0) {
     
    698752        return false;
    699753
    700 #if !defined(QT_NO_IPV6)
    701     struct sockaddr_storage sa;
    702 #else
    703     struct sockaddr_in sa;
    704 #endif
    705     struct sockaddr *sockAddrPtr = (struct sockaddr *) &sa;
     754    qt_sockaddr sa;
    706755    QT_SOCKLEN_T sockAddrSize = sizeof(sa);
    707756
    708757    // Determine local address
    709758    memset(&sa, 0, sizeof(sa));
    710     if (::getsockname(socketDescriptor, sockAddrPtr, &sockAddrSize) == 0) {
    711         qt_socket_getPortAndAddress(sockAddrPtr, &localPort, &localAddress);
     759    if (::getsockname(socketDescriptor, , &sockAddrSize) == 0) {
     760        qt_socket_getPortAndAddress(, &localPort, &localAddress);
    712761
    713762        // Determine protocol family
    714         switch (sockAddrPtr->sa_family) {
     763        switch (ssa_family) {
    715764        case AF_INET:
    716765            socketProtocol = QAbstractSocket::IPv4Protocol;
     
    732781
    733782    // Determine the remote address
    734     if (!::getpeername(socketDescriptor, sockAddrPtr, &sockAddrSize))
    735         qt_socket_getPortAndAddress(sockAddrPtr, &peerPort, &peerAddress);
     783    if (!::getpeername(socketDescriptor, , &sockAddrSize))
     784        qt_socket_getPortAndAddress(, &peerPort, &peerAddress);
    736785
    737786    // Determine the socket type (UDP/TCP)
     
    769818    qDebug("QNativeSocketEngine::nativeClose()");
    770819#endif
     820
     821
    771822    ::close(socketDescriptor);
     823
     824
     825
    772826}
    773827
     
    783837    ssize_t writtenBytes;
    784838    do {
    785         writtenBytes = ::write(socketDescriptor, data, len);
     839#ifdef Q_OS_SYMBIAN
     840            writtenBytes = ::write(socketDescriptor, data, len);
     841#else
     842        writtenBytes = qt_safe_write(socketDescriptor, data, len);
     843#endif
     844        // writtenBytes = QT_WRITE(socketDescriptor, data, len); ### TODO S60: Should this line be removed or the one above it?
    786845    } while (writtenBytes < 0 && errno == EINTR);
    787846
     
    825884    ssize_t r = 0;
    826885    do {
     886
    827887        r = ::read(socketDescriptor, data, maxSize);
     888
     889
     890
    828891    } while (r == -1 && errno == EINTR);
    829892
     
    843906            setError(QAbstractSocket::NetworkError, ReadErrorString);
    844907            break;
     908
     909
     910
    845911        case ECONNRESET:
     912
     913
     914
    846915            r = 0;
    847916            break;
     
    870939    tv.tv_usec = (timeout % 1000) * 1000;
    871940
    872     QTime timer;
    873     timer.start();
     941#ifdef Q_OS_SYMBIAN
     942    fd_set fdexception;
     943    FD_ZERO(&fdexception);
     944    FD_SET(socketDescriptor, &fdexception);
     945#endif
    874946
    875947    int retval;
    876     do {
    877         if (selectForRead)
    878             retval = select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
    879         else
    880             retval = select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv);
    881 
    882         if (retval != -1 || errno != EINTR)
    883             break;
    884 
    885         if (timeout > 0) {
    886             // recalculate the timeout
    887             int t = timeout - timer.elapsed();
    888             if (t < 0) {
    889                 // oops, timeout turned negative?
    890                 retval = -1;
    891                 break;
     948    if (selectForRead)
     949#ifdef Q_OS_SYMBIAN
     950        retval = ::select(socketDescriptor + 1, &fds, 0, &fdexception, timeout < 0 ? 0 : &tv);
     951#else
     952        retval = qt_safe_select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
     953#endif
     954    else
     955#ifdef Q_OS_SYMBIAN
     956        retval = ::select(socketDescriptor + 1, 0, &fds, &fdexception, timeout < 0 ? 0 : &tv);
     957#else
     958        retval = qt_safe_select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv);
     959#endif
     960
     961
     962#ifdef Q_OS_SYMBIAN
     963        bool selectForExec = false;
     964        if(retval != 0) {
     965            if(retval < 0) {
     966                qWarning("nativeSelect(....) returned < 0 for socket %d", socketDescriptor);
    892967            }
    893 
    894             tv.tv_sec = t / 1000;
    895             tv.tv_usec = (t % 1000) * 1000;
    896         }
    897     } while (true);
     968            selectForExec = FD_ISSET(socketDescriptor, &fdexception);
     969        }
     970        if(selectForExec) {
     971            qWarning("nativeSelect (selectForRead %d, retVal %d, errno %d) Unexpected exception for fd %d",
     972                    selectForRead, retval, errno, socketDescriptor);
     973            }
     974#endif
    898975
    899976    return retval;
     
    901978
    902979int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool checkWrite,
    903                                       bool *selectForRead, bool *selectForWrite) const
     980      bool *selectForRead, bool *selectForWrite) const
    904981{
    905982    fd_set fdread;
     
    913990        FD_SET(socketDescriptor, &fdwrite);
    914991
     992
     993
     994
     995
     996
     997
    915998    struct timeval tv;
    916999    tv.tv_sec = timeout / 1000;
    9171000    tv.tv_usec = (timeout % 1000) * 1000;
    9181001
     1002
     1003
     1004
     1005
    9191006    QTime timer;
    9201007    timer.start();
    9211008
    922     int ret;
    9231009    do {
    924         ret = select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv);
    925         if (ret != -1 || errno != EINTR)
    926             break;
     1010        ret = ::select(socketDescriptor + 1, &fdread, &fdwrite, &fdexception, timeout < 0 ? 0 : &tv);
     1011        bool selectForExec = false;
     1012        if(ret != 0) {
     1013            if(ret < 0) {
     1014                qWarning("nativeSelect(....) returned < 0 for socket %d", socketDescriptor);
     1015            }
     1016            selectForExec = FD_ISSET(socketDescriptor, &fdexception);
     1017        }
     1018        if(selectForExec) {
     1019            qWarning("nativeSelect (checkRead %d, checkWrite %d, ret %d, errno %d): Unexpected expectfds ready in fd %d",
     1020                    checkRead, checkWrite, ret, errno, socketDescriptor);
     1021            if (checkWrite){
     1022                FD_CLR(socketDescriptor, &fdread);
     1023                FD_SET(socketDescriptor, &fdwrite);
     1024            } else if (checkRead)
     1025                FD_SET(socketDescriptor, &fdread);
     1026
     1027
     1028            if ((ret == -1) && ( errno == ECONNREFUSED || errno == EPIPE ))
     1029                ret = 1;
     1030
     1031        }
     1032
     1033        if (ret != -1 || errno != EINTR) {
     1034            break;
     1035        }
    9271036
    9281037        if (timeout > 0) {
     
    9391048        }
    9401049    } while (true);
     1050
     1051
    9411052    if (ret <= 0)
    9421053        return ret;
    943 
    9441054    *selectForRead = FD_ISSET(socketDescriptor, &fdread);
    9451055    *selectForWrite = FD_ISSET(socketDescriptor, &fdwrite);
     1056
    9461057    return ret;
    9471058}
Note: See TracChangeset for help on using the changeset viewer.