diff options
author | Alexander Færøy <ahf@torproject.org> | 2018-11-22 04:49:23 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-12-17 16:39:28 -0500 |
commit | bb784cf4f36256a8276ba60641d3ff766b9cd9df (patch) | |
tree | 347af5c98bbeb2edcd4655f6740de9358b70ab62 /src/lib/process/process.h | |
parent | 2e957027e28449d4c3254cc404d154f4bce41bfc (diff) | |
download | tor-bb784cf4f36256a8276ba60641d3ff766b9cd9df.tar.gz tor-bb784cf4f36256a8276ba60641d3ff766b9cd9df.zip |
Add Windows backend for the Process subsystem.
This patch adds support for Microsoft Windows in the Process subsystem.
Libevent does not support mixing different types of handles (sockets,
named pipes, etc.) on Windows in its core event loop code. This have
historically meant that Tor have avoided attaching any non-networking
handles to the event loop. This patch uses a slightly different approach
to roughly support the same features for the Process subsystem as we do
with the Unix backend.
In this patch we use Windows Extended I/O functions (ReadFileEx() and
WriteFileEx()) which executes asynchronously in the background and
executes a completion routine when the scheduled read or write operation
have completed. This is much different from the Unix backend where the
operating system signals to us whenever a file descriptor is "ready" to
either being read from or written to.
To make the Windows operating system execute the completion routines of
ReadFileEx() and WriteFileEx() we must get the Tor process into what
Microsoft calls an "alertable" state. To do this we execute SleepEx()
with a zero millisecond sleep time from a main loop timer that ticks
once a second. This moves the process into the "alertable" state and
when we return from the zero millisecond timeout all the outstanding I/O
completion routines will be called and we can schedule the next reads
and writes.
The timer loop is also responsible for detecting whether our child
processes have terminated since the last timer tick.
See: https://bugs.torproject.org/28179
Diffstat (limited to 'src/lib/process/process.h')
-rw-r--r-- | src/lib/process/process.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/lib/process/process.h b/src/lib/process/process.h index b17b8dac7c..f759c71939 100644 --- a/src/lib/process/process.h +++ b/src/lib/process/process.h @@ -98,6 +98,9 @@ process_status_t process_get_status(const process_t *process); #ifndef _WIN32 struct process_unix_t; struct process_unix_t *process_get_unix_process(const process_t *process); +#else +struct process_win32_t; +struct process_win32_t *process_get_win32_process(const process_t *process); #endif void process_write(process_t *process, |