summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qlocalserver_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket/qlocalserver_win.cpp')
-rw-r--r--src/network/socket/qlocalserver_win.cpp79
1 files changed, 21 insertions, 58 deletions
diff --git a/src/network/socket/qlocalserver_win.cpp b/src/network/socket/qlocalserver_win.cpp
index 6d92ebe93a..bc761b1e8f 100644
--- a/src/network/socket/qlocalserver_win.cpp
+++ b/src/network/socket/qlocalserver_win.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qlocalserver.h"
#include "qlocalserver_p.h"
@@ -53,11 +17,10 @@
// before it is read. Pipewriter is used for write buffering.
#define BUFSIZE 0
-// ###: This should be a property. Should replace the insane 50 on unix as well.
-#define SYSTEM_MAX_PENDING_SOCKETS 8
-
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
bool QLocalServerPrivate::addListener()
{
// The object must not change its address once the
@@ -77,10 +40,10 @@ bool QLocalServerPrivate::addListener()
QByteArray tokenGroupBuffer;
// create security descriptor if access options were specified
- if ((socketOptions & QLocalServer::WorldAccessOption)) {
+ if ((socketOptions.value() & QLocalServer::WorldAccessOption)) {
pSD.reset(new SECURITY_DESCRIPTOR);
if (!InitializeSecurityDescriptor(pSD.data(), SECURITY_DESCRIPTOR_REVISION)) {
- setError(QLatin1String("QLocalServerPrivate::addListener"));
+ setError("QLocalServerPrivate::addListener"_L1);
return false;
}
HANDLE hToken = NULL;
@@ -91,7 +54,7 @@ bool QLocalServerPrivate::addListener()
tokenUserBuffer.fill(0, dwBufferSize);
auto pTokenUser = reinterpret_cast<PTOKEN_USER>(tokenUserBuffer.data());
if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwBufferSize, &dwBufferSize)) {
- setError(QLatin1String("QLocalServerPrivate::addListener"));
+ setError("QLocalServerPrivate::addListener"_L1);
CloseHandle(hToken);
return false;
}
@@ -101,7 +64,7 @@ bool QLocalServerPrivate::addListener()
tokenGroupBuffer.fill(0, dwBufferSize);
auto pTokenGroup = reinterpret_cast<PTOKEN_PRIMARY_GROUP>(tokenGroupBuffer.data());
if (!GetTokenInformation(hToken, TokenPrimaryGroup, pTokenGroup, dwBufferSize, &dwBufferSize)) {
- setError(QLatin1String("QLocalServerPrivate::addListener"));
+ setError("QLocalServerPrivate::addListener"_L1);
CloseHandle(hToken);
return false;
}
@@ -128,7 +91,7 @@ bool QLocalServerPrivate::addListener()
if (!AllocateAndInitializeSid(&WorldAuth, 1, SECURITY_WORLD_RID,
0, 0, 0, 0, 0, 0, 0,
&worldSID)) {
- setError(QLatin1String("QLocalServerPrivate::addListener"));
+ setError("QLocalServerPrivate::addListener"_L1);
return false;
}
@@ -143,23 +106,23 @@ bool QLocalServerPrivate::addListener()
auto acl = reinterpret_cast<PACL>(aclBuffer.data());
InitializeAcl(acl, aclSize, ACL_REVISION_DS);
- if (socketOptions & QLocalServer::UserAccessOption) {
+ if (socketOptions.value() & QLocalServer::UserAccessOption) {
if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, pTokenUser->User.Sid)) {
- setError(QLatin1String("QLocalServerPrivate::addListener"));
+ setError("QLocalServerPrivate::addListener"_L1);
FreeSid(worldSID);
return false;
}
}
- if (socketOptions & QLocalServer::GroupAccessOption) {
+ if (socketOptions.value() & QLocalServer::GroupAccessOption) {
if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, pTokenGroup->PrimaryGroup)) {
- setError(QLatin1String("QLocalServerPrivate::addListener"));
+ setError("QLocalServerPrivate::addListener"_L1);
FreeSid(worldSID);
return false;
}
}
- if (socketOptions & QLocalServer::OtherAccessOption) {
+ if (socketOptions.value() & QLocalServer::OtherAccessOption) {
if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, worldSID)) {
- setError(QLatin1String("QLocalServerPrivate::addListener"));
+ setError("QLocalServerPrivate::addListener"_L1);
FreeSid(worldSID);
return false;
}
@@ -167,7 +130,7 @@ bool QLocalServerPrivate::addListener()
SetSecurityDescriptorOwner(pSD.data(), pTokenUser->User.Sid, FALSE);
SetSecurityDescriptorGroup(pSD.data(), pTokenGroup->PrimaryGroup, FALSE);
if (!SetSecurityDescriptorDacl(pSD.data(), TRUE, acl, FALSE)) {
- setError(QLatin1String("QLocalServerPrivate::addListener"));
+ setError("QLocalServerPrivate::addListener"_L1);
FreeSid(worldSID);
return false;
}
@@ -188,7 +151,7 @@ bool QLocalServerPrivate::addListener()
&sa);
if (listener->handle == INVALID_HANDLE_VALUE) {
- setError(QLatin1String("QLocalServerPrivate::addListener"));
+ setError("QLocalServerPrivate::addListener"_L1);
listeners.pop_back();
return false;
}
@@ -211,7 +174,7 @@ bool QLocalServerPrivate::addListener()
break;
default:
CloseHandle(listener->handle);
- setError(QLatin1String("QLocalServerPrivate::addListener"));
+ setError("QLocalServerPrivate::addListener"_L1);
listeners.pop_back();
return false;
}
@@ -243,7 +206,7 @@ bool QLocalServerPrivate::listen(const QString &name)
{
Q_Q(QLocalServer);
- const QLatin1String pipePath("\\\\.\\pipe\\");
+ const auto pipePath = "\\\\.\\pipe\\"_L1;
if (name.startsWith(pipePath))
fullServerName = name;
else
@@ -256,7 +219,7 @@ bool QLocalServerPrivate::listen(const QString &name)
connectionEventNotifier = new QWinEventNotifier(eventHandle , q);
q->connect(connectionEventNotifier, SIGNAL(activated(HANDLE)), q, SLOT(_q_onNewConnection()));
- for (int i = 0; i < SYSTEM_MAX_PENDING_SOCKETS; ++i)
+ for (int i = 0; i < listenBacklog; ++i)
if (!addListener())
return false;
@@ -303,7 +266,7 @@ void QLocalServerPrivate::_q_onNewConnection()
} else {
if (GetLastError() != ERROR_IO_INCOMPLETE) {
q->close();
- setError(QLatin1String("QLocalServerPrivate::_q_onNewConnection"));
+ setError("QLocalServerPrivate::_q_onNewConnection"_L1);
return;
}