From 61fbdc00fb03eba82309860487954d87460852a3 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 18 Jul 2013 14:42:14 +0200 Subject: Fix compilation of run-time-resolved SSL on Android We need the same code for both the no-sdk and the sdk case for the OpenSSL code, since this is not covered by a system library, but by an external dependency in both cases. Task-number: QTBUG-32130 Change-Id: I976835556fcb0e6c32cfb3da4dd585e45490061b Reviewed-by: Thiago Macieira --- src/network/ssl/qsslsocket_openssl_symbols.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/network') diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 812703b21a..d2a349455e 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -67,7 +67,7 @@ #if defined(Q_OS_UNIX) #include #endif -#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) #include #endif @@ -387,7 +387,7 @@ static bool libGreaterThan(const QString &lhs, const QString &rhs) return true; } -#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) static int dlIterateCallback(struct dl_phdr_info *info, size_t size, void *data) { if (size < sizeof (info->dlpi_addr) + sizeof (info->dlpi_name)) @@ -418,7 +418,7 @@ static QStringList libraryPathList() paths << QLatin1String("/lib64") << QLatin1String("/usr/lib64") << QLatin1String("/usr/local/lib64"); paths << QLatin1String("/lib32") << QLatin1String("/usr/lib32") << QLatin1String("/usr/local/lib32"); -#if defined(Q_OS_ANDROID_NO_SDK) +#if defined(Q_OS_ANDROID) paths << QLatin1String("/system/lib"); #elif defined(Q_OS_LINUX) // discover paths of already loaded libraries -- cgit v1.2.3 From 674e79416fefe7b5acf2a8c18d3c91d8feddcc18 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 7 Jul 2013 10:12:24 -0700 Subject: Fix incomplete override of QIODevice::open in QProcess and QLocalSocket The rule for a new override is that it must still work if the old implementation is called. The catch is that any class that derives from QProcess and isn't recompiled will still have QIODevice::open in its virtual table. That is equivalent to overriding open() and calling QIODevice::open() (like the tests). In Qt 5.0, QProcess::start() called QIODevice::open directly, not the virtual open(), so there's no expectation that a user-overridden open() be called. With that in mind, simply fix QProcess::start to not call the virtual open at all. Similarly with QLocalSocket, the calls to open were always non-virtual. Task-number: QTBUG-32284 Change-Id: I88925f0ba08bc23c849658b54582744997e69a4c Reviewed-by: Giuseppe D'Angelo --- src/network/socket/qlocalsocket.cpp | 37 +++++++++++++++++--------------- src/network/socket/qlocalsocket_tcp.cpp | 9 ++++---- src/network/socket/qlocalsocket_unix.cpp | 12 +++++------ src/network/socket/qlocalsocket_win.cpp | 9 ++++---- 4 files changed, 34 insertions(+), 33 deletions(-) (limited to 'src/network') diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index 1ce6568364..f516b932e7 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -70,6 +70,22 @@ QT_BEGIN_NAMESPACE \sa QLocalServer */ +/*! + \fn void QLocalSocket::connectToServer(OpenMode openMode) + \since 5.1 + + Attempts to make a connection to serverName(). + setServerName() must be called before you open the connection. + Alternatively you can use connectToServer(const QString &name, OpenMode openMode); + + The socket is opened in the given \a openMode and first enters ConnectingState. + If a connection is established, QLocalSocket enters ConnectedState and emits connected(). + + After calling this function, the socket can emit error() to signal that an error occurred. + + \sa state(), serverName(), waitForConnected() +*/ + /*! \fn void QLocalSocket::open(OpenMode openMode) @@ -352,23 +368,10 @@ QLocalSocket::~QLocalSocket() #endif } -/*! - \since 5.1 - - Attempts to make a connection to serverName(). - setServerName() must be called before you open the connection. - Alternatively you can use connectToServer(const QString &name, OpenMode openMode); - - The socket is opened in the given \a openMode and first enters ConnectingState. - If a connection is established, QLocalSocket enters ConnectedState and emits connected(). - - After calling this function, the socket can emit error() to signal that an error occurred. - - \sa state(), serverName(), waitForConnected() -*/ -void QLocalSocket::connectToServer(OpenMode openMode) +bool QLocalSocket::open(OpenMode openMode) { - open(openMode); + connectToServer(openMode); + return isOpen(); } /*! \overload @@ -385,7 +388,7 @@ void QLocalSocket::connectToServer(OpenMode openMode) void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) { setServerName(name); - open(openMode); + connectToServer(openMode); } /*! diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index 31aaa6e1c5..1a61a54a76 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -214,13 +214,13 @@ void QLocalSocketPrivate::errorOccurred(QLocalSocket::LocalSocketError error, co q->emit stateChanged(state); } -bool QLocalSocket::open(OpenMode openMode) +void QLocalSocket::connectToServer(OpenMode openMode) { Q_D(QLocalSocket); if (state() == ConnectedState || state() == ConnectingState) { setErrorString(tr("Trying to connect while connection is in progress")); emit error(QLocalSocket::OperationError); - return false; + return; } d->errorString.clear(); @@ -230,7 +230,7 @@ bool QLocalSocket::open(OpenMode openMode) if (d->serverName.isEmpty()) { d->errorOccurred(ServerNotFoundError, QLatin1String("QLocalSocket::connectToServer")); - return false; + return; } const QLatin1String prefix("QLocalServer/"); @@ -245,11 +245,10 @@ bool QLocalSocket::open(OpenMode openMode) if (!ok) { d->errorOccurred(ServerNotFoundError, QLatin1String("QLocalSocket::connectToServer")); - return false; + return; } d->tcpSocket->connectToHost(QHostAddress::LocalHost, port, openMode); QIODevice::open(openMode); - return true; } bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor, diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 67182e57b0..31780a27ec 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -221,14 +221,14 @@ void QLocalSocketPrivate::errorOccurred(QLocalSocket::LocalSocketError error, co q->emit stateChanged(state); } -bool QLocalSocket::open(OpenMode openMode) +void QLocalSocket::connectToServer(OpenMode openMode) { Q_D(QLocalSocket); if (state() == ConnectedState || state() == ConnectingState) { QString errorString = d->generateErrorString(QLocalSocket::OperationError, QLatin1String("QLocalSocket::connectToserver")); setErrorString(errorString); emit error(QLocalSocket::OperationError); - return false; + return; } d->errorString.clear(); @@ -239,14 +239,14 @@ bool QLocalSocket::open(OpenMode openMode) if (d->serverName.isEmpty()) { d->errorOccurred(ServerNotFoundError, QLatin1String("QLocalSocket::connectToServer")); - return false; + return; } // create the socket if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0))) { d->errorOccurred(UnsupportedSocketOperationError, QLatin1String("QLocalSocket::connectToServer")); - return false; + return; } // set non blocking so we can try to connect and it won't wait int flags = fcntl(d->connectingSocket, F_GETFL, 0); @@ -254,14 +254,14 @@ bool QLocalSocket::open(OpenMode openMode) || -1 == (fcntl(d->connectingSocket, F_SETFL, flags | O_NONBLOCK))) { d->errorOccurred(UnknownSocketError, QLatin1String("QLocalSocket::connectToServer")); - return false; + return; } // _q_connectToSocket does the actual connecting d->connectingName = d->serverName; d->connectingOpenMode = openMode; d->_q_connectToSocket(); - return true; + return; } /*! diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index cdfa18377d..c907ce6ada 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -128,13 +128,13 @@ void QLocalSocketPrivate::destroyPipeHandles() } } -bool QLocalSocket::open(OpenMode openMode) +void QLocalSocket::connectToServer(OpenMode openMode) { Q_D(QLocalSocket); if (state() == ConnectedState || state() == ConnectingState) { setErrorString(tr("Trying to connect while connection is in progress")); emit error(QLocalSocket::OperationError); - return false; + return; } d->error = QLocalSocket::UnknownSocketError; @@ -147,7 +147,7 @@ bool QLocalSocket::open(OpenMode openMode) d->state = UnconnectedState; emit error(d->error); emit stateChanged(d->state); - return false; + return; } QString pipePath = QLatin1String("\\\\.\\pipe\\"); @@ -184,7 +184,7 @@ bool QLocalSocket::open(OpenMode openMode) if (localSocket == INVALID_HANDLE_VALUE) { d->setErrorString(QLatin1String("QLocalSocket::connectToServer")); d->fullServerName = QString(); - return false; + return; } // we have a valid handle @@ -192,7 +192,6 @@ bool QLocalSocket::open(OpenMode openMode) d->handle = localSocket; emit connected(); } - return true; } // This is reading from the buffer -- cgit v1.2.3 From bfc5bb09c4b79c17e1d846f6c46611d83cc7de4a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 7 Jul 2013 16:00:43 -0700 Subject: Ignore or suppress warning and debug messages in tst_QLocalSocket The one in tst_QLocalSocket::writeToClientAndDisconnect just needed proper ordering: that's what waitForDisconnect is for. At the same time, we need to make sure we get the same message from all three implementations of QLocalSocket::waitForDisconnect (and without the useless space at the end). Change-Id: I21364263cf908df022df814a6a39fcb5783e84e6 Reviewed-by: Shane Kearns --- src/network/socket/qlocalsocket_tcp.cpp | 2 +- src/network/socket/qlocalsocket_unix.cpp | 2 +- src/network/socket/qlocalsocket_win.cpp | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/network') diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index 1a61a54a76..0bf0cc0654 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -424,7 +424,7 @@ bool QLocalSocket::waitForDisconnected(int msecs) { Q_D(QLocalSocket); if (state() == UnconnectedState) { - qWarning() << "QLocalSocket::waitForDisconnected() is not allowed in UnconnectedState"; + qWarning("QLocalSocket::waitForDisconnected() is not allowed in UnconnectedState"); return false; } return (d->tcpSocket->waitForDisconnected(msecs)); diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 31780a27ec..4af584b345 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -560,7 +560,7 @@ bool QLocalSocket::waitForDisconnected(int msecs) { Q_D(QLocalSocket); if (state() == UnconnectedState) { - qWarning() << "QLocalSocket::waitForDisconnected() is not allowed in UnconnectedState"; + qWarning("QLocalSocket::waitForDisconnected() is not allowed in UnconnectedState"); return false; } return (d->unixSocket.waitForDisconnected(msecs)); diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index c907ce6ada..96c6c0f6ea 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -378,8 +378,10 @@ bool QLocalSocket::waitForConnected(int msecs) bool QLocalSocket::waitForDisconnected(int msecs) { Q_D(QLocalSocket); - if (state() == UnconnectedState) + if (state() == UnconnectedState) { + qWarning("QLocalSocket::waitForDisconnected() is not allowed in UnconnectedState"); return false; + } if (!openMode().testFlag(QIODevice::ReadOnly)) { qWarning("QLocalSocket::waitForDisconnected isn't supported for write only pipes."); return false; -- cgit v1.2.3