Commit Graph

61575 Commits

Author SHA1 Message Date
Antti Määttä
8a45faba36 Tracepointgen: Fix reading enums from multiple files
Don't stop searching enums if the enum partially matches.

Pick-to: 6.5
Change-Id: Idc2b45cee5a32994d55fe90c038938f0ad8b4a59
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
2023-05-31 08:18:45 +03:00
Yuhang Zhao
389507a047 CMake: make compile options consistent for Qt created libraries
Currently some libraries created by Qt are lacking some compile
definitions and compile options, and this issue is causing us
troubles when building Qt statically. This patch tries to reduce
the parameter difference when compiling Qt's own libraries.

Change-Id: I3842943a874fab32ef90980e8aa29f5beb01feeb
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-31 01:08:45 +00:00
Vlad Zahorodnii
fb86c5a470 QGuiApplication: Remove .desktop suffix in setDesktopFileName
The desktop file name should not contain ".desktop" suffix, but some
applications still specify it anyway because of the ambiguity in the
documentation that was fixed in
0c5135a9df.

This change makes setDesktopFileName remove ".desktop" suffix so
desktopFileName always returns a desktop file name with correct format
and its users don't need to chop ".desktop".

Pick-to: 6.5
Change-Id: If5abccaf3bf976449cada8891fff887870e45b5f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-30 23:51:56 +03:00
Alexey Rochev
d68dbd8b7d Fix version script test
1. Don't reassign different versions to same symbol
2. Define symbols used
This fixes warnings with LLD linker (or errors if -Wl,--fatal-warnings is added by toolchain e.g. with Android NDK)
3. Add -Wl,--version-script to CMAKE_REQUIRED_LINK_OPTIONS instead of CMAKE_REQUIRED_FLAGS to prevent unused argument warning in compilation phase
(there is no need for _SAVE variable because we are inside a function and our CMAKE_REQUIRED_LINK_OPTIONS won't escase its scope)
4. Fix removal of version script file (incorrect file name was used)

Pick-to: 6.2 6.5
Task-number: QTBUG-111514
Change-Id: I0a1548c4268ad511760a0d4aa69ba7a0bdcbb0bc
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-30 23:25:57 +03:00
Arno Rehn
07d6d31a4c QFuture: Gracefully handle a destroyed context in continuations
This patch relaxes the requirements on the context object of
continuations. Instead of having to stay alive during execution of the
whole chain, it now only has to stay alive during setup of the chain.
If the context object is destroyed before the chain finishes, the
respective future is canceled.

This patch works by using QFutureCallOutInterface and signals instead
of direct invocation of the continuation by the parent future, similar
to how QFutureWatcher is implemented.
If a continuation is used with a context object, a QBasicFutureWatcher
is connected to the QFuture via a QFutureCallOutInterface. When the
future finishes, QBasicFutureWatcher::finished() triggers the
continuation with a signal/slot connection.
This way, we require the context object to stay alive only during setup;
the required synchronization is guaranteed by the existing event and
signal-slot mechanisms. The continuation itself does not need to know
about the context object anymore.

[ChangeLog][QtCore][QFuture] Added support for context objects of
continuations being destroyed before the continuation finishes. In
these cases the future is cancelled immediately.

Fixes: QTBUG-112958
Change-Id: Ie0ef3470b2a0ccfa789d2ae7604b92e509c14591
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-30 21:42:46 +02:00
Ivan Solovev
86c044176f Extend QFuture continuations tests
Create tests to check that the continuations attached to ready futures
are immediately executed, and that the proper handlers are selected.

These checks were missing from the overall test set, which was detected
while working on the linked issue.

Task-number: QTBUG-112958
Change-Id: Iae97e4b9dfb1e016869693a5162f72e027ca7f5e
Reviewed-by: Arno Rehn <a.rehn@menlosystems.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-30 21:42:45 +02:00
Ilya Fedin
b3b6dd49ba xdgdesktopportal: Fallback to base theme if color scheme is unknown
This should be better than returning unknown if xdg-desktop-portal
is not running or its backend doesn't know color scheme

This also matches the pratice of all other
QXdgDesktopPortalTheme methods

Pick-to: 6.5
Change-Id: I352e091a019bc5b683c3f1dad223e55717888d02
Reviewed-by: Jan Grulich <jgrulich@redhat.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-30 23:42:44 +04:00
Dennis Oberst
8f0d2e2874 QArrayDataPointer: add missing std::invoke call to projection
To ensure the correct invocation of the projection function, this patch
introduces the usage of std::invoke for all accesses to it. This
modification expands the coverage to include cases where the callable
object is a pointer to a member function.

Amends: 7ca633d9a8.

Change-Id: If666012d785ac74c8e856ea9be2a46b3307c8a06
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-30 16:50:58 +00:00
Dennis Oberst
2d77051f9d QArrayDataPointer: add missing Q_CHECK_PTR check in assign()
The previous implementation of iterator-assign did not include a check
for the return value of QArrayData::allocate(~), which returns a nullptr
on failure.

Amends: bbbe5f45c4.

Change-Id: I219e63ecd6de4225364d9c3dd2006ddbbe47068f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-30 16:50:54 +00:00
Amir Masoud Abdol
574cf24a65 Replace AUTO_RESOURCE_PREFIX with RESOURCE_PREFIX in qt-cmake-project
Pick-to: 6.5
Change-Id: I53b9e8887e8e79c1c1e836c514171aece8cf35aa
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-30 10:38:33 +02:00
Laszlo Agocs
09597d05f7 rhi: avoid backends modifying the frontend depth and arraySize
Buffer and texture sizes (size, pixelSize) may get increased, if needed,
but those actual sizes calculated by the QRhi backends are not written
back to the QRhiBuffer m_size or QRhiTexture m_pixelSize.

In contrast, both m_depth and m_arraySize are clamped in QRhiTexture
by most backends (to ensure a lower bound of 1 and 0, respectively).
This is not great since it means the getters for depth() and arraySize()
may return values different from what the user has provided. To avoid
confusion, do not modify the m_* variables.

Change-Id: I2cc5b9abf41ea108549ffd7f2403306e6e8ebba2
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
2023-05-30 10:29:55 +02:00
Laszlo Agocs
afe0bf0914 rhi: vulkan: expose the instance in the nativeHandles query
Mainly for completeness, but it has practical uses: someone retrieving
a QRhi instance from somewhere should be able to tell the
QVulkanInstance, and so the VkInstance, used by that QRhi without
resorting to investigating other objects (e.g. retrieving the instance
from the QWindow). This provides symmetry to other 3D APIs and QRhi
backends where just a single QRhi instance is sufficient to get the
MTLDevice, ID3D11Device/Context, etc. i.e. all that is needed to
work with the 3D API directly.

Change-Id: I5a8b9871a543ea648c76b868bf6ff7be5f2098f2
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io>
2023-05-30 10:29:51 +02:00
Topi Reinio
1cd35cff4d Doc: Fix documentation warnings for Qt Gui
* Fix file quoting in RHI Window example
* Add missing \inmodule commands for QRhi Classes
* Add missing dependency to qtshadertools
* Remove documentation for non-existent overload of
  QRhiGraphicsPipeline::setTargetBlends()

Other fixed warnings:

src/gui/rhi/qrhi.cpp:
* warning: clang couldn't find function when parsing
  \fn void setUsage(UsageFlags u)
* warning: clang couldn't find function when parsing
  \fn virtual bool QRhiSwapChain::isFormatSuported(Format f)

Change-Id: I73ff7896c3d5c8bb491368e941b32c8026a47191
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-05-30 08:29:26 +00:00
Andre Hartmann
2a90efcfc2 Diagram Scene: Fix documentation word repetiton
Pick-to: 6.5
Fixes: QTCREATORBUG-29214
Change-Id: I356a6ffbd48bf918208180b8b403b5c74ad368d5
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-05-29 19:51:21 +02:00
Andre Hartmann
2297056221 QPainter: Fix missing variable in drawPixmap snippet
Fixes: QTCREATORBUG-29216
Pick-to: 6.5
Change-Id: If055e7b4d6ba7734bc29da29db68b3224fc734c1
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-05-29 19:51:14 +02:00
Mårten Nordheim
57ba6260c0 Ssl: Copy the on-demand cert loading bool from default config
Otherwise individual sockets will still load system certificates when
a chain doesn't match against the configured CA certificates.
That's not intended behavior, since specifically setting the CA
certificates means you don't want the system certificates to be used.

Follow-up to/amends ada2c573c1

This is potentially a breaking change because now, if you ever add a
CA to the default config, it will disable loading system certificates
on demand for all sockets. And the only way to re-enable it is to
create a null-QSslConfiguration and set it as the new default.

Pick-to: 6.5 6.2 5.15
Change-Id: Ic3b2ab125c0cdd58ad654af1cb36173960ce2d1e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-05-29 16:03:35 +02:00
Yuhang Zhao
51becfbd23 CMake: use VS2019's flag for stronger inlining
Use the new "/Ob3" flag introduced in VS2019 to increase the inline
level, which may give better performance. For compilers older than
VS2019, we still use the traditional "/Ob2" inline level.

Official documentation:
https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170

Change-Id: I34a50f27a151cb7c09f0085dd037a385c71848aa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-29 05:57:08 +00:00
Ahmad Samir
44cfdfa7c0 Moc: port to qsizetype
Simple s/int/qsizetype/. Fixes some narrowing conversion warnings.

Pick-to: 6.5
Change-Id: Ied82e861298fa9763089cadc7eae6e536f1bb9ca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-28 01:18:56 +03:00
Ahmad Samir
c452a43b59 Moc: only call checkSuperClasses() if the class inherits another
I.e. if def.superclassList is empty, calling checkSuperClasses() is
no-op. Spotted by Fabian in code review.

Change-Id: I499baf1d2cf6dd08a26394221a48af991ccea4ad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-28 01:18:53 +03:00
Ahmad Samir
10510c0405 Moc: fix narrowing conversion warnings with iterators/algorithms
Drive-by change: check a QList isn't empty before using first()

Pick-to: 6.5
Change-Id: I24171d17244ae96ad5779d721c65d33e5489f5f3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-28 01:18:49 +03:00
Thiago Macieira
26dd7fe4ed CMake: remove "res_ninit" feature and collapse to just "libresolv"
Testing for "res_ninit" when WrapResolv.cmake has already checked for
far more complex functions was pointless. Instead, just accept the
library that was found by find_package() as good enough and rename the
feature as "libresolv".

Amends 4a46ba1209 and
68b625901f.

Change-Id: Ib5ce7a497e034ebabb2cfffd1762c0afa2fac6e0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-27 12:57:16 -07:00
Ahmad Samir
369952fbd7 QTimer: lambdas don't implicitly capture 'this' in C++20
Can't use [=, this], as clang fails to build with:
error: explicit capture of 'this' with a capture default of '=' is a
C++20 extension [-Werror,-Wc++20-extensions]

Change-Id: I8ead9cb493cb1e295aa03386d80af6e83ba8cbb4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-27 19:21:44 +02:00
Thiago Macieira
f89c4c4f8f qsimd_x86: update from upstream and enable a few more features
After https://github.com/opendcdiag/opendcdiag/pull/223.

Enabled for Qt:
* waitpkg
* RAO (Remote Atomic Operations)
* CMPccXADD
* avxifma
* LAM (Linear Address Masking)

Disabled:
* AVX-512 VNNI

Change-Id: I5f7f427ded124479baa6fffd1760c35ed5b2adbb
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2023-05-26 16:22:22 -07:00
Thiago Macieira
718dae8e0b x86simdgen: update the Makefile to include the copyright in the .cpp
Drive-by include "DO NOT EDIT" in both files.

Change-Id: Ib5ce7a497e034ebabb2cfffd1762bf1d4ce737eb
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2023-05-26 16:22:15 -07:00
Mårten Nordheim
456cfa0bd2 Network: Fix IFF_UP conflict on Linux with unity builds
I cannot repro this myself, but from the bug report it seems to be
defined in two headers, so we should consistently use the same one.

Fixes: QTBUG-113787
Pick-to: 6.5
Change-Id: I9f1cc51e379c33dbbf659946340a5207aaeb448a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-26 23:06:50 +02:00
Ahmad Samir
f3d0f4f4c3 qgenericatomic.h: fix includes
Change-Id: Ibac2204c971b16da9117c66a18c5c679ed331d3e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-26 19:48:33 +03:00
Ahmad Samir
516aa662a0 Break qglobal.h cyclic includes [3/3]
... with q*atomic.h.

Drive-by change: include <climits> instead of <limits.h>, from the
former's docs:
«This is a Standard C++ Library file.  You should @c \#include this
file in your programs, rather than any of the @a *.h implementation
files.»

Task-number: QTBUG-106722
Change-Id: Id8169c482d2231c1620db033fbed1f904e15ed9c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-26 19:48:32 +03:00
Ahmad Samir
0677d334f8 Break cyclic includes in qglobal.h [2/3]
Task-number: QTBUG-106722
Change-Id: I6cf2b3fcd419659cc8a0633892393febd26e505b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-26 19:48:31 +03:00
Ahmad Samir
43ec3d8d01 Break some include cycles in qglobal.h [1/3]
Remove qglobal.h include from qcompilerdetection.h, qsystemdetection.h
and modulecppexports.h.in

Testing locally, the code builds on Linux with precompiled headers
disabled/enabled (qt_pch.h includes qglobal.h, so building with PCH
enabled isn't useful for testing this) and with/without bootstrap.

qrunnable.*: missing includes detected by compiling with
-DFEATURE_headersclean=ON.

Task-number: QTBUG-106722
Change-Id: I70864dfbf117ffd7fe492eb715a413eb6f209990
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-26 19:48:29 +03:00
Volker Hilsheimer
2d9f7633bf Doc: use [since] tag for enum values added in Qt 6.6
Remove the manual "This enum value has been introduced..." text. Doing
that only for 6.6 to avoid unnecessary cherry-pick conflicts and general
code churn.

Change-Id: I89a6fd313582fd0c5d6209608a3740f19f91bd01
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-05-26 18:48:24 +02:00
Amir Masoud Abdol
966e256116 Make CONFIGS arguments of qt_internal_remove_compiler_flags optional
There was a discrepancy between what the comment was saying, and what
the function was doing before, and with this patch, we opt for what the
comment was saying, which makes more sense. In addition, I cleaned up
its documentation a bit.

Pick-to: 6.5
Change-Id: I07c20f93aa5c8e9bc942f5e69f0cf8299f4a813e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-26 18:48:23 +02:00
Alexey Edelev
fec618b723 Ignore carriage return character symbol explicitly
If users prefer non-unix new line style when building Qt in Linux
'\r' leads to an issue. syncqt cannot parse Qt header files using
inputstream. Add the explicit ignorance of the carriage return
character to make sure that it won't break parsing of the Qt headers.

Pick-to: 6.5
Fixes: QTBUG-113771
Change-Id: Iac69e77788517fe160118297051597a656b2f345
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-26 18:48:23 +02:00
Eike Ziller
47db21965d Examples: Do not add the same category twice
Amends 1371cd107a

Task-number: QTCREATORBUG-29197
Change-Id: I0dd4a08a597c237fd09f788cafb79af755953d0d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2023-05-26 17:44:54 +02:00
Alexey Edelev
18ef6849d2 Add the list of previously searched packages to qt_find_package
When configuring Qt the second time it might be situation that
the set of qt_find_package calls is changed. One of the scenarios
is the changing of the submodule list that needs to be built in
top-level builds. It's also applicable for Qt features that lead to
extra package lookup in the unlocked subdirectories. Current approach
collects packages that were found at the previous run and skips
search of the packages that are missing. The problem is that
it also skips packages even if qt_find_package was not called at
previous run. QT_INTERNAL_PREVIOUSLY_SEARCHED_PACKAGES collects
all packages that were actually searched at the previous run
to make sure that qt_find_package don't skip packages that
appeared at second run only.

Note: Described scenarios may still have other issues and are not
tested well.

Fixes: QTBUG-113244
Pick-to: 6.5
Change-Id: Iab36060a28fbaa16a3b3bdba67795955c496b0c3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
2023-05-26 17:44:54 +02:00
Joerg Bornemann
f18842dc38 Remove the -no-gcc-sysroot configure option
This option is dysfunctional since Qt 6.0. Modify the CMake variables
CMAKE_SYSROOT_LINK and CMAKE_SYSROOT_COMPILE instead.

Change-Id: Ib97dcc765c4644b5c3975d4b61c0e567451ea977
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-26 17:44:53 +02:00
Joerg Bornemann
fcf5eb7fee Remove the -silent option from configure-cmake-mapping.md
There's just no good equivalent with the CMake based build.

Change-Id: I923ef3173d631afe2db0bdacc1d02c1f4649b741
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-26 17:44:52 +02:00
Joerg Bornemann
360ccedd2c CMake: Remove the -mp configure option
This configure option is dysfunctional since Qt 6.0. If you really want
to add the /MP compiler option, add it to CMAKE_CXX_FLAGS.

Change-Id: I00b535067944df52abbadb424ec03e53aa41c819
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-26 17:44:51 +02:00
Joerg Bornemann
9639d11687 CMake: Remove the -make-tool configure option
This configure option is dysfunctional since Qt 6.0.
Use -cmake-generator instead.

Change-Id: Idb147ec8087018dab3ac0e571eeff7d1f18e34f6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-26 17:44:51 +02:00
Joerg Bornemann
a02be0f1cc Remove -list-libraries from configure-cmake-mapping.md
This Qt5 configure argument does not exist anymore.

Change-Id: I68c798eb2769c93e3ca0b30d6a3da3247e319eee
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-26 17:44:50 +02:00
Joerg Bornemann
06f117d7ca CMake: Update USE_FOLDERS comment in qt_standard_project_setup
Mention that CMake 3.26 introduced CMP0143 which enables USE_FOLDERS by
default.

Change-Id: I35deed9838f99f377657ca19a4e6058e1ecbedcf
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
2023-05-26 17:44:49 +02:00
Ievgenii Meshcheriakov
1538d30c76 qdbusxml2cpp: Use modern string literals
Replace QStringLiteral and QString::fromLatin1 by u""_s or ""_L1.

Also use initializer list constructor for QStringList.

Change-Id: Ife020ddf48d27dd015aed1c04878216165decf69
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-26 15:46:37 +02:00
Ievgenii Meshcheriakov
f6be12f2f9 qdbusxml2cpp: Combine string literals
Use multi-line string literals instead of repeated applications
of << operator. This should improve code size and performance.

Change-Id: I661454c007877bf86a289174e98d4cd3fe145d6f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-26 15:46:36 +02:00
Ievgenii Meshcheriakov
464bcc0b6a qdbusxml2cpp: Use "\n" instead of Qt::endl
This program is non-interactive and its output does not need
to be flushed after each line of the generated code. Using "\n"
improves code size, performance and readability.

Change-Id: I7def2a207cf4e5c3960db6ba3d8a8574eb0d27c1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-26 15:46:35 +02:00
Ievgenii Meshcheriakov
4f65f91d6f QDBus: Fix typo in a function name
Rename connectionCapabilies -> connectionCapabilities

Change-Id: I07deff1b944b30404548181d5c930b76fb1a575c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-26 15:46:34 +02:00
Marc Mutz
c7af8d5808 Deprecate qAsConst()
std::as_const() is a 100% equivalent replacement.

[ChangeLog][Deprecation Notices][QtCore] qAsConst() is now
deprecated. You can simply globally search and replace "qAsConst" with
"std::as_const" in your code-base.

Change-Id: If9b29f9b4119cf5bdb9f0a1ada1271c6bb503916
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-26 15:46:34 +02:00
Thiago Macieira
432d67b43f QDnsLookup: add TimeoutError for timeouts
We were getting InvalidReplyError because it was simply unknown, which
is not very useful. Previously, the Unix code used res_nquery(), which
does not return timeouts as a condition. It returns -1 if a timeout did
happen, but the content in errno could be a left-over from a previous
timeout (see the "Not a typewriter"[1] problem).

With the rewrite to using res_nmkquery() and res_nsend() from the
previous commits, we can rely on errno being set properly by
res_nsend().

$ $objdir/tests/manual/qdnslookup/qdnslookup @0.0.0.1
; <<>> QDnsLookup 6.6.0 <<>> qdnslookup @0.0.0.1
;; status: TimeoutError (Request timed out)
;; QUESTION:
;qt-project.org                 IN A

;; Query time: 10008 ms
;; SERVER: 0.0.0.1#53

Tested on FreeBSD, Linux, macOS, and Windows.

[1] https://en.wikipedia.org/wiki/Not_a_typewriter

Change-Id: I3e3bfef633af4130a03afffd175e31958247f9b1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-26 06:46:33 -07:00
Thiago Macieira
5ecdce0c35 QDnsLookup/Unix large replies: manually handle VC [3/3]
The current code was inefficient when replies exceeded the initial
buffer size because the res_nsend() function switched to VC to get the
full reply, but that wouldn't fit our buffer before we enlarged it. This
commit tells res_nsend() to only use UDP or only use TCP, avoiding the
two unnecessary transactions in the lookup.

Since we don't get that second TCP reply now that would tell us the size
of the reply, we must allocate the largest possible buffer for a DNS
reply.

Change-Id: I3e3bfef633af4130a03afffd175e73d2e9fa9bf1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-26 06:46:32 -07:00
Thiago Macieira
df07d98243 QDnsLookup/Unix large replies: use EDNS0 [2/3]
The current code is inefficient when dealing with replies exceeding the
PACKETSZ default size. This commit adds an EDNS0 footer to the DNS query
informing the DNS server how big our buffer is. We choose a larger
buffer than the old PACKETSZ so more will fit before a Virtual Circuit
(TCP socket) is required.

The choice is based on IPv6 requirements for the minimum MTU. Any
network incapable of transmitting frames with that big a payload must
support fragmenting and reassembly at the Layer 2 level, below IP.
Ethernet MTU is usually 1500, so we leave a bit on the table, but this
avoids having to discover our Path MTU to the DNS server.

This is incomplete: DNS queries above the 1232-byte limit still perform
the same query four times.

Change-Id: I3e3bfef633af4130a03afffd175e72f7fbc9265d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-26 06:46:31 -07:00
Thiago Macieira
b673fa09c3 QDnsLookup/Unix large replies: use res_nmkquery & res_nsend [1/3]
The current code is inefficient when dealing with replies exceeding the
PACKETSZ default size and especially those that require the use of a
Virtual Circuit (TCP socket). When the TC (Truncated) bit is set in the
DNS reply header, res_nquery() automatically switches to VC so it is
able to return the full size of the reply to us. This means we make the
same request four times:
 1) over UDP, getting ~512 bytes of data
 2) over TCP, getting the full reply but returning ~512 to us
 3) over UDP again, getting (maybe) 1400 bytes of data
 4) over TCP again, getting all the data

This commit splits res_nquery() into its two component functions,
res_nmkquery() and res_nsend(). This is incomplete: the four queries
above still happen.

Change-Id: I3e3bfef633af4130a03afffd175e728d96d6a604
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-26 06:46:31 -07:00
Samuli Piippo
4a46ba1209 network: fix link issue with older libc
Amend 68b625901f and fix link issue with
slightly less modern libc/libresolv where not all functions have been
moved over to libc.

ld: src/network/CMakeFiles/Network.dir/kernel/qdnslookup_unix.cpp.o: in function `QDnsLookupRunnable::query(QDnsLookupReply*)':
qdnslookup_unix.cpp:(.text+0x183): undefined reference to `__res_nquery'
ld: qdnslookup_unix.cpp:(.text+0x437): undefined reference to `__dn_expand'
ld: qdnslookup_unix.cpp:(.text+0x621): undefined reference to `__dn_expand'
ld: qdnslookup_unix.cpp:(.text+0x8ff): undefined reference to `__res_nquery'
ld: qdnslookup_unix.cpp:(.text+0xbd7): undefined reference to `__dn_expand'
ld: qdnslookup_unix.cpp:(.text+0xd7f): undefined reference to `__dn_expand'
ld: qdnslookup_unix.cpp:(.text+0xf4f): undefined reference to `__dn_expand'
ld: qdnslookup_unix.cpp:(.text+0x10fa): undefined reference to `__dn_expand'
ld: qdnslookup_unix.cpp:(.text+0x131c): undefined reference to `__dn_expand'
collect2: error: ld returned 1 exit status

Change-Id: If81b292222c78d828b9fef61f30a62f1d584c183
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-26 06:46:30 -07:00