diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-01-30 18:24:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-01-30 18:24:13 +0000 |
commit | 6fd0a7efde08115b568b99b7755861a50f1b6c2e (patch) | |
tree | d8d712f0a5cafe18ddf8ff33296ff24b30beae7f /src/core | |
parent | 6a4c5ee6195fb7a6fcf90b1bae5ca36926e82023 (diff) | |
download | gnunet-6fd0a7efde08115b568b99b7755861a50f1b6c2e.tar.gz gnunet-6fd0a7efde08115b568b99b7755861a50f1b6c2e.zip |
towards reviving priorities in core API, this time with enum to make classes clearer
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/core_api.c | 16 | ||||
-rw-r--r-- | src/core/gnunet-service-core.h | 3 | ||||
-rw-r--r-- | src/core/gnunet-service-core_clients.c | 8 | ||||
-rw-r--r-- | src/core/test_core_api.c | 3 | ||||
-rw-r--r-- | src/core/test_core_api_reliability.c | 9 | ||||
-rw-r--r-- | src/core/test_core_quota_compliance.c | 9 |
6 files changed, 27 insertions, 21 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c index c69e3fe1d..56bd29df3 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -71,7 +71,7 @@ struct GNUNET_CORE_TransmitHandle | |||
71 | /** | 71 | /** |
72 | * How important is this message? | 72 | * How important is this message? |
73 | */ | 73 | */ |
74 | uint32_t priority; | 74 | enum GNUNET_CORE_Priority priority; |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Size of this request. | 77 | * Size of this request. |
@@ -517,7 +517,7 @@ request_next_transmission (struct PeerRecord *pr) | |||
517 | smr = (struct SendMessageRequest *) &cm[1]; | 517 | smr = (struct SendMessageRequest *) &cm[1]; |
518 | smr->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST); | 518 | smr->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST); |
519 | smr->header.size = htons (sizeof (struct SendMessageRequest)); | 519 | smr->header.size = htons (sizeof (struct SendMessageRequest)); |
520 | smr->priority = htonl (th->priority); | 520 | smr->priority = htonl ((uint32_t) th->priority); |
521 | smr->deadline = GNUNET_TIME_absolute_hton (th->timeout); | 521 | smr->deadline = GNUNET_TIME_absolute_hton (th->timeout); |
522 | smr->peer = pr->peer; | 522 | smr->peer = pr->peer; |
523 | smr->reserved = htonl (0); | 523 | smr->reserved = htonl (0); |
@@ -653,7 +653,7 @@ transmit_message (void *cls, size_t size, void *buf) | |||
653 | GNUNET_i2s (&pr->peer), (unsigned int) th->msize); | 653 | GNUNET_i2s (&pr->peer), (unsigned int) th->msize); |
654 | sm = (struct SendMessage *) buf; | 654 | sm = (struct SendMessage *) buf; |
655 | sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND); | 655 | sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND); |
656 | sm->priority = htonl (th->priority); | 656 | sm->priority = htonl ((uint32_t) th->priority); |
657 | sm->deadline = GNUNET_TIME_absolute_hton (th->timeout); | 657 | sm->deadline = GNUNET_TIME_absolute_hton (th->timeout); |
658 | sm->peer = pr->peer; | 658 | sm->peer = pr->peer; |
659 | sm->cork = htonl ((uint32_t) th->cork); | 659 | sm->cork = htonl ((uint32_t) th->cork); |
@@ -1187,7 +1187,7 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1187 | 1187 | ||
1188 | /** | 1188 | /** |
1189 | * Disconnect from the core service. This function can only | 1189 | * Disconnect from the core service. This function can only |
1190 | * be called *after* all pending 'GNUNET_CORE_notify_transmit_ready' | 1190 | * be called *after* all pending #GNUNET_CORE_notify_transmit_ready() |
1191 | * requests have been explicitly canceled. | 1191 | * requests have been explicitly canceled. |
1192 | * | 1192 | * |
1193 | * @param handle connection to core to disconnect | 1193 | * @param handle connection to core to disconnect |
@@ -1279,7 +1279,7 @@ run_request_next_transmission (void *cls, | |||
1279 | */ | 1279 | */ |
1280 | struct GNUNET_CORE_TransmitHandle * | 1280 | struct GNUNET_CORE_TransmitHandle * |
1281 | GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork, | 1281 | GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork, |
1282 | uint32_t priority, | 1282 | enum GNUNET_CORE_Priority priority, |
1283 | struct GNUNET_TIME_Relative maxdelay, | 1283 | struct GNUNET_TIME_Relative maxdelay, |
1284 | const struct GNUNET_PeerIdentity *target, | 1284 | const struct GNUNET_PeerIdentity *target, |
1285 | size_t notify_size, | 1285 | size_t notify_size, |
@@ -1289,9 +1289,6 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork, | |||
1289 | struct PeerRecord *pr; | 1289 | struct PeerRecord *pr; |
1290 | struct GNUNET_CORE_TransmitHandle *th; | 1290 | struct GNUNET_CORE_TransmitHandle *th; |
1291 | 1291 | ||
1292 | GNUNET_assert (NULL != handle); | ||
1293 | GNUNET_assert (NULL != target); | ||
1294 | |||
1295 | if (notify_size > GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE) | 1292 | if (notify_size > GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE) |
1296 | { | 1293 | { |
1297 | GNUNET_break (0); | 1294 | GNUNET_break (0); |
@@ -1329,7 +1326,8 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork, | |||
1329 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pr->ntr_task); | 1326 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pr->ntr_task); |
1330 | pr->ntr_task = | 1327 | pr->ntr_task = |
1331 | GNUNET_SCHEDULER_add_now (&run_request_next_transmission, pr); | 1328 | GNUNET_SCHEDULER_add_now (&run_request_next_transmission, pr); |
1332 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmission request added to queue\n"); | 1329 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1330 | "Transmission request added to queue\n"); | ||
1333 | return th; | 1331 | return th; |
1334 | } | 1332 | } |
1335 | 1333 | ||
diff --git a/src/core/gnunet-service-core.h b/src/core/gnunet-service-core.h index e48ad8bad..8d3e8ee2a 100644 --- a/src/core/gnunet-service-core.h +++ b/src/core/gnunet-service-core.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define GNUNET_SERVICE_CORE_H | 27 | #define GNUNET_SERVICE_CORE_H |
28 | 28 | ||
29 | #include "gnunet_statistics_service.h" | 29 | #include "gnunet_statistics_service.h" |
30 | #include "gnunet_core_service.h" | ||
30 | #include "core.h" | 31 | #include "core.h" |
31 | 32 | ||
32 | /** | 33 | /** |
@@ -73,7 +74,7 @@ struct GSC_ClientActiveRequest | |||
73 | /** | 74 | /** |
74 | * How important is this request. | 75 | * How important is this request. |
75 | */ | 76 | */ |
76 | uint32_t priority; | 77 | enum GNUNET_CORE_Priority priority; |
77 | 78 | ||
78 | /** | 79 | /** |
79 | * Has this request been solicited yet? | 80 | * Has this request been solicited yet? |
diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c index f6574b7f9..f153ac397 100644 --- a/src/core/gnunet-service-core_clients.c +++ b/src/core/gnunet-service-core_clients.c | |||
@@ -374,7 +374,7 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
374 | } | 374 | } |
375 | 375 | ||
376 | car = GNUNET_CONTAINER_multipeermap_get (c->requests, &req->peer); | 376 | car = GNUNET_CONTAINER_multipeermap_get (c->requests, &req->peer); |
377 | if (car == NULL) | 377 | if (NULL == car) |
378 | { | 378 | { |
379 | /* create new entry */ | 379 | /* create new entry */ |
380 | car = GNUNET_new (struct GSC_ClientActiveRequest); | 380 | car = GNUNET_new (struct GSC_ClientActiveRequest); |
@@ -391,7 +391,7 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
391 | } | 391 | } |
392 | car->target = req->peer; | 392 | car->target = req->peer; |
393 | car->deadline = GNUNET_TIME_absolute_ntoh (req->deadline); | 393 | car->deadline = GNUNET_TIME_absolute_ntoh (req->deadline); |
394 | car->priority = ntohl (req->priority); | 394 | car->priority = (enum GNUNET_CORE_Priority) ntohl (req->priority); |
395 | car->msize = ntohs (req->size); | 395 | car->msize = ntohs (req->size); |
396 | car->smr_id = req->smr_id; | 396 | car->smr_id = req->smr_id; |
397 | car->was_solicited = GNUNET_NO; | 397 | car->was_solicited = GNUNET_NO; |
@@ -503,7 +503,7 @@ handle_client_send (void *cls, struct GNUNET_SERVER_Client *client, | |||
503 | * or other CLIENT (for loopback). | 503 | * or other CLIENT (for loopback). |
504 | * | 504 | * |
505 | * @param cls closure | 505 | * @param cls closure |
506 | * @param client reservation request ('struct GSC_ClientActiveRequest') | 506 | * @param client reservation request (`struct GSC_ClientActiveRequest`) |
507 | * @param message the actual message | 507 | * @param message the actual message |
508 | */ | 508 | */ |
509 | static int | 509 | static int |
@@ -560,7 +560,7 @@ client_tokenizer_callback (void *cls, void *client, | |||
560 | * | 560 | * |
561 | * @param cls NULL | 561 | * @param cls NULL |
562 | * @param key identity of peer for which this is an active request | 562 | * @param key identity of peer for which this is an active request |
563 | * @param value the 'struct GSC_ClientActiveRequest' to free | 563 | * @param value the `struct GSC_ClientActiveRequest` to free |
564 | * @return #GNUNET_YES (continue iteration) | 564 | * @return #GNUNET_YES (continue iteration) |
565 | */ | 565 | */ |
566 | static int | 566 | static int |
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index af2b98e41..b3674fdec 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c | |||
@@ -174,7 +174,8 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
174 | "Asking core (1) for transmission to peer `%4s'\n", | 174 | "Asking core (1) for transmission to peer `%4s'\n", |
175 | GNUNET_i2s (&p2.id)); | 175 | GNUNET_i2s (&p2.id)); |
176 | if (NULL == | 176 | if (NULL == |
177 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_YES, 0, | 177 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_YES, |
178 | GNUNET_CORE_PRIO_BEST_EFFORT, | ||
178 | GNUNET_TIME_relative_multiply | 179 | GNUNET_TIME_relative_multiply |
179 | (GNUNET_TIME_UNIT_SECONDS, 145), | 180 | (GNUNET_TIME_UNIT_SECONDS, 145), |
180 | &p2.id, | 181 | &p2.id, |
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index 97006fe95..cb05fa9e5 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c | |||
@@ -189,7 +189,8 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
189 | { | 189 | { |
190 | if (p1.ch != NULL) | 190 | if (p1.ch != NULL) |
191 | GNUNET_break (NULL != | 191 | GNUNET_break (NULL != |
192 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, | 192 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, |
193 | GNUNET_CORE_PRIO_BEST_EFFORT, | ||
193 | FAST_TIMEOUT, &p2.id, | 194 | FAST_TIMEOUT, &p2.id, |
194 | get_size (tr_n), | 195 | get_size (tr_n), |
195 | &transmit_ready, &p1)); | 196 | &transmit_ready, &p1)); |
@@ -250,7 +251,8 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
250 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); | 251 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); |
251 | start_time = GNUNET_TIME_absolute_get (); | 252 | start_time = GNUNET_TIME_absolute_get (); |
252 | GNUNET_break (NULL != | 253 | GNUNET_break (NULL != |
253 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, | 254 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, |
255 | GNUNET_CORE_PRIO_BEST_EFFORT, | ||
254 | TIMEOUT, &p2.id, | 256 | TIMEOUT, &p2.id, |
255 | get_size (0), | 257 | get_size (0), |
256 | &transmit_ready, &p1)); | 258 | &transmit_ready, &p1)); |
@@ -340,7 +342,8 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
340 | { | 342 | { |
341 | if (n == tr_n) | 343 | if (n == tr_n) |
342 | GNUNET_break (NULL != | 344 | GNUNET_break (NULL != |
343 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, | 345 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, |
346 | GNUNET_CORE_PRIO_BEST_EFFORT, | ||
344 | FAST_TIMEOUT, &p2.id, | 347 | FAST_TIMEOUT, &p2.id, |
345 | get_size (tr_n), | 348 | get_size (tr_n), |
346 | &transmit_ready, &p1)); | 349 | &transmit_ready, &p1)); |
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index 91ba1d621..0e74fbef5 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c | |||
@@ -325,7 +325,8 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
325 | if ((p1.ch != NULL) && (p1.connect_status == 1)) | 325 | if ((p1.ch != NULL) && (p1.connect_status == 1)) |
326 | GNUNET_break (NULL != | 326 | GNUNET_break (NULL != |
327 | (p1.nth = | 327 | (p1.nth = |
328 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, | 328 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, |
329 | GNUNET_CORE_PRIO_BEST_EFFORT, | ||
329 | FAST_TIMEOUT, &p2.id, | 330 | FAST_TIMEOUT, &p2.id, |
330 | MESSAGESIZE, | 331 | MESSAGESIZE, |
331 | &transmit_ready, &p1))); | 332 | &transmit_ready, &p1))); |
@@ -392,7 +393,8 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
392 | 393 | ||
393 | GNUNET_break (NULL != | 394 | GNUNET_break (NULL != |
394 | (p1.nth = | 395 | (p1.nth = |
395 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, | 396 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, |
397 | GNUNET_CORE_PRIO_BEST_EFFORT, | ||
396 | TIMEOUT, &p2.id, | 398 | TIMEOUT, &p2.id, |
397 | MESSAGESIZE, | 399 | MESSAGESIZE, |
398 | &transmit_ready, &p1))); | 400 | &transmit_ready, &p1))); |
@@ -488,7 +490,8 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
488 | 490 | ||
489 | if (running == GNUNET_YES) | 491 | if (running == GNUNET_YES) |
490 | GNUNET_break (NULL != | 492 | GNUNET_break (NULL != |
491 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, | 493 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, |
494 | GNUNET_CORE_PRIO_BEST_EFFORT, | ||
492 | FAST_TIMEOUT, &p2.id, | 495 | FAST_TIMEOUT, &p2.id, |
493 | MESSAGESIZE, | 496 | MESSAGESIZE, |
494 | &transmit_ready, &p1)); | 497 | &transmit_ready, &p1)); |