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/qlocalserver_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**
     
    4444#include "qlocalsocket.h"
    4545#include "qlocalsocket_p.h"
     46
    4647
    4748#ifndef QT_NO_LOCALSERVER
     
    5354#include <qdir.h>
    5455#include <qdatetime.h>
     56
     57
     58
     59
    5560
    5661QT_BEGIN_NAMESPACE
     
    8994
    9095    // create the unix socket
    91     listenSocket = qSocket(PF_UNIX, SOCK_STREAM, 0);
     96    listenSocket = qocket(PF_UNIX, SOCK_STREAM, 0);
    9297    if (-1 == listenSocket) {
    9398        setError(QLatin1String("QLocalServer::listen"));
     
    107112             fullServerName.toLatin1().size() + 1);
    108113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
    109132    // bind
    110     if(-1 == qBind(listenSocket, (sockaddr *)&addr, sizeof(sockaddr_un))) {
     133    if(-1 == (listenSocket, (sockaddr *)&addr, sizeof(sockaddr_un))) {
    111134        setError(QLatin1String("QLocalServer::listen"));
    112135        // if address is in use already, just close the socket, but do not delete the file
     
    121144
    122145    // listen for connections
    123     if (-1 == qListen(listenSocket, 50)) {
     146    if (-1 == qisten(listenSocket, 50)) {
    124147        setError(QLatin1String("QLocalServer::listen"));
    125148        closeServer();
     
    133156                                         QSocketNotifier::Read, q);
    134157    q->connect(socketNotifier, SIGNAL(activated(int)),
    135                q, SLOT(_q_socketActivated()));
     158               q, SLOT(_q_()));
    136159    socketNotifier->setEnabled(maxPendingConnections > 0);
    137160    return true;
     
    149172    listenSocket = -1;
    150173
    151     if (socketNotifier)
     174    if (socketNotifier) {
     175        socketNotifier->setEnabled(false); // Otherwise, closed socket is checked before deleter runs
    152176        socketNotifier->deleteLater();
    153     socketNotifier = 0;
     177        socketNotifier = 0;
     178    }
    154179
    155180    if (!fullServerName.isEmpty())
     
    163188    Accept the new socket.
    164189 */
    165 void QLocalServerPrivate::_q_socketActivated()
     190void QLocalServerPrivate::_q_()
    166191{
    167192    Q_Q(QLocalServer);
     
    171196    ::sockaddr_un addr;
    172197    QT_SOCKLEN_T length = sizeof(sockaddr_un);
    173     int connectedSocket = qAccept(listenSocket, (sockaddr *)&addr, &length);
     198    int connectedSocket = qccept(listenSocket, (sockaddr *)&addr, &length);
    174199    if(-1 == connectedSocket) {
    175200        setError(QLatin1String("QLocalSocket::activated"));
     
    192217    timeout.tv_usec = (msec % 1000) * 1000;
    193218
    194     // timeout can not be 0 or else select will return an error.
    195     if (0 == msec)
    196         timeout.tv_usec = 1000;
    197 
    198219    int result = -1;
    199     // on Linux timeout will be updated by select, but _not_ on other systems.
    200     QTime timer;
    201     timer.start();
    202     while (pendingConnections.isEmpty() && (-1 == msec || timer.elapsed() < msec)) {
    203         result = ::select(listenSocket + 1, &readfds, 0, 0, &timeout);
    204         if (-1 == result && errno != EINTR) {
    205             setError(QLatin1String("QLocalServer::waitForNewConnection"));
    206             closeServer();
    207             break;
    208         }
    209         if (result > 0)
    210             _q_socketActivated();
    211     }
     220    result = qt_safe_select(listenSocket + 1, &readfds, 0, 0, (msec == -1) ? 0 : &timeout);
     221    if (-1 == result) {
     222        setError(QLatin1String("QLocalServer::waitForNewConnection"));
     223        closeServer();
     224    }
     225    if (result > 0)
     226        _q_onNewConnection();
    212227    if (timedOut)
    213228        *timedOut = (result == 0);
Note: See TracChangeset for help on using the changeset viewer.