tor
master
|
Uses the workqueue/threadpool code to farm CPU-intensive activities out to subprocesses. More...
#include "or.h"
#include "channel.h"
#include "circuitbuild.h"
#include "circuitlist.h"
#include "connection_or.h"
#include "config.h"
#include "cpuworker.h"
#include "crypto_rand.h"
#include "crypto_util.h"
#include "main.h"
#include "onion.h"
#include "rephist.h"
#include "router.h"
#include "workqueue.h"
Data Structures | |
struct | worker_state_s |
struct | cpuworker_request_t |
struct | cpuworker_reply_t |
struct | cpuworker_job_u |
Macros | |
#define | worker_state_free(ws) FREE_AND_NULL(worker_state_t, worker_state_free_, (ws)) |
#define | CPUWORKER_REQUEST_MAGIC 0xda4afeed |
#define | CPUWORKER_REPLY_MAGIC 0x5eedf00d |
#define | MAX_BELIEVABLE_ONIONSKIN_DELAY (2*1000*1000) |
Typedefs | |
typedef struct worker_state_s | worker_state_t |
typedef struct cpuworker_request_t | cpuworker_request_t |
typedef struct cpuworker_reply_t | cpuworker_reply_t |
typedef struct cpuworker_job_u | cpuworker_job_t |
Functions | |
void | cpu_init (void) |
void | cpuworkers_rotate_keyinfo (void) |
uint64_t | estimated_usec_for_onionskins (uint32_t n_requests, uint16_t onionskin_type) |
void | cpuworker_log_onionskin_overhead (int severity, int onionskin_type, const char *onionskin_type_name) |
MOCK_IMPL (workqueue_entry_t *, cpuworker_queue_work,(workqueue_priority_t priority, workqueue_reply_t(*fn)(void *, void *), void(*reply_fn)(void *), void *arg)) | |
int | assign_onionskin_to_cpuworker (or_circuit_t *circ, create_cell_t *onionskin) |
void | cpuworker_cancel_circ_handshake (or_circuit_t *circ) |
Uses the workqueue/threadpool code to farm CPU-intensive activities out to subprocesses.
The multithreading backend for this module is in workqueue.c; this module specializes workqueue.c.
Right now, we use this infrastructure
#define CPUWORKER_REQUEST_MAGIC 0xda4afeed |
Magic numbers to make sure our cpuworker_requests don't grow any mis-framing bugs.
#define MAX_BELIEVABLE_ONIONSKIN_DELAY (2*1000*1000) |
If any onionskin takes longer than this, we clip them to this time. (microseconds)
typedef struct cpuworker_reply_t cpuworker_reply_t |
A reply sent by a cpuworker.
typedef struct cpuworker_request_t cpuworker_request_t |
A request sent to a cpuworker.
int assign_onionskin_to_cpuworker | ( | or_circuit_t * | circ, |
create_cell_t * | onionskin | ||
) |
Try to tell a cpuworker to perform the public key operations necessary to respond to onionskin for the circuit circ.
Return 0 if we successfully assign the task, or -1 on failure.
void cpu_init | ( | void | ) |
Initialize the cpuworker subsystem. It is OK to call this more than once during Tor's lifetime.
void cpuworker_cancel_circ_handshake | ( | or_circuit_t * | circ | ) |
If circ has a pending handshake that hasn't been processed yet, remove it from the worker queue.
void cpuworker_log_onionskin_overhead | ( | int | severity, |
int | onionskin_type, | ||
const char * | onionskin_type_name | ||
) |
If we've measured overhead for onionskins of type onionskin_type, log it.
void cpuworkers_rotate_keyinfo | ( | void | ) |
Called when the onion key has changed so update all CPU worker(s) with new function pointers with which a new state will be generated.
uint64_t estimated_usec_for_onionskins | ( | uint32_t | n_requests, |
uint16_t | onionskin_type | ||
) |
Return an estimate of how many microseconds we will need for a single cpuworker to process n_requests onionskins of type onionskin_type.
MOCK_IMPL | ( | workqueue_entry_t * | , |
cpuworker_queue_work | , | ||
(workqueue_priority_t priority, workqueue_reply_t(*fn)(void *, void *), void(*reply_fn)(void *), void *arg) | |||
) |
DOCDOC