curl-fuzzer C++ reference
Loading...
Searching...
No Matches
proto_fuzzer::MultiSocketDriver Class Reference

Owns the socket and timer callback state required by libcurl's event-driven multi API. More...

#include <multi_socket_driver.h>

Classes

struct  DriveResult
 Result from one non-blocking event-loop turn. More...

Public Member Functions

 MultiSocketDriver ()
 Construct detached callback state.
 ~MultiSocketDriver ()
 The owner deliberately destroys this after curl_multi_cleanup, so there is no callback deregistration or libcurl access left for the destructor.
bool Install (CURLM *multi)
 Install socket/timer callbacks on a caller-owned multi before adding an easy handle.
CURLMcode Start (int *running_handles)
 Start libcurl's socket state machine through the documented timeout pseudo-socket without waiting for a real timer.
DriveResult DriveReady (int *running_handles)
 Run one bounded, non-blocking event-loop turn: poll the callback-provided watch set with a zero timeout and report readiness back to libcurl.
void ProbeControlApis ()
 Exercise the wakeup and timeout-query APIs from a valid live-multi state.
bool watch_exhausted () const

Detailed Description

Owns the socket and timer callback state required by libcurl's event-driven multi API.

The fuzzer must retain callback storage until after the easy handle leaves the multi and the multi is cleaned up: either operation can synchronously issue CURL_POLL_REMOVE. A fixed watch table provides stable addresses for curl_multi_assign while preventing a mutated transfer from allocating an unbounded application-side poll set.

Definition at line 30 of file multi_socket_driver.h.

Constructor & Destructor Documentation

◆ MultiSocketDriver()

proto_fuzzer::MultiSocketDriver::MultiSocketDriver ( )

Construct detached callback state.

Install() supplies the multi only after all watch storage has reached its final address.

Definition at line 54 of file multi_socket_driver.cc.

Member Function Documentation

◆ DriveReady()

MultiSocketDriver::DriveResult proto_fuzzer::MultiSocketDriver::DriveReady ( int * running_handles)

Run one bounded, non-blocking event-loop turn: poll the callback-provided watch set with a zero timeout and report readiness back to libcurl.

The snapshot is intentional: a socket action may synchronously remove the current watch or install another one, so the callback-owned table must not be iterated as a live container across that call. Service a deferred zero timer after socket callbacks, never recursively from the timer callback.

Parameters
running_handlesIn/out unfinished-transfer count.
Returns
Result code and whether observable driver state advanced.

Definition at line 101 of file multi_socket_driver.cc.

◆ Install()

bool proto_fuzzer::MultiSocketDriver::Install ( CURLM * multi)

Install socket/timer callbacks on a caller-owned multi before adding an easy handle.

curl may announce a timer during curl_multi_add_handle, so installing later would miss the event that starts an otherwise idle socket-action application.

Parameters
multiMulti handle that outlives this driver.
Returns
true when every callback option was accepted.

Definition at line 67 of file multi_socket_driver.cc.

◆ ProbeControlApis()

void proto_fuzzer::MultiSocketDriver::ProbeControlApis ( )

Exercise the wakeup and timeout-query APIs from a valid live-multi state.

A zero-timeout query is informational; wakeup is also non-blocking when no other thread is in a poll call, which is the deterministic behavior this lane needs. Neither call waits or changes the operation budget.

Definition at line 168 of file multi_socket_driver.cc.

◆ Start()

CURLMcode proto_fuzzer::MultiSocketDriver::Start ( int * running_handles)

Start libcurl's socket state machine through the documented timeout pseudo-socket without waiting for a real timer.

This creates the first socket and gives the callback its initial watch without a wall-clock dependency.

Parameters
running_handlesReceives the number of unfinished transfers.
Returns
Result from curl_multi_socket_action.

Definition at line 84 of file multi_socket_driver.cc.

◆ watch_exhausted()

bool proto_fuzzer::MultiSocketDriver::watch_exhausted ( ) const
inline
Returns
true if any socket callback exhausted the fixed watch table in this drive.

Definition at line 55 of file multi_socket_driver.h.


The documentation for this class was generated from the following files: