aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/stats/functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/stats/functions.c')
-rw-r--r--src/plugins/stats/functions.c268
1 files changed, 134 insertions, 134 deletions
diff --git a/src/plugins/stats/functions.c b/src/plugins/stats/functions.c
index 9c5e90db..f3f8bee9 100644
--- a/src/plugins/stats/functions.c
+++ b/src/plugins/stats/functions.c
@@ -27,15 +27,15 @@
27#include <GNUnet/gnunet_protocols.h> 27#include <GNUnet/gnunet_protocols.h>
28#include "functions.h" 28#include "functions.h"
29 29
30#define FUNCTIONS_DEBUG NO 30#define FUNCTIONS_DEBUG GNUNET_NO
31 31
32static StatPair *lastStatValues; 32static StatPair *lastStatValues;
33 33
34static unsigned int lsv_size; 34static unsigned int lsv_size;
35 35
36static struct ClientServerConnection *sock; 36static struct GNUNET_ClientServerConnection *sock;
37 37
38static struct MUTEX *lock; 38static struct GNUNET_Mutex *lock;
39 39
40static long connectionGoal; 40static long connectionGoal;
41 41
@@ -47,12 +47,12 @@ static struct GE_Context *ectx;
47 47
48static struct GC_Configuration *cfg; 48static struct GC_Configuration *cfg;
49 49
50static struct CronManager *cron; 50static struct GNUNET_CronManager *cron;
51 51
52static int 52static int
53getStatValue (long long *value, 53getStatValue (long long *value,
54 long long *lvalue, 54 long long *lvalue,
55 cron_t * dtime, const char *optName, int monotone) 55 GNUNET_CronTime * dtime, const char *optName, int monotone)
56{ 56{
57 unsigned int i; 57 unsigned int i;
58 58
@@ -68,9 +68,9 @@ getStatValue (long long *value,
68 *lvalue = lastStatValues[i].lvalue; 68 *lvalue = lastStatValues[i].lvalue;
69 if (dtime != NULL) 69 if (dtime != NULL)
70 *dtime = lastStatValues[i].delta; 70 *dtime = lastStatValues[i].delta;
71 if ((monotone == YES) && (lvalue != NULL) && (*lvalue > *value)) 71 if ((monotone == GNUNET_YES) && (lvalue != NULL) && (*lvalue > *value))
72 return SYSERR; /* gnunetd restart? */ 72 return GNUNET_SYSERR; /* gnunetd restart? */
73 return OK; 73 return GNUNET_OK;
74 } 74 }
75 } 75 }
76#if FUNCTIONS_DEBUG 76#if FUNCTIONS_DEBUG
@@ -78,7 +78,7 @@ getStatValue (long long *value,
78 GE_DEBUG | GE_DEVELOPER | GE_REQUEST, 78 GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
79 "Statistic not found: `%s'\n", optName); 79 "Statistic not found: `%s'\n", optName);
80#endif 80#endif
81 return SYSERR; 81 return GNUNET_SYSERR;
82} 82}
83 83
84static void 84static void
@@ -88,13 +88,13 @@ updateConnectionGoal (void *unused)
88 char *availableDown; 88 char *availableDown;
89 char *availableUp; 89 char *availableUp;
90 90
91 MUTEX_LOCK (lock); 91 GNUNET_mutex_lock (lock);
92 cmh = getConfigurationOptionValue (sock, "gnunetd", "connection-max-hosts"); 92 cmh = GNUNET_get_daemon_configuration_value (sock, "gnunetd", "connection-max-hosts");
93 availableDown = getConfigurationOptionValue (sock, 93 availableDown = GNUNET_get_daemon_configuration_value (sock,
94 "LOAD", "MAXNETDOWNBPSTOTAL"); 94 "LOAD", "MAXNETDOWNBPSTOTAL");
95 availableUp = getConfigurationOptionValue (sock, 95 availableUp = GNUNET_get_daemon_configuration_value (sock,
96 "LOAD", "MAXNETUPBPSTOTAL"); 96 "LOAD", "MAXNETUPBPSTOTAL");
97 MUTEX_UNLOCK (lock); 97 GNUNET_mutex_unlock (lock);
98 if (cmh == NULL) 98 if (cmh == NULL)
99 connectionGoal = 0; 99 connectionGoal = 0;
100 else 100 else
@@ -108,9 +108,9 @@ updateConnectionGoal (void *unused)
108 else 108 else
109 bandup = atol (availableUp); 109 bandup = atol (availableUp);
110 110
111 FREENONNULL (cmh); 111 GNUNET_free_non_null (cmh);
112 FREENONNULL (availableDown); 112 GNUNET_free_non_null (availableDown);
113 FREENONNULL (availableUp); 113 GNUNET_free_non_null (availableUp);
114} 114}
115 115
116static int 116static int
@@ -119,11 +119,11 @@ getConnectedNodesStat (const void *closure, gfloat ** data)
119 long long val; 119 long long val;
120 120
121 if (connectionGoal == 0) 121 if (connectionGoal == 0)
122 return SYSERR; 122 return GNUNET_SYSERR;
123 if (OK != getStatValue (&val, NULL, NULL, "# of connected peers", NO)) 123 if (GNUNET_OK != getStatValue (&val, NULL, NULL, "# of connected peers", GNUNET_NO))
124 return SYSERR; 124 return GNUNET_SYSERR;
125 data[0][0] = ((gfloat) val) / connectionGoal; 125 data[0][0] = ((gfloat) val) / connectionGoal;
126 return OK; 126 return GNUNET_OK;
127} 127}
128 128
129static int 129static int
@@ -134,21 +134,21 @@ getLoadStat (const void *closure, gfloat ** data)
134 long long valu; 134 long long valu;
135 long long vald; 135 long long vald;
136 136
137 if (OK != getStatValue (&valc, NULL, NULL, "% of allowed cpu load", NO)) 137 if (GNUNET_OK != getStatValue (&valc, NULL, NULL, "% of allowed cpu load", GNUNET_NO))
138 return SYSERR; 138 return GNUNET_SYSERR;
139 if (OK != getStatValue (&vali, NULL, NULL, "% of allowed io load", NO)) 139 if (GNUNET_OK != getStatValue (&vali, NULL, NULL, "% of allowed io load", GNUNET_NO))
140 return SYSERR; 140 return GNUNET_SYSERR;
141 if (OK != getStatValue (&valu, 141 if (GNUNET_OK != getStatValue (&valu,
142 NULL, NULL, "% of allowed network load (up)", NO)) 142 NULL, NULL, "% of allowed network load (up)", GNUNET_NO))
143 return SYSERR; 143 return GNUNET_SYSERR;
144 if (OK != getStatValue (&vald, 144 if (GNUNET_OK != getStatValue (&vald,
145 NULL, NULL, "% of allowed network load (down)", NO)) 145 NULL, NULL, "% of allowed network load (down)", GNUNET_NO))
146 return SYSERR; 146 return GNUNET_SYSERR;
147 data[0][0] = (gfloat) valc / 100.0; 147 data[0][0] = (gfloat) valc / 100.0;
148 data[0][1] = (gfloat) vali / 100.0; 148 data[0][1] = (gfloat) vali / 100.0;
149 data[0][2] = (gfloat) valu / 100.0; 149 data[0][2] = (gfloat) valu / 100.0;
150 data[0][3] = (gfloat) vald / 100.0; 150 data[0][3] = (gfloat) vald / 100.0;
151 return OK; 151 return GNUNET_OK;
152} 152}
153 153
154static int 154static int
@@ -157,15 +157,15 @@ getQuotaStat (const void *closure, gfloat ** data)
157 long long allowed; 157 long long allowed;
158 long long have; 158 long long have;
159 159
160 if (OK != getStatValue (&allowed, 160 if (GNUNET_OK != getStatValue (&allowed,
161 NULL, NULL, "# bytes allowed in datastore", NO)) 161 NULL, NULL, "# bytes allowed in datastore", GNUNET_NO))
162 return SYSERR; 162 return GNUNET_SYSERR;
163 if (allowed == 0) 163 if (allowed == 0)
164 return SYSERR; 164 return GNUNET_SYSERR;
165 if (OK != getStatValue (&have, NULL, NULL, "# bytes in datastore", NO)) 165 if (GNUNET_OK != getStatValue (&have, NULL, NULL, "# bytes in datastore", GNUNET_NO))
166 return SYSERR; 166 return GNUNET_SYSERR;
167 data[0][0] = ((gfloat) have) / allowed; 167 data[0][0] = ((gfloat) have) / allowed;
168 return OK; 168 return GNUNET_OK;
169} 169}
170 170
171static int 171static int
@@ -183,43 +183,43 @@ getTrafficRecvStats (const void *closure, gfloat ** data)
183 long long lqueries; 183 long long lqueries;
184 long long lhellos; 184 long long lhellos;
185 long long lrlimit; 185 long long lrlimit;
186 cron_t dtime; 186 GNUNET_CronTime dtime;
187 char *buffer; 187 char *buffer;
188 188
189 if (OK != getStatValue (&total, &ltotal, &dtime, "# bytes received", YES)) 189 if (GNUNET_OK != getStatValue (&total, &ltotal, &dtime, "# bytes received", GNUNET_YES))
190 return SYSERR; 190 return GNUNET_SYSERR;
191 if (OK != getStatValue (&noise, 191 if (GNUNET_OK != getStatValue (&noise,
192 &lnoise, NULL, "# bytes of noise received", YES)) 192 &lnoise, NULL, "# bytes of noise received", GNUNET_YES))
193 return SYSERR; 193 return GNUNET_SYSERR;
194 buffer = MALLOC (512); 194 buffer = GNUNET_malloc (512);
195 SNPRINTF (buffer, 512, "# bytes received of type %d", P2P_PROTO_gap_RESULT); 195 GNUNET_snprintf (buffer, 512, "# bytes received of type %d", P2P_PROTO_gap_RESULT);
196 if (OK != getStatValue (&content, &lcontent, NULL, buffer, YES)) 196 if (GNUNET_OK != getStatValue (&content, &lcontent, NULL, buffer, GNUNET_YES))
197 { 197 {
198 content = 0; 198 content = 0;
199 lcontent = 0; 199 lcontent = 0;
200 } 200 }
201 SNPRINTF (buffer, 512, "# bytes received of type %d", p2p_PROTO_hello); 201 GNUNET_snprintf (buffer, 512, "# bytes received of type %d", p2p_PROTO_hello);
202 if (OK != getStatValue (&hellos, &lhellos, NULL, buffer, YES)) 202 if (GNUNET_OK != getStatValue (&hellos, &lhellos, NULL, buffer, GNUNET_YES))
203 { 203 {
204 hellos = 0; 204 hellos = 0;
205 lhellos = 0; 205 lhellos = 0;
206 } 206 }
207 SNPRINTF (buffer, 512, "# bytes received of type %d", P2P_PROTO_gap_QUERY); 207 GNUNET_snprintf (buffer, 512, "# bytes received of type %d", P2P_PROTO_gap_QUERY);
208 if (OK != getStatValue (&queries, &lqueries, NULL, buffer, YES)) 208 if (GNUNET_OK != getStatValue (&queries, &lqueries, NULL, buffer, GNUNET_YES))
209 { 209 {
210 queries = 0; 210 queries = 0;
211 lqueries = 0; 211 lqueries = 0;
212 } 212 }
213 if (OK != getStatValue (&rlimit, 213 if (GNUNET_OK != getStatValue (&rlimit,
214 &lrlimit, 214 &lrlimit,
215 NULL, "# total bytes per second receive limit", NO)) 215 NULL, "# total bytes per second receive limit", GNUNET_NO))
216 { 216 {
217 rlimit = 0; 217 rlimit = 0;
218 lrlimit = 0; 218 lrlimit = 0;
219 } 219 }
220 FREE (buffer); 220 GNUNET_free (buffer);
221 if (banddown == 0) 221 if (banddown == 0)
222 return SYSERR; 222 return GNUNET_SYSERR;
223 223
224 total -= ltotal; 224 total -= ltotal;
225 noise -= lnoise; 225 noise -= lnoise;
@@ -234,18 +234,18 @@ getTrafficRecvStats (const void *closure, gfloat ** data)
234 data[0][3] = 0.0; 234 data[0][3] = 0.0;
235 data[0][4] = 0.0; 235 data[0][4] = 0.0;
236 data[0][5] = 0.0; 236 data[0][5] = 0.0;
237 return OK; 237 return GNUNET_OK;
238 } 238 }
239 data[0][0] = ((gfloat) noise) / (banddown * dtime / cronSECONDS); /* red */ 239 data[0][0] = ((gfloat) noise) / (banddown * dtime / GNUNET_CRON_SECONDS); /* red */
240 data[0][1] = ((gfloat) (content + noise)) / (banddown * dtime / cronSECONDS); /* green */ 240 data[0][1] = ((gfloat) (content + noise)) / (banddown * dtime / GNUNET_CRON_SECONDS); /* green */
241 data[0][2] = ((gfloat) (queries + content + noise)) / (banddown * dtime / cronSECONDS); /* yellow */ 241 data[0][2] = ((gfloat) (queries + content + noise)) / (banddown * dtime / GNUNET_CRON_SECONDS); /* yellow */
242 data[0][3] = ((gfloat) (queries + content + noise + hellos)) / (banddown * dtime / cronSECONDS); /* blue */ 242 data[0][3] = ((gfloat) (queries + content + noise + hellos)) / (banddown * dtime / GNUNET_CRON_SECONDS); /* blue */
243 data[0][4] = ((gfloat) total) / (banddown * dtime / cronSECONDS); /* gray */ 243 data[0][4] = ((gfloat) total) / (banddown * dtime / GNUNET_CRON_SECONDS); /* gray */
244 data[0][5] = (gfloat) rlimit / banddown; /* magenta */ 244 data[0][5] = (gfloat) rlimit / banddown; /* magenta */
245#if 0 245#if 0
246 printf ("I: %f %f %f %f\n", data[0][0], data[0][1], data[0][2]); 246 printf ("I: %f %f %f %f\n", data[0][0], data[0][1], data[0][2]);
247#endif 247#endif
248 return OK; 248 return GNUNET_OK;
249} 249}
250 250
251static int 251static int
@@ -263,45 +263,45 @@ getTrafficSendStats (const void *closure, gfloat ** data)
263 long long lqueries; 263 long long lqueries;
264 long long lhellos; 264 long long lhellos;
265 long long lslimit; 265 long long lslimit;
266 cron_t dtime; 266 GNUNET_CronTime dtime;
267 char *buffer; 267 char *buffer;
268 268
269 if (OK != getStatValue (&total, 269 if (GNUNET_OK != getStatValue (&total,
270 &ltotal, &dtime, "# bytes transmitted", YES)) 270 &ltotal, &dtime, "# bytes transmitted", GNUNET_YES))
271 return SYSERR; 271 return GNUNET_SYSERR;
272 if (OK != getStatValue (&noise, &lnoise, NULL, "# bytes noise sent", YES)) 272 if (GNUNET_OK != getStatValue (&noise, &lnoise, NULL, "# bytes noise sent", GNUNET_YES))
273 return SYSERR; 273 return GNUNET_SYSERR;
274 buffer = MALLOC (512); 274 buffer = GNUNET_malloc (512);
275 SNPRINTF (buffer, 275 GNUNET_snprintf (buffer,
276 512, "# bytes transmitted of type %d", P2P_PROTO_gap_RESULT); 276 512, "# bytes transmitted of type %d", P2P_PROTO_gap_RESULT);
277 if (OK != getStatValue (&content, &lcontent, NULL, buffer, YES)) 277 if (GNUNET_OK != getStatValue (&content, &lcontent, NULL, buffer, GNUNET_YES))
278 { 278 {
279 content = 0; 279 content = 0;
280 lcontent = 0; 280 lcontent = 0;
281 } 281 }
282 SNPRINTF (buffer, 282 GNUNET_snprintf (buffer,
283 512, "# bytes transmitted of type %d", P2P_PROTO_gap_QUERY); 283 512, "# bytes transmitted of type %d", P2P_PROTO_gap_QUERY);
284 if (OK != getStatValue (&queries, &lqueries, NULL, buffer, YES)) 284 if (GNUNET_OK != getStatValue (&queries, &lqueries, NULL, buffer, GNUNET_YES))
285 { 285 {
286 queries = 0; 286 queries = 0;
287 lqueries = 0; 287 lqueries = 0;
288 } 288 }
289 SNPRINTF (buffer, 512, "# bytes transmitted of type %d", p2p_PROTO_hello); 289 GNUNET_snprintf (buffer, 512, "# bytes transmitted of type %d", p2p_PROTO_hello);
290 if (OK != getStatValue (&hellos, &lhellos, NULL, buffer, YES)) 290 if (GNUNET_OK != getStatValue (&hellos, &lhellos, NULL, buffer, GNUNET_YES))
291 { 291 {
292 queries = 0; 292 queries = 0;
293 lqueries = 0; 293 lqueries = 0;
294 } 294 }
295 if (OK != getStatValue (&slimit, 295 if (GNUNET_OK != getStatValue (&slimit,
296 &lslimit, 296 &lslimit,
297 NULL, "# total bytes per second send limit", NO)) 297 NULL, "# total bytes per second send limit", GNUNET_NO))
298 { 298 {
299 slimit = 0; 299 slimit = 0;
300 lslimit = 0; 300 lslimit = 0;
301 } 301 }
302 FREE (buffer); 302 GNUNET_free (buffer);
303 if (bandup == 0) 303 if (bandup == 0)
304 return SYSERR; 304 return GNUNET_SYSERR;
305 total -= ltotal; 305 total -= ltotal;
306 noise -= lnoise; 306 noise -= lnoise;
307 queries -= lqueries; 307 queries -= lqueries;
@@ -315,25 +315,25 @@ getTrafficSendStats (const void *closure, gfloat ** data)
315 data[0][3] = 0.0; 315 data[0][3] = 0.0;
316 data[0][4] = 0.0; 316 data[0][4] = 0.0;
317 data[0][5] = 0.0; 317 data[0][5] = 0.0;
318 return OK; 318 return GNUNET_OK;
319 } 319 }
320 data[0][0] = ((gfloat) noise) / (bandup * dtime / cronSECONDS); /* red */ 320 data[0][0] = ((gfloat) noise) / (bandup * dtime / GNUNET_CRON_SECONDS); /* red */
321 data[0][1] = ((gfloat) (noise + content)) / (bandup * dtime / cronSECONDS); /* green */ 321 data[0][1] = ((gfloat) (noise + content)) / (bandup * dtime / GNUNET_CRON_SECONDS); /* green */
322 data[0][2] = ((gfloat) (noise + content + queries)) / (bandup * dtime / cronSECONDS); /* yellow */ 322 data[0][2] = ((gfloat) (noise + content + queries)) / (bandup * dtime / GNUNET_CRON_SECONDS); /* yellow */
323 data[0][3] = ((gfloat) (noise + content + queries + hellos)) / (bandup * dtime / cronSECONDS); /* blue */ 323 data[0][3] = ((gfloat) (noise + content + queries + hellos)) / (bandup * dtime / GNUNET_CRON_SECONDS); /* blue */
324 data[0][4] = ((gfloat) total) / (bandup * dtime / cronSECONDS); /* grey */ 324 data[0][4] = ((gfloat) total) / (bandup * dtime / GNUNET_CRON_SECONDS); /* grey */
325 data[0][5] = ((gfloat) slimit) / bandup; /* magenta */ 325 data[0][5] = ((gfloat) slimit) / bandup; /* magenta */
326#if 0 326#if 0
327 printf ("O: %f %f %f %f\n", data[0][0], data[0][1], data[0][2], data[0][3]); 327 printf ("O: %f %f %f %f\n", data[0][0], data[0][1], data[0][2], data[0][3]);
328#endif 328#endif
329 return OK; 329 return GNUNET_OK;
330} 330}
331 331
332 332
333static int 333static int
334getEffectivenessStats (const void *closure, gfloat ** data) 334getEffectivenessStats (const void *closure, gfloat ** data)
335{ 335{
336 static cron_t last; 336 static GNUNET_CronTime last;
337 static double lastdata; 337 static double lastdata;
338 static double lastavg; 338 static double lastavg;
339 long long total; 339 long long total;
@@ -342,31 +342,31 @@ getEffectivenessStats (const void *closure, gfloat ** data)
342 long long ltotal; 342 long long ltotal;
343 long long lsuccess; 343 long long lsuccess;
344 long long llocal; 344 long long llocal;
345 cron_t now; 345 GNUNET_CronTime now;
346 346
347 now = get_time (); 347 now = GNUNET_get_time ();
348 if (now < last + 2 * cronMINUTES) 348 if (now < last + 2 * GNUNET_CRON_MINUTES)
349 { 349 {
350 data[0][0] = lastdata; 350 data[0][0] = lastdata;
351 data[0][1] = lastavg; 351 data[0][1] = lastavg;
352 return OK; 352 return GNUNET_OK;
353 } 353 }
354 last = now; 354 last = now;
355 if (OK != getStatValue (&total, 355 if (GNUNET_OK != getStatValue (&total,
356 &ltotal, 356 &ltotal,
357 NULL, 357 NULL,
358 "# gap requests forwarded (counting each peer)", 358 "# gap requests forwarded (counting each peer)",
359 YES)) 359 GNUNET_YES))
360 return SYSERR; 360 return GNUNET_SYSERR;
361 if (OK != getStatValue (&success, 361 if (GNUNET_OK != getStatValue (&success,
362 &lsuccess, 362 &lsuccess,
363 NULL, "# gap routing successes (total)", YES)) 363 NULL, "# gap routing successes (total)", GNUNET_YES))
364 return SYSERR; 364 return GNUNET_SYSERR;
365 if (OK != getStatValue (&local, 365 if (GNUNET_OK != getStatValue (&local,
366 &llocal, 366 &llocal,
367 NULL, 367 NULL,
368 "# gap requests processed: local result", YES)) 368 "# gap requests processed: local result", GNUNET_YES))
369 return SYSERR; 369 return GNUNET_SYSERR;
370 total -= ltotal; 370 total -= ltotal;
371 data[0][0] = 0.0; 371 data[0][0] = 0.0;
372 if (ltotal + total > 0) 372 if (ltotal + total > 0)
@@ -377,18 +377,18 @@ getEffectivenessStats (const void *closure, gfloat ** data)
377 else 377 else
378 { 378 {
379 data[0][1] = 0.0; 379 data[0][1] = 0.0;
380 return OK; 380 return GNUNET_OK;
381 } 381 }
382 if (total == 0) 382 if (total == 0)
383 return OK; 383 return GNUNET_OK;
384 success -= lsuccess; 384 success -= lsuccess;
385 local -= llocal; 385 local -= llocal;
386 if (success <= local) 386 if (success <= local)
387 return OK; 387 return GNUNET_OK;
388 success -= local; 388 success -= local;
389 lsuccess -= llocal; 389 lsuccess -= llocal;
390 data[0][0] = lastdata = 1.0 * success / total; 390 data[0][0] = lastdata = 1.0 * success / total;
391 return OK; 391 return GNUNET_OK;
392} 392}
393 393
394static int 394static int
@@ -401,7 +401,7 @@ statsProcessor (const char *optName, unsigned long long value, void *data)
401 * this will predict correctly). 401 * this will predict correctly).
402 */ 402 */
403 static unsigned int last; 403 static unsigned int last;
404 cron_t *delta = data; 404 GNUNET_CronTime *delta = data;
405 int j; 405 int j;
406 int found; 406 int found;
407 407
@@ -425,14 +425,14 @@ statsProcessor (const char *optName, unsigned long long value, void *data)
425 if (found == -1) 425 if (found == -1)
426 { 426 {
427 found = lsv_size; 427 found = lsv_size;
428 GROW (lastStatValues, lsv_size, lsv_size + 1); 428 GNUNET_array_grow (lastStatValues, lsv_size, lsv_size + 1);
429 lastStatValues[found].statName = STRDUP (optName); 429 lastStatValues[found].statName = GNUNET_strdup (optName);
430 } 430 }
431 lastStatValues[found].lvalue = lastStatValues[found].value; 431 lastStatValues[found].lvalue = lastStatValues[found].value;
432 lastStatValues[found].value = value; 432 lastStatValues[found].value = value;
433 lastStatValues[found].delta = *delta; 433 lastStatValues[found].delta = *delta;
434 last = found + 1; 434 last = found + 1;
435 return OK; 435 return GNUNET_OK;
436} 436}
437 437
438/** 438/**
@@ -441,16 +441,16 @@ statsProcessor (const char *optName, unsigned long long value, void *data)
441static void 441static void
442updateStatValues (void *unused) 442updateStatValues (void *unused)
443{ 443{
444 static cron_t lastUpdate; 444 static GNUNET_CronTime lastUpdate;
445 cron_t now; 445 GNUNET_CronTime now;
446 cron_t delta; 446 GNUNET_CronTime delta;
447 447
448 now = get_time (); 448 now = GNUNET_get_time ();
449 delta = now - lastUpdate; 449 delta = now - lastUpdate;
450 MUTEX_LOCK (lock); 450 GNUNET_mutex_lock (lock);
451 if (OK == STATS_getStatistics (ectx, sock, &statsProcessor, &delta)) 451 if (GNUNET_OK == STATS_getStatistics (ectx, sock, &statsProcessor, &delta))
452 lastUpdate = now; 452 lastUpdate = now;
453 MUTEX_UNLOCK (lock); 453 GNUNET_mutex_unlock (lock);
454} 454}
455 455
456 456
@@ -461,7 +461,7 @@ StatEntry stats[] = {
461 &getConnectedNodesStat, 461 &getConnectedNodesStat,
462 NULL, 462 NULL,
463 1, 463 1,
464 NO, 464 GNUNET_NO,
465 } 465 }
466 , 466 ,
467 { 467 {
@@ -471,7 +471,7 @@ StatEntry stats[] = {
471 &getLoadStat, 471 &getLoadStat,
472 NULL, 472 NULL,
473 4, 473 4,
474 NO, 474 GNUNET_NO,
475 } 475 }
476 , 476 ,
477 { 477 {
@@ -480,7 +480,7 @@ StatEntry stats[] = {
480 &getQuotaStat, 480 &getQuotaStat,
481 NULL, 481 NULL,
482 1, 482 1,
483 NO, 483 GNUNET_NO,
484 } 484 }
485 , 485 ,
486 { 486 {
@@ -510,7 +510,7 @@ StatEntry stats[] = {
510 &getEffectivenessStats, 510 &getEffectivenessStats,
511 NULL, 511 NULL,
512 2, 512 2,
513 NO, 513 GNUNET_NO,
514 } 514 }
515 , 515 ,
516 { 516 {
@@ -519,7 +519,7 @@ StatEntry stats[] = {
519 NULL, 519 NULL,
520 NULL, 520 NULL,
521 0, 521 0,
522 NO, 522 GNUNET_NO,
523 } 523 }
524 , 524 ,
525}; 525};
@@ -535,16 +535,16 @@ init_functions (struct GE_Context *e, struct GC_Configuration *c)
535 "GNUNET-GTK", 535 "GNUNET-GTK",
536 "STATS-INTERVAL", 536 "STATS-INTERVAL",
537 1, 537 1,
538 99 * cronYEARS, 538 99 * GNUNET_CRON_YEARS,
539 30 * cronSECONDS, &UPDATE_INTERVAL); 539 30 * GNUNET_CRON_SECONDS, &UPDATE_INTERVAL);
540 sock = client_connection_create (ectx, cfg); 540 sock = GNUNET_client_connection_create (ectx, cfg);
541 lock = MUTEX_CREATE (NO); 541 lock = GNUNET_mutex_create (GNUNET_NO);
542 cron = gnunet_gtk_get_cron (); 542 cron = gnunet_gtk_get_cron ();
543 cron_add_job (cron, 543 GNUNET_cron_add_job (cron,
544 &updateStatValues, UPDATE_INTERVAL, UPDATE_INTERVAL, NULL); 544 &updateStatValues, UPDATE_INTERVAL, UPDATE_INTERVAL, NULL);
545 cron_add_job (cron, 545 GNUNET_cron_add_job (cron,
546 &updateConnectionGoal, 546 &updateConnectionGoal,
547 5 * cronMINUTES, 5 * cronMINUTES, NULL); 547 5 * GNUNET_CRON_MINUTES, 5 * GNUNET_CRON_MINUTES, NULL);
548} 548}
549 549
550void 550void
@@ -552,13 +552,13 @@ done_functions ()
552{ 552{
553 int i; 553 int i;
554 554
555 cron_del_job (cron, &updateConnectionGoal, 5 * cronMINUTES, NULL); 555 GNUNET_cron_del_job (cron, &updateConnectionGoal, 5 * GNUNET_CRON_MINUTES, NULL);
556 cron_del_job (cron, &updateStatValues, UPDATE_INTERVAL, NULL); 556 GNUNET_cron_del_job (cron, &updateStatValues, UPDATE_INTERVAL, NULL);
557 MUTEX_DESTROY (lock); 557 GNUNET_mutex_destroy (lock);
558 connection_destroy (sock); 558 GNUNET_client_connection_destroy (sock);
559 for (i = 0; i < lsv_size; i++) 559 for (i = 0; i < lsv_size; i++)
560 FREE (lastStatValues[i].statName); 560 GNUNET_free (lastStatValues[i].statName);
561 GROW (lastStatValues, lsv_size, 0); 561 GNUNET_array_grow (lastStatValues, lsv_size, 0);
562 sock = NULL; 562 sock = NULL;
563} 563}
564 564