Data Structures | Macros | Typedefs | Functions | Variables
onion_queue.c File Reference
#include "core/or/or.h"
#include "feature/relay/onion_queue.h"
#include "app/config/config.h"
#include "core/mainloop/cpuworker.h"
#include "core/or/circuitlist.h"
#include "core/or/onion.h"
#include "feature/nodelist/networkstatus.h"
#include "core/or/or_circuit_st.h"

Go to the source code of this file.

Data Structures

struct  onion_queue_t


#define MAX_NUM_NTORS_PER_TAP   100000


typedef struct onion_queue_t onion_queue_t


static TOR_TAILQ_HEAD (onion_queue_head_t, onion_queue_t)
static int num_ntors_per_tap (void)
static void onion_queue_entry_remove (onion_queue_t *victim)
static int have_room_for_onionskin (uint16_t type)
int onion_pending_add (or_circuit_t *circ, create_cell_t *onionskin)
static uint16_t decide_next_handshake_type (void)
or_circuit_tonion_next_task (create_cell_t **onionskin_out)
int onion_num_pending (uint16_t handshake_type)
void onion_pending_remove (or_circuit_t *circ)
void clear_pending_onions (void)


static int ol_entries [MAX_ONION_HANDSHAKE_TYPE+1]

Detailed Description

Functions to queue create cells for processing.

Relays invoke these functions when they receive a CREATE or EXTEND cell in command.c or relay.c, in order to queue the pending request. They also invoke them from cpuworker.c, which handles dispatching onionskin requests to different worker threads.

This module also handles:

Definition in file onion_queue.c.

Macro Definition Documentation



5 seconds on the onion queue til we just send back a destroy

Definition at line 50 of file onion_queue.c.

Typedef Documentation

◆ onion_queue_t

typedef struct onion_queue_t onion_queue_t

Type for a linked list of circuits that are waiting for a free CPU worker to process a waiting onion handshake.

Function Documentation

◆ clear_pending_onions()

void clear_pending_onions ( void  )

Remove all circuits from the pending list. Called from tor_free_all.

Definition at line 349 of file onion_queue.c.

◆ decide_next_handshake_type()

static uint16_t decide_next_handshake_type ( void  )

Choose which onion queue we'll pull from next. If one is empty choose the other; if they both have elements, load balance across them but favoring NTOR.

Definition at line 225 of file onion_queue.c.

References ol_entries.

Referenced by onion_next_task().

◆ have_room_for_onionskin()

static int have_room_for_onionskin ( uint16_t  type)

Return true iff we have room to queue another onionskin of type type.

Definition at line 77 of file onion_queue.c.

◆ num_ntors_per_tap()

static int num_ntors_per_tap ( void  )

Return a fairness parameter, to prefer processing NTOR style handshakes but still slowly drain the TAP queue so we don't starve it entirely.

Definition at line 209 of file onion_queue.c.

◆ onion_next_task()

or_circuit_t* onion_next_task ( create_cell_t **  onionskin_out)

Remove the highest priority item from ol_list[] and return it, or return NULL if the lists are empty.

Definition at line 265 of file onion_queue.c.

References decide_next_handshake_type(), and tor_assert().

◆ onion_num_pending()

int onion_num_pending ( uint16_t  handshake_type)

Return the number of handshake_type-style create requests pending.

Definition at line 297 of file onion_queue.c.

References ol_entries.

◆ onion_pending_add()

int onion_pending_add ( or_circuit_t circ,
create_cell_t onionskin 

Add circ to the end of ol_list and return 0, except if ol_list is too long, in which case do nothing and return -1.

Definition at line 140 of file onion_queue.c.

References create_cell_t::handshake_type.

◆ onion_pending_remove()

void onion_pending_remove ( or_circuit_t circ)

Go through ol_list, find the onion_queue_t element which points to circ, remove and free that element. Leave circ itself alone.

Definition at line 306 of file onion_queue.c.

References cpuworker_cancel_circ_handshake(), onion_queue_entry_remove(), and or_circuit_t::onionqueue_entry.

Referenced by circuit_about_to_free().

◆ onion_queue_entry_remove()

static void onion_queue_entry_remove ( onion_queue_t victim)

Remove a queue entry victim from the queue, unlinking it from its circuit and freeing it and any structures it owns.

Definition at line 323 of file onion_queue.c.

Referenced by onion_pending_remove().


static TOR_TAILQ_HEAD ( onion_queue_head_t  ,

Array of queues of circuits waiting for CPU workers. An element is NULL if that queue is empty.

Definition at line 54 of file onion_queue.c.

Variable Documentation

◆ ol_entries

int ol_entries[MAX_ONION_HANDSHAKE_TYPE+1]

Number of entries of each type currently in each element of ol_list[].

Definition at line 59 of file onion_queue.c.

Referenced by decide_next_handshake_type(), and onion_num_pending().