History log of /curl/lib/asyn-thread.c (Results 1 – 25 of 120)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 72abf7c1 02-Jun-2024 Viktor Szakats

lib: tidy up types and casts

Cherry-picked from #13489
Closes #13862


# 998b17ea 03-Jun-2024 Viktor Szakats

windows: fix UWP builds, add GHA job

Add new job to test building for UWP (aka `CURL_WINDOWS_APP`).

Fix fallouts when building for UWP:
- rand: do not use `BCryptGenRandom()`.

windows: fix UWP builds, add GHA job

Add new job to test building for UWP (aka `CURL_WINDOWS_APP`).

Fix fallouts when building for UWP:
- rand: do not use `BCryptGenRandom()`.
- cmake: disable using win32 LDAP.
- cmake: disable telnet.
- version_win32: fix code before declaration.
- schannel: disable `HAS_MANUAL_VERIFY_API`.
- schannel: disable `SSLSUPP_PINNEDPUBKEY`
and make `schannel_checksum()` a stub.
Ref: e178fbd40a896f2098278ae61e1166c88e7b31d0 #1429
- schannel: make `cert_get_name_string()` a failing stub.
- system_win32: make `Curl_win32_impersonating()` a failing stub.
- system_win32: try to fix `Curl_win32_init()` (untested).
- threads: fix to use `CreateThread()`.
- src: disable searching `PATH` for the CA bundle.
- src: disable bold text support and capability detection.
- src: disable `getfiletime()`/`setfiletime()`.
- tests: make `win32_load_system_library()` a failing stub.
- tests/server/util: make it compile.
- tests/server/sockfilt: make it compile.
- tests/lib3026: fix to use `CreateThread()`.

See individual commits for build error details.

Some of these fixes may have better solutions, and some may not work
as expected. The goal of this patch is to make curl build for UWP.

Closes #13870

show more ...


# 23fe1a52 01-Jun-2024 Andy Pan

socketpair: add `eventfd` and use `SOCK_NONBLOCK` for `socketpair()`

Currently, we use `pipe` for `wakeup_create`, which requires ***two***
file descriptors. Furthermore, given its compl

socketpair: add `eventfd` and use `SOCK_NONBLOCK` for `socketpair()`

Currently, we use `pipe` for `wakeup_create`, which requires ***two***
file descriptors. Furthermore, given its complexity inside, `pipe` is a
bit heavyweight for just a simple event wait/notify mechanism.

`eventfd` would be a more suitable solution for this kind of scenario,
kernel also advocates for developers to use `eventfd` instead of `pipe`
in some simple use cases:

Applications can use an eventfd file descriptor instead of a pipe
(see pipe(2) in all cases where a pipe is used simply to signal
events. The kernel overhead of an eventfd file descriptor is much
lower than that of a pipe, and only one file descriptor is required
(versus the two required for a pipe).

This change adds the new backend of `eventfd` for `wakeup_create` and
uses it where available, eliminating the overhead of `pipe`. Also, it
optimizes the `wakeup_create` to eliminate the system calls that make
file descriptors non-blocking by moving the logic of setting
non-blocking flags on file descriptors to `socketpair.c` and using
`SOCK_NONBLOCK` for `socketpair(2)`, `EFD_NONBLOCK` for `eventfd(2)`.

Ref:
https://man7.org/linux/man-pages/man7/pipe.7.html
https://man7.org/linux/man-pages/man2/eventfd.2.html
https://man7.org/linux/man-pages/man2/socketpair.2.html
https://www.gnu.org/software/gnulib/manual/html_node/eventfd.html

Closes #13874

show more ...


# 83384669 04-Jun-2024 Viktor Szakats

lib: fix thread entry point to return `DWORD` on WinCE

We already do this in `tests/server/util.c`:
https://github.com/curl/curl/blob/97e5e37cc8269660bc5d4a1936f10f2390b97c5a/tests/serve

lib: fix thread entry point to return `DWORD` on WinCE

We already do this in `tests/server/util.c`:
https://github.com/curl/curl/blob/97e5e37cc8269660bc5d4a1936f10f2390b97c5a/tests/server/util.c#L604-L606
and in `sockfilt.c`, `lib3026.c`.

Before this patch it returned `unsigned int`.

Closes #13877

show more ...


# 0caadc1f 21-May-2024 Pavel Pavlov

asyn-thread: avoid using GetAddrInfoExW with impersonation

Multiple reports suggest that GetAddrInfoExW fails when impersonation is
used. This PR checks if thread is impersonating and av

asyn-thread: avoid using GetAddrInfoExW with impersonation

Multiple reports suggest that GetAddrInfoExW fails when impersonation is
used. This PR checks if thread is impersonating and avoids using
GetAddrInfoExW api.

Reported-by: Keerthi Timmaraju
Assisted-by: edmcln on github
Fixes #13612
Closes #13738

show more ...


# 428579f5 02-May-2024 Pavel Pavlov

asyn-thread: fix curl_global_cleanup crash in Windows

- Make sure that asynchronous resolves handled by Winsock are stopped
before WSACleanup is called.

This is implemented by

asyn-thread: fix curl_global_cleanup crash in Windows

- Make sure that asynchronous resolves handled by Winsock are stopped
before WSACleanup is called.

This is implemented by ensuring that when Curl_resolver_kill is called
(eg via multi_done) it will cancel the Winsock asynchronous resolve and
wait for the cancellation to complete. Winsock runs the asynchronous
completion routine immediately when a resolve is canceled.

Prior to this change it was possible that during curl_global_cleanup
"a DNS resolver thread created by GetAddrInfoExW did not terminate yet,
however curl is already shutting down, deinitializing Winsock with
WSACleanup() leading to an access violation."

Background:

If libcurl is built with the asynchronous threaded resolver option for
Windows then it resolves in one of two ways. For Windows 8.1 and later,
libcurl resolves by using the Winsock asynchronous resolver which does
its own thread management. For older versions of Windows, libcurl
resolves by creating a separate thread that calls getaddrinfo. This
change only affects the former and it's already handled for the latter.

Reported-by: Ch40zz@users.noreply.github.com

Fixes https://github.com/curl/curl/issues/13509
Closes https://github.com/curl/curl/pull/13518

show more ...


# 62ae1f10 06-May-2024 Jay Satiro

asyn-thread: fix Curl_thread_create result check

- Compare to curl_thread_t_null instead of 0 for error.

Currently for both supported thread libraries (pthreads and Windows)
cur

asyn-thread: fix Curl_thread_create result check

- Compare to curl_thread_t_null instead of 0 for error.

Currently for both supported thread libraries (pthreads and Windows)
curl_thread_t_null is defined as 0. However, the pattern throughout the
code is to check against curl_thread_t_null and not 0 since for
posterity some thread library may not use 0 for error.

Closes https://github.com/curl/curl/pull/13542

show more ...


# e411c98f 11-Apr-2024 Viktor Szakats

build: prefer `USE_IPV6` macro internally (was: `ENABLE_IPV6`)

Before this patch, two macros were used to guard IPv6 features in curl
sources: `ENABLE_IPV6` and `USE_IPV6`. This patch ma

build: prefer `USE_IPV6` macro internally (was: `ENABLE_IPV6`)

Before this patch, two macros were used to guard IPv6 features in curl
sources: `ENABLE_IPV6` and `USE_IPV6`. This patch makes the source use
the latter for consistency with other similar switches.

`-DENABLE_IPV6` remains accepted for compatibility as a synonym for
`-DUSE_IPV6`, when passed to the compiler.

`ENABLE_IPV6` also remains the name of the CMake and `Makefile.vc`
options to control this feature.

Closes #13349

show more ...


# 8243ad64 01-Feb-2024 Daniel Stenberg

asyn-thread: use wakeup_close to close the read descriptor

Reported-by: Dan Fandrich
Ref: #12834
Closes #12836


# f0ea11b5 01-Jan-2024 Viktor Szakats

asyn-thread: silence `-Wcast-align` warning for Windows

Seen with llvm/clang 17:
```
lib/asyn-thread.c:310:5: warning: cast from 'PCHAR' (aka 'char *') to 'struct thread_sync_data *'

asyn-thread: silence `-Wcast-align` warning for Windows

Seen with llvm/clang 17:
```
lib/asyn-thread.c:310:5: warning: cast from 'PCHAR' (aka 'char *') to 'struct thread_sync_data *' increases required alignment from 1 to 8 [-Wcast-align]
310 | CONTAINING_RECORD(overlapped, struct thread_sync_data, w8.overlapped);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../llvm-mingw/aarch64-w64-mingw32/include/winnt.h:717:48: note: expanded from macro 'CONTAINING_RECORD'
717 | #define CONTAINING_RECORD(address,type,field) ((type *)((PCHAR)(address) - (ULONG_PTR)(&((type *)0)->field)))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Follow-up to a6bbc87f9e9ffb46a1801dfb983e7534825ed56b #12482

Ref: https://github.com/curl/curl/pull/12482#issuecomment-1873017261
Closes #12615

show more ...


# a6bbc87f 17-Nov-2023 Pavel Pavlov

asyn-thread: use GetAddrInfoExW on >= Windows 8

For doing async DNS resolution instead of starting a thread for each
request.

Fixes #12481
Closes #12482


# 907eea08 14-Dec-2023 Daniel Stenberg

Revert "urldata: move async resolver state from easy handle to connectdata"

This reverts commit 56a4db2e4e2bcb9a0dcb75b83560a78ef231fcc8 (#12198)

We want the c-ares channel to be he

Revert "urldata: move async resolver state from easy handle to connectdata"

This reverts commit 56a4db2e4e2bcb9a0dcb75b83560a78ef231fcc8 (#12198)

We want the c-ares channel to be held in the easy handle, not per
connection - for performance.

Closes #12524

show more ...


# 56a4db2e 25-Oct-2023 Stefan Eissing

urldata: move async resolver state from easy handle to connectdata

- resolving is done for a connection, not for every transfer
- save create/dup/free of a cares channel for each transfe

urldata: move async resolver state from easy handle to connectdata

- resolving is done for a connection, not for every transfer
- save create/dup/free of a cares channel for each transfer
- check values of setopt calls against a local channel if no
connection has been attached yet, when needed.

Closes #12198

show more ...


# 43eb798d 17-Oct-2023 Daniel Stenberg

asyn-thread: use pipe instead of socketpair for IPC when available

If pipe() is present. Less overhead.

Helped-by: Viktor Szakats
Closes #12146


# d3142b57 01-Aug-2023 Daniel Stenberg

resolve: use PF_INET6 family lookups when CURL_IPRESOLVE_V6 is set

Previously it would always do PF_UNSPEC if CURL_IPRESOLVE_V4 is not
used, thus unnecessarily asking for addresses that

resolve: use PF_INET6 family lookups when CURL_IPRESOLVE_V6 is set

Previously it would always do PF_UNSPEC if CURL_IPRESOLVE_V4 is not
used, thus unnecessarily asking for addresses that will not be used.

Reported-by: Joseph Tharayil
Fixes #11564
Closes #11565

show more ...


# f198d33e 18-May-2023 Emanuele Torre

checksrc: disallow spaces before labels

Out of 415 labels throughout the code base, 86 of those labels were
not at the start of the line. Which means labels always at the start of
th

checksrc: disallow spaces before labels

Out of 415 labels throughout the code base, 86 of those labels were
not at the start of the line. Which means labels always at the start of
the line is the favoured style overall with 329 instances.

Out of the 86 labels not at the start of the line:
* 75 were indented with the same indentation level of the following line
* 8 were indented with exactly one space
* 2 were indented with one fewer indentation level then the following
line
* 1 was indented with the indentation level of the following line minus
three space (probably unintentional)

Co-Authored-By: Viktor Szakats

Closes #11134

show more ...


# 2bc1d775 02-Jan-2023 Daniel Stenberg

copyright: update all copyright lines and remove year ranges

- they are mostly pointless in all major jurisdictions
- many big corporations and projects already don't use them
- save

copyright: update all copyright lines and remove year ranges

- they are mostly pointless in all major jurisdictions
- many big corporations and projects already don't use them
- saves us from pointless churn
- git keeps history for us
- the year range is kept in COPYING

checksrc is updated to allow non-year using copyright statements

Closes #10205

show more ...


# 2d9fee45 23-Nov-2022 Daniel Gustafsson

netware: remove leftover traces

Commit 3b16575ae938dec2a29454631a12aa52b6ab9c67 removed support for
building on Novell Netware, but a few leftover traces remained. This
removes the l

netware: remove leftover traces

Commit 3b16575ae938dec2a29454631a12aa52b6ab9c67 removed support for
building on Novell Netware, but a few leftover traces remained. This
removes the last bits.

Closes: #9966
Reviewed-by: Daniel Stenberg <daniel@haxx.se>

show more ...


# 49798cac 12-Jul-2022 Alexandre Ferrieux

CURLOPT_QUICK_EXIT: don't wait for DNS thread on exit

Fixes #2975
Closes #9147


# b563a92c 01-Nov-2022 Viktor Szakats

tidy-up: process.h detection and use

This patch aims to cleanup the use of `process.h` header and the macro
`HAVE_PROCESS_H` associated with it.

- `process.h` is always availabl

tidy-up: process.h detection and use

This patch aims to cleanup the use of `process.h` header and the macro
`HAVE_PROCESS_H` associated with it.

- `process.h` is always available on Windows. In curl, it is required
only for `_beginthreadex()` in `lib/curl_threads.c`.

- `process.h` is also available in MS-DOS. In curl, its only use was in
`lib/smb.c` for `getpid()`. But `getpid()` is in fact declared by
`unistd.h`, which is always enabled via `lib/config-dos.h`. So the
header is not necessary.

- `HAVE_PROCESS_H` was detected by CMake, forced to 1 on Windows and
left to real detection for other platforms.
It was also set to always-on in `lib/config-win32.h` and
`lib/config-dos.h`.
In autotools builds, there was no detection and the macro was never
set.

Based on these observations, in this patch we:

- Rework Windows `getpid` logic in `lib/smb.c` to always use the
equivalent direct Win32 API function `GetCurrentProcessId()`, as we
already did for Windows UWP apps. This makes `process.h` unnecessary
here on Windows.

- Stop #including `process.h` into files where it was not necessary.
This is everywhere, except `lib/curl_threads.c`.

> Strangely enough, `lib/curl_threads.c` compiled fine with autotools
> because `process.h` is also indirecty included via `unistd.h`. This
> might have been broken in autotools MSVC builds, where the latter
> header is missing.

- Delete all remaining `HAVE_PROCESS_H` feature guards, for they were
unnecessary.

- Delete `HAVE_PROCESS_H` detection from CMake and predefined values
from `lib/config-*.h` headers.

Reviewed-by: Jay Satiro
Closes #9703

show more ...


# 279834dd 24-Oct-2022 Daniel Stenberg

misc: remove duplicated include files

Closes #9796


# 46f3fe0e 21-Sep-2022 Daniel Stenberg

hostip: lazily wait to figure out if IPv6 works until needed

The check may take many milliseconds, so now it is performed once the
value is first needed. Also, this change makes sure tha

hostip: lazily wait to figure out if IPv6 works until needed

The check may take many milliseconds, so now it is performed once the
value is first needed. Also, this change makes sure that the value is
not used if the resolve is set to be IPv4-only.

Closes #9553

show more ...


# 1902e8fc 19-Sep-2022 Dmitry Karpov

resolve: make forced IPv4 resolve only use A queries

This protects IPv4-only transfers from undesired bad IPv6-related side
effects and make IPv4 transfers in dual-stack libcurl behave t

resolve: make forced IPv4 resolve only use A queries

This protects IPv4-only transfers from undesired bad IPv6-related side
effects and make IPv4 transfers in dual-stack libcurl behave the same
way as in IPv4 single-stack libcurl.

Closes #9540

show more ...


# f236595e 14-Aug-2022 Daniel Stenberg

asyn-thread: fix socket leak on OOM

Closes #9310


# 451bcc1a 12-Jul-2022 Daniel Stenberg

asyn-thread: make getaddrinfo_complete return CURLcode

... as the only caller that cares about what it returns assumes that
anyway. This caused icc to warn:

asyn-thread.c(505):

asyn-thread: make getaddrinfo_complete return CURLcode

... as the only caller that cares about what it returns assumes that
anyway. This caused icc to warn:

asyn-thread.c(505): error #188: enumerated type mixed with another type
result = getaddrinfo_complete(data);

Repoorted-by: Matthew Thompson
Bug: https://github.com/curl/curl/issues/9081#issuecomment-1182143076
Closes #9146

show more ...


12345