Data Structures | Macros | Typedefs | Functions | Variables
onion_queue.c File Reference

Functions to queue create cells for processing. More...

#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_head_t onion_queue_head_t


 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 onion_queue_head_t ol_list [MAX_ONION_HANDSHAKE_TYPE+1]
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.

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 353 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 229 of file onion_queue.c.

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 79 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 211 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 269 of file onion_queue.c.

◆ onion_num_pending()

int onion_num_pending ( uint16_t  handshake_type)

Return the number of handshake_type-style create requests pending.

Definition at line 301 of file onion_queue.c.

◆ 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 142 of file onion_queue.c.

◆ 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 310 of file onion_queue.c.

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 327 of file onion_queue.c.

Referenced by onion_pending_remove().

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 64 of file onion_queue.c.

Referenced by decide_next_handshake_type(), and onion_num_pending().

◆ ol_list

onion_queue_head_t ol_list[MAX_ONION_HANDSHAKE_TYPE+1]
Initial value:

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

Definition at line 57 of file onion_queue.c.

Referenced by onion_next_task().

static onion_queue_head_t ol_list[MAX_ONION_HANDSHAKE_TYPE+1]
Definition: onion_queue.c:57