Skip to content

Commit

Permalink
statemachines.md: add the state image
Browse files Browse the repository at this point in the history
With an associated explanation of the shown states
  • Loading branch information
bagder committed Dec 15, 2021
1 parent 9855773 commit 05fa73c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
Binary file added internals/slide-transfer-state-machine.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 26 additions & 5 deletions internals/statemachines.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
# Everything is state machines

To facilitate that non-blocking nature, the curl source is full of state
machines. Work on as much data as there is and drive the state machine to
where it can go based on what's available and allow the functions to continue
from that point later on when more data arrives that then might drive the
state machine further.
To facilitate non-blocking behavior all through, the curl source is full of
state machines. Work on as much data as there is and drive the state machine
to where it can go based on what's available and allow the functions to
continue from that point later on when more data arrives that then might drive
the state machine further.

There are such states in many different levels for a given transfer and the
code for each particular protocol may have its own set of state machines.

## mstate

One of the primary states is the main transfer "mode" the easy handle holds,
which says if the current transfer is resolving, waiting for a resolve,
connecting, waiting for a connect, issuing a request, doing a transfer etc
(see the `CURLMstate` enum in `lib/multihandle.h`). Every transfer done with
libcurl has an associated easy handle and every easy handle will exercise that
state machine.

The image below shows all states and possible state transitions. See further
explanation below.

![libcurl transfer state machine](slide-transfer-state-machine.jpg)

All transfers start in **INIT** and they end in **MSGSENT**

**yellow**: the initial setting-up states

**blue**: resolving names and setting up the connection

**green**: initiating and setting up the transfer

**white**: the transfer

**red**: post-transfer

All states within the striped area have an associated connection.

0 comments on commit 05fa73c

Please sign in to comment.