diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-30 17:43:00 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-30 17:43:00 +0100 |
commit | c8aa8bdff30b23d8eb7217302468b12613dc1e42 (patch) | |
tree | bcfff20afcf7645a851d24cdb70ae611484c988b /src/cadet | |
parent | 6c4af0398d260316dd2dd2358a02000cbf84ceba (diff) | |
download | gnunet-c8aa8bdff30b23d8eb7217302468b12613dc1e42.tar.gz gnunet-c8aa8bdff30b23d8eb7217302468b12613dc1e42.zip |
putting into place the data structures for a global buffer pool shared across routes
Diffstat (limited to 'src/cadet')
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_core.c | 85 |
1 files changed, 84 insertions, 1 deletions
diff --git a/src/cadet/gnunet-service-cadet-new_core.c b/src/cadet/gnunet-service-cadet-new_core.c index 9cd6055c2..fc81c1a3e 100644 --- a/src/cadet/gnunet-service-cadet-new_core.c +++ b/src/cadet/gnunet-service-cadet-new_core.c | |||
@@ -44,6 +44,47 @@ | |||
44 | 44 | ||
45 | #define LOG(level, ...) GNUNET_log_from(level,"cadet-cor",__VA_ARGS__) | 45 | #define LOG(level, ...) GNUNET_log_from(level,"cadet-cor",__VA_ARGS__) |
46 | 46 | ||
47 | /** | ||
48 | * Information we keep per direction for a route. | ||
49 | */ | ||
50 | struct RouteDirection; | ||
51 | |||
52 | |||
53 | /** | ||
54 | * Set of CadetRoutes that have exactly the same number of messages | ||
55 | * in their buffer. Used so we can efficiently find all of those | ||
56 | * routes that have the current maximum of messages in the buffer (in | ||
57 | * case we have to purge). | ||
58 | */ | ||
59 | struct Rung | ||
60 | { | ||
61 | |||
62 | /** | ||
63 | * Rung of RouteDirections with one more buffer entry each. | ||
64 | */ | ||
65 | struct Rung *next; | ||
66 | |||
67 | /** | ||
68 | * Rung of RouteDirections with one less buffer entry each. | ||
69 | */ | ||
70 | struct Rung *prev; | ||
71 | |||
72 | /** | ||
73 | * DLL of route directions with a number of buffer entries matching this rung. | ||
74 | */ | ||
75 | struct RouteDirection *rd_head; | ||
76 | |||
77 | /** | ||
78 | * DLL of route directions with a number of buffer entries matching this rung. | ||
79 | */ | ||
80 | struct RouteDirection *rd_tail; | ||
81 | |||
82 | /** | ||
83 | * Total number of route directions in this rung. | ||
84 | */ | ||
85 | unsigned int num_routes; | ||
86 | }; | ||
87 | |||
47 | 88 | ||
48 | /** | 89 | /** |
49 | * Number of messages we are willing to buffer per route. | 90 | * Number of messages we are willing to buffer per route. |
@@ -57,6 +98,32 @@ | |||
57 | */ | 98 | */ |
58 | struct RouteDirection | 99 | struct RouteDirection |
59 | { | 100 | { |
101 | |||
102 | /** | ||
103 | * DLL of other route directions within the same `struct Rung`. | ||
104 | */ | ||
105 | struct RouteDirection *prev; | ||
106 | |||
107 | /** | ||
108 | * DLL of other route directions within the same `struct Rung`. | ||
109 | */ | ||
110 | struct RouteDirection *next; | ||
111 | |||
112 | /** | ||
113 | * Rung of this route direction (matches length of the buffer DLL). | ||
114 | */ | ||
115 | struct Rung *rung; | ||
116 | |||
117 | /** | ||
118 | * Head of DLL of envelopes we have in the buffer for this direction. | ||
119 | */ | ||
120 | struct GNUNET_MQ_Envelope *env_head; | ||
121 | |||
122 | /** | ||
123 | * Tail of DLL of envelopes we have in the buffer for this direction. | ||
124 | */ | ||
125 | struct GNUNET_MQ_Envelope *env_tail; | ||
126 | |||
60 | /** | 127 | /** |
61 | * Target peer. | 128 | * Target peer. |
62 | */ | 129 | */ |
@@ -159,6 +226,16 @@ static struct GNUNET_CONTAINER_Heap *route_heap; | |||
159 | static unsigned long long max_routes; | 226 | static unsigned long long max_routes; |
160 | 227 | ||
161 | /** | 228 | /** |
229 | * Maximum number of envelopes we will buffer at this peer. | ||
230 | */ | ||
231 | static unsigned long long max_buffers; | ||
232 | |||
233 | /** | ||
234 | * Current number of envelopes we have buffered at this peer. | ||
235 | */ | ||
236 | static unsigned long long cur_buffers; | ||
237 | |||
238 | /** | ||
162 | * Task to timeout routes. | 239 | * Task to timeout routes. |
163 | */ | 240 | */ |
164 | static struct GNUNET_SCHEDULER_Task *timeout_task; | 241 | static struct GNUNET_SCHEDULER_Task *timeout_task; |
@@ -1079,7 +1156,13 @@ GCO_init (const struct GNUNET_CONFIGURATION_Handle *c) | |||
1079 | "CADET", | 1156 | "CADET", |
1080 | "MAX_ROUTES", | 1157 | "MAX_ROUTES", |
1081 | &max_routes)) | 1158 | &max_routes)) |
1082 | max_routes = 10000; | 1159 | max_routes = 5000; |
1160 | if (GNUNET_OK != | ||
1161 | GNUNET_CONFIGURATION_get_value_number (c, | ||
1162 | "CADET", | ||
1163 | "MAX_MSGS_QUEUE", | ||
1164 | &max_buffers)) | ||
1165 | max_buffers = 10000; | ||
1083 | routes = GNUNET_CONTAINER_multishortmap_create (1024, | 1166 | routes = GNUNET_CONTAINER_multishortmap_create (1024, |
1084 | GNUNET_NO); | 1167 | GNUNET_NO); |
1085 | route_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 1168 | route_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |