Refactor curl-util to use the same per-request, refcounted, cancellable
slot model as sd-bus, sd-varlink and qmp-client.
CurlGlue becomes opaque and refcounted, and dispatches per-slot
completion callbacks through CURLOPT_PRIVATE instead of a single
g->on_finished demux that every caller had to switch on. The new
curl_glue_perform_async(g, easy, cb, userdata, &slot) replaces
curl_glue_add + the on_finished/userdata wiring.
CurlSlot is the per-request handle: it owns the easy handle,
curl_slot_unref does curl_multi_remove_handle + curl_easy_cleanup
(which doubles as cancel since remove aborts in-flight transfers
without queuing CURLMSG_DONE), and floating slots (ret_slot=NULL) are
kept alive in the glue's slot set until the callback fires. Drop the
userdata parameter from curl_glue_make: CURLOPT_PRIVATE is now used
internally to route completions to the slot.
Migrate pull-job and the pull-{oci,raw,tar} drivers, and imdsd, to the
new shape. PullJob.curl becomes PullJob.slot; pull_job_curl_on_finished
becomes a per-slot callback. imdsd routes its token-vs-data branch off
slot identity rather than easy-handle pointer comparison. Both daemons
drop the global on_finished/userdata wiring on the glue. pull_job_finish
and context_fail{,_full} now return int (always 0) so the callbacks
stay in the `return finish(...);` style.
Add test-curl-util covering glue lifecycle, easy-handle defaults,
floating and non-floating perform paths, cancel-via-slot-unref (verified
by a sentinel request that drives the loop to completion), and three
concurrent requests on a single glue. Tests fetch local files via
file:// URLs so no network is needed; libcurl availability is probed
once via dlopen_curl in intro().
95 lines
3.6 KiB
C
95 lines
3.6 KiB
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
#pragma once
|
|
|
|
/* IWYU pragma: always_keep */
|
|
|
|
#include "sd-forward.h" /* IWYU pragma: export */
|
|
|
|
typedef int (*copy_progress_bytes_t)(uint64_t n_bytes, uint64_t bytes_per_second, void *userdata);
|
|
typedef int (*copy_progress_path_t)(const char *path, const struct stat *st, void *userdata);
|
|
|
|
struct local_address;
|
|
struct in_addr_prefix;
|
|
struct in_addr_full;
|
|
|
|
typedef enum AskPasswordFlags AskPasswordFlags;
|
|
typedef enum BootEntryTokenType BootEntryTokenType;
|
|
typedef enum BootEntrySource BootEntrySource;
|
|
typedef enum BusPrintPropertyFlags BusPrintPropertyFlags;
|
|
typedef enum BusTransport BusTransport;
|
|
typedef enum CatFlags CatFlags;
|
|
typedef enum CertificateSourceType CertificateSourceType;
|
|
typedef enum DnsAnswerFlags DnsAnswerFlags;
|
|
typedef enum DnsCacheMode DnsCacheMode;
|
|
typedef enum DnsOverTlsMode DnsOverTlsMode;
|
|
typedef enum DnsProtocol DnsProtocol;
|
|
typedef enum DnssecMode DnssecMode;
|
|
typedef enum Fido2EnrollFlags Fido2EnrollFlags;
|
|
typedef enum KeySourceType KeySourceType;
|
|
typedef enum LabelFixFlags LabelFixFlags;
|
|
typedef enum MatchUnitFlag MatchUnitFlag;
|
|
typedef enum MountInNamespaceFlags MountInNamespaceFlags;
|
|
typedef enum NamePolicy NamePolicy;
|
|
typedef enum OutputFlags OutputFlags;
|
|
typedef enum OutputMode OutputMode;
|
|
typedef enum PagerFlags PagerFlags;
|
|
typedef enum PatternCompileCase PatternCompileCase;
|
|
typedef enum RemoveFlags RemoveFlags;
|
|
typedef enum ResolveSupport ResolveSupport;
|
|
typedef enum TPM2Flags TPM2Flags;
|
|
typedef enum Tpm2Support Tpm2Support;
|
|
typedef enum Tpm2UserspaceEventType Tpm2UserspaceEventType;
|
|
typedef enum UnitFileFlags UnitFileFlags;
|
|
typedef enum UnitFilePresetMode UnitFilePresetMode;
|
|
typedef enum UnitFileState UnitFileState;
|
|
typedef enum UserDBFlags UserDBFlags;
|
|
typedef enum UserRecordLoadFlags UserRecordLoadFlags;
|
|
typedef enum UserStorage UserStorage;
|
|
|
|
typedef struct AskPasswordRequest AskPasswordRequest;
|
|
typedef struct Bitmap Bitmap;
|
|
typedef struct BootConfig BootConfig;
|
|
typedef struct BootEntry BootEntry;
|
|
typedef struct BPFProgram BPFProgram;
|
|
typedef struct BusObjectImplementation BusObjectImplementation;
|
|
typedef struct CalendarSpec CalendarSpec;
|
|
typedef struct Condition Condition;
|
|
typedef struct ConfigSection ConfigSection;
|
|
typedef struct ConfigTableItem ConfigTableItem;
|
|
typedef struct CPUSet CPUSet;
|
|
typedef struct CurlGlue CurlGlue;
|
|
typedef struct CurlSlot CurlSlot;
|
|
typedef struct DissectedImage DissectedImage;
|
|
typedef struct DnsAnswer DnsAnswer;
|
|
typedef struct DnsPacket DnsPacket;
|
|
typedef struct DnsQuestion DnsQuestion;
|
|
typedef struct DnsResourceKey DnsResourceKey;
|
|
typedef struct DnsResourceRecord DnsResourceRecord;
|
|
typedef struct DnsSvcParam DnsSvcParam;
|
|
typedef struct DnsTxtItem DnsTxtItem;
|
|
typedef struct FDSet FDSet;
|
|
typedef struct Fido2HmacSalt Fido2HmacSalt;
|
|
typedef struct GroupRecord GroupRecord;
|
|
typedef struct Image Image;
|
|
typedef struct ImageFilter ImageFilter;
|
|
typedef struct ImagePolicy ImagePolicy;
|
|
typedef struct InstallChange InstallChange;
|
|
typedef struct InstallInfo InstallInfo;
|
|
typedef struct LookupPaths LookupPaths;
|
|
typedef struct LoopDevice LoopDevice;
|
|
typedef struct MachineBindUserContext MachineBindUserContext;
|
|
typedef struct MachineCredentialContext MachineCredentialContext;
|
|
typedef struct MountOptions MountOptions;
|
|
typedef struct MStack MStack;
|
|
typedef struct OpenFile OpenFile;
|
|
typedef struct Pkcs11EncryptedKey Pkcs11EncryptedKey;
|
|
typedef struct QmpClient QmpClient;
|
|
typedef struct QmpSlot QmpSlot;
|
|
typedef struct Table Table;
|
|
typedef struct Tpm2Context Tpm2Context;
|
|
typedef struct Tpm2Handle Tpm2Handle;
|
|
typedef struct Tpm2PCRValue Tpm2PCRValue;
|
|
typedef struct UnitInfo UnitInfo;
|
|
typedef struct UserRecord UserRecord;
|
|
typedef struct VeritySettings VeritySettings;
|