GNUnet  0.20.0
gnunet-service-testbed_connectionpool.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2008--2015 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
27 #include "platform.h"
28 #include "gnunet-service-testbed.h"
30 #include "testbed_api_operations.h"
32 
36 #ifdef LOG
37 #undef LOG
38 #endif
39 #define LOG(kind, ...) \
40  GNUNET_log_from (kind, "testbed-connectionpool", __VA_ARGS__)
41 
42 
46 #define CACHE_EXPIRY \
47  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
48 
49 
54 
55 
60 {
66 
72 
77 
82 
87 
92 
97 
102 
109 
115 
120 
125 
131 
137 
142 
147 
151  unsigned int demand;
152 
156  int in_lru;
157 
161  int in_pool;
162 
166  uint32_t index;
167 };
168 
169 
174 {
182 
187 
192 
197 
201  void *cb_cls;
202 
208 
214 
219 
224 
229 
234 };
235 
236 
241 
246 static struct PooledConnection *head_lru;
247 
251 static struct PooledConnection *tail_lru;
252 
259 
265 
269 static unsigned int max_size;
270 
271 
277 static void
278 expire_task_cancel (struct PooledConnection *entry);
279 
280 
286 static void
288 {
289  GNUNET_assert ((NULL == entry->head_notify) && (NULL == entry->tail_notify));
290  GNUNET_assert ((NULL == entry->head_waiting) &&
291  (NULL == entry->tail_waiting));
292  GNUNET_assert (0 == entry->demand);
293  expire_task_cancel (entry);
294  if (entry->in_lru)
296  if (entry->in_pool)
297  GNUNET_assert (
298  GNUNET_OK ==
300  if (NULL != entry->notify_task)
301  {
303  entry->notify_task = NULL;
304  }
305  LOG_DEBUG ("Cleaning up handles of a pooled connection\n");
306  if (NULL != entry->handle_transport)
307  GNUNET_assert (NULL != entry->op_transport);
308  if (NULL != entry->op_transport)
309  {
311  entry->op_transport = NULL;
312  }
313  if (NULL != entry->handle_ats_connectivity)
314  GNUNET_assert (NULL != entry->op_ats_connectivity);
315  if (NULL != entry->op_ats_connectivity)
316  {
318  entry->op_ats_connectivity = NULL;
319  }
320  if (NULL != entry->op_core)
321  {
323  entry->op_core = NULL;
324  }
325  GNUNET_assert (NULL == entry->handle_core);
326  GNUNET_assert (NULL == entry->handle_ats_connectivity);
327  GNUNET_assert (NULL == entry->handle_transport);
329  GNUNET_free (entry);
330 }
331 
332 
338 static void
339 expire (void *cls)
340 {
341  struct PooledConnection *entry = cls;
342 
343  entry->expire_task = NULL;
345 }
346 
347 
353 static void
355 {
356  if (NULL != entry->expire_task)
357  {
359  entry->expire_task = NULL;
360  }
361 }
362 
363 
369 static void
371 {
372  GNUNET_assert (0 == entry->demand);
373  GNUNET_assert (! entry->in_lru);
375  entry->in_lru = GNUNET_YES;
376  GNUNET_assert (NULL == entry->expire_task);
377  entry->expire_task =
379 }
380 
381 
393 static struct GST_ConnectionPool_GetHandle *
396 {
398 
399  for (gh = head; NULL != gh; gh = gh->next)
400  {
401  switch (gh->service)
402  {
404  if (NULL == entry->handle_core)
405  continue;
406  if (NULL == entry->peer_identity)
407  continue; /* CORE connection isn't ready yet */
408  break;
409 
411  if (NULL == entry->handle_transport)
412  continue;
413  break;
414 
416  if (NULL == entry->handle_ats_connectivity)
417  continue;
418  break;
419  }
420  break;
421  }
422  return gh;
423 }
424 
425 
435 static void
436 connection_ready (void *cls)
437 {
438  struct PooledConnection *entry = cls;
440  struct GST_ConnectionPool_GetHandle *gh_next;
441 
442  GNUNET_assert (NULL != entry->notify_task);
443  entry->notify_task = NULL;
445  GNUNET_assert (NULL != gh);
446  gh_next = NULL;
447  if (NULL != gh->next)
448  gh_next = search_waiting (entry, gh->next);
451  gh);
452  gh->connection_ready_called = 1;
453  if (NULL != gh_next)
455  entry);
456  if ((NULL != gh->target) && (NULL != gh->connect_notify_cb))
457  {
460  gh);
461  gh->notify_waiting = 1;
462  }
463  LOG_DEBUG ("Connection ready to %u for handle type %u\n",
464  (unsigned int) entry->index,
465  gh->service);
466  gh->cb (gh->cb_cls,
471  entry->cfg);
472 }
473 
474 
484 static void
486  const struct GNUNET_PeerIdentity *peer,
488 {
489  struct PooledConnection *entry = cls;
491  struct GST_ConnectionPool_GetHandle *gh_next;
493  void *cb_cls;
494 
495  for (gh = entry->head_notify; NULL != gh;)
496  {
497  GNUNET_assert (NULL != gh->target);
498  GNUNET_assert (NULL != gh->connect_notify_cb);
499  GNUNET_assert (gh->connection_ready_called);
500  if (service != gh->service)
501  {
502  gh = gh->next;
503  continue;
504  }
505  if (0 != memcmp (gh->target, peer, sizeof(struct GNUNET_PeerIdentity)))
506  {
507  gh = gh->next;
508  continue;
509  }
510  cb = gh->connect_notify_cb;
511  cb_cls = gh->connect_notify_cb_cls;
512  gh_next = gh->next;
514  gh->notify_waiting = 0;
515  LOG_DEBUG ("Peer connected to peer %u at service %u\n",
516  entry->index,
517  gh->service);
518  gh = gh_next;
519  cb (cb_cls, peer);
520  }
521 }
522 
523 
533 static void *
535  const struct GNUNET_PeerIdentity *peer,
536  struct GNUNET_MQ_Handle *mq)
537 {
538  struct PooledConnection *entry = cls;
539 
541  return NULL;
542 }
543 
544 
551 static void
553 {
554  struct PooledConnection *entry = cls;
555 
556  GNUNET_assert (NULL != entry);
557  LOG_DEBUG ("Opening a transport connection to peer %u\n", entry->index);
558  entry->handle_transport =
560  NULL,
561  NULL,
562  entry,
564  NULL,
565  NULL);
566  if (NULL == entry->handle_transport)
567  {
568  GNUNET_break (0);
569  return;
570  }
571  if (0 == entry->demand)
572  return;
573  if (NULL != entry->notify_task)
574  return;
575  if (NULL != search_waiting (entry, entry->head_waiting))
576  {
578  return;
579  }
580 }
581 
582 
589 static void
591 {
592  struct PooledConnection *entry = cls;
593 
594  if (NULL == entry->handle_transport)
595  return;
597  entry->handle_transport = NULL;
598 }
599 
600 
609 static void *
611  const struct GNUNET_PeerIdentity *peer,
612  struct GNUNET_MQ_Handle *mq)
613 {
614  struct PooledConnection *entry = cls;
615 
617  return (void *) peer;
618 }
619 
620 
633 static void
634 core_startup_cb (void *cls,
635  const struct GNUNET_PeerIdentity *my_identity)
636 {
637  struct PooledConnection *entry = cls;
638 
639  if (NULL == my_identity)
640  {
641  GNUNET_break (0);
642  return;
643  }
644  GNUNET_assert (NULL == entry->peer_identity);
645  entry->peer_identity = GNUNET_new (struct GNUNET_PeerIdentity);
646  *entry->peer_identity = *my_identity;
648  "Established CORE connection for peer %s (%u)\n",
650  (unsigned int) entry->index);
651  if (0 == entry->demand)
652  return;
653  if (NULL != entry->notify_task)
654  return;
655  if (NULL != search_waiting (entry, entry->head_waiting))
656  {
658  return;
659  }
660 }
661 
662 
669 static void
671 {
672  struct PooledConnection *entry = cls;
673 
674  GNUNET_assert (NULL != entry);
675  LOG_DEBUG ("Opening a CORE connection to peer %u\n", entry->index);
676  entry->handle_core =
677  GNUNET_CORE_connect (entry->cfg,
678  entry, /* closure */
679  &core_startup_cb, /* core startup notify */
680  &core_peer_connect_cb, /* peer connect notify */
681  NULL, /* peer disconnect notify */
682  NULL);
683 }
684 
685 
692 static void
694 {
695  struct PooledConnection *entry = cls;
696 
697  if (NULL == entry->handle_core)
698  return;
700  entry->handle_core = NULL;
701  GNUNET_free (entry->peer_identity);
702  entry->peer_identity = NULL;
703 }
704 
705 
712 static void
714 {
715  struct PooledConnection *entry = cls;
716 
718 }
719 
720 
727 static void
729 {
730  struct PooledConnection *entry = cls;
731 
732  if (NULL == entry->handle_ats_connectivity)
733  return;
735  entry->handle_ats_connectivity = NULL;
736 }
737 
738 
749 static int
750 cleanup_iterator (void *cls, uint32_t key, void *value)
751 {
752  struct PooledConnection *entry = value;
753 
754  GNUNET_assert (NULL != entry);
756  return GNUNET_YES;
757 }
758 
759 
767 void
769 {
770  max_size = size;
771  if (0 == max_size)
772  return;
773  GNUNET_assert (NULL == map);
774  map = GNUNET_CONTAINER_multihashmap32_create (((size * 3) / 4) + 1);
775 }
776 
777 
781 void
783 {
784  struct PooledConnection *entry;
785 
786  if (NULL != map)
787  {
788  GNUNET_assert (
789  GNUNET_SYSERR !=
792  map = NULL;
793  }
794  while (NULL != (entry = head_lru))
795  {
798  }
799  GNUNET_assert (NULL == head_not_pooled);
800 }
801 
802 
837  unsigned int peer_id,
838  const struct GNUNET_CONFIGURATION_Handle *cfg,
841  void *cb_cls,
842  const struct GNUNET_PeerIdentity *target,
844  void *connect_notify_cb_cls)
845 {
847  struct PooledConnection *entry;
849  void *handle;
850  uint32_t peer_id32;
851 
852  peer_id32 = (uint32_t) peer_id;
853  handle = NULL;
854  entry = NULL;
855  if (NULL != map)
856  entry = GNUNET_CONTAINER_multihashmap32_get (map, peer_id32);
857  if (NULL != entry)
858  {
859  if (entry->in_lru)
860  {
861  GNUNET_assert (0 == entry->demand);
862  expire_task_cancel (entry);
864  entry->in_lru = GNUNET_NO;
865  }
866  switch (service)
867  {
869  handle = entry->handle_transport;
870  if (NULL != handle)
871  LOG_DEBUG ("Found TRANSPORT handle for peer %u\n",
872  entry->index);
873  break;
875  handle = entry->handle_core;
876  if (NULL != handle)
877  LOG_DEBUG ("Found CORE handle for peer %u\n",
878  entry->index);
879  break;
882  if (NULL != handle)
883  LOG_DEBUG ("Found ATS CONNECTIVITY handle for peer %u\n",
884  entry->index);
885  break;
886  }
887  }
888  else
889  {
890  entry = GNUNET_new (struct PooledConnection);
891  entry->index = peer_id32;
892  if ((NULL != map) &&
894  {
897  map,
898  entry->index,
899  entry,
901  entry->in_pool = GNUNET_YES;
902  }
903  else
904  {
907  entry);
908  }
909  entry->cfg = GNUNET_CONFIGURATION_dup (cfg);
910  }
911  entry->demand++;
913  gh->entry = entry;
914  gh->cb = cb;
915  gh->cb_cls = cb_cls;
916  gh->target = target;
917  gh->connect_notify_cb = connect_notify_cb;
918  gh->connect_notify_cb_cls = connect_notify_cb_cls;
919  gh->service = service;
921  entry->tail_waiting,
922  gh);
923  if (NULL != handle)
924  {
925  if (NULL == entry->notify_task)
926  {
927  if (NULL != search_waiting (entry, entry->head_waiting))
928  entry->notify_task =
930  }
931  return gh;
932  }
933  op = NULL;
934  switch (gh->service)
935  {
937  if (NULL != entry->op_transport)
938  return gh; /* Operation pending */
942  entry->op_transport = op;
943  break;
944 
946  if (NULL != entry->op_core)
947  return gh; /* Operation pending */
951  entry->op_core = op;
952  break;
953 
955  if (NULL != entry->op_ats_connectivity)
956  return gh; /* Operation pending */
957  op =
961  entry->op_ats_connectivity = op;
962  break;
963  }
966  return gh;
967 }
968 
969 
982 void
984 {
985  struct PooledConnection *entry;
986 
987  if (NULL == gh)
988  return;
989  entry = gh->entry;
990  LOG_DEBUG ("Cleaning up get handle %p for service %u, peer %u\n",
991  gh,
992  gh->service,
993  entry->index);
994  if (! gh->connection_ready_called)
995  {
997  if ((NULL == search_waiting (entry, entry->head_waiting)) &&
998  (NULL != entry->notify_task))
999  {
1001  entry->notify_task = NULL;
1002  }
1003  }
1004  if (gh->notify_waiting)
1005  {
1007  gh->notify_waiting = 0;
1008  }
1009  GNUNET_free (gh);
1010  gh = NULL;
1011  GNUNET_assert (! entry->in_lru);
1012  if (! entry->in_pool)
1014  if (NULL != map)
1015  {
1016  if (GNUNET_YES ==
1018  goto unallocate;
1020  {
1021  if (NULL == head_lru)
1022  goto unallocate;
1024  }
1027  map,
1028  entry->index,
1029  entry,
1031  entry->in_pool = GNUNET_YES;
1032  }
1033 
1034 unallocate:
1035  GNUNET_assert (0 < entry->demand);
1036  entry->demand--;
1037  if (0 != entry->demand)
1038  return;
1039  if (entry->in_pool)
1040  {
1041  add_to_lru (entry);
1042  return;
1043  }
1044  destroy_pooled_connection (entry);
1045 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static struct PendingResolutions * head
Head of list of pending resolution requests.
Definition: gnunet-ats.c:230
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
struct GNUNET_PeerIdentity my_identity
Our peer identity.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static char * value
Value of the record to add/remove.
#define LOG_DEBUG(...)
Debug logging shorthand.
static struct GNUNET_TRANSPORT_HelloGetHandle * gh
Pending GNUNET_TRANSPORT_hello_get() operation.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
struct OperationQueue * GST_opq_openfds
Operation queue for open file descriptors.
data structures shared amongst components of TESTBED service
struct GST_ConnectionPool_GetHandle * GST_connection_pool_get_handle(unsigned int peer_id, const struct GNUNET_CONFIGURATION_Handle *cfg, enum GST_ConnectionPool_Service service, GST_connection_pool_connection_ready_cb cb, void *cb_cls, const struct GNUNET_PeerIdentity *target, GST_connection_pool_peer_connect_notify connect_notify_cb, void *connect_notify_cb_cls)
Get a connection handle to service.
static struct GNUNET_CONTAINER_MultiHashMap32 * map
A hashmap for quickly finding connections in the connection pool.
static void destroy_pooled_connection(struct PooledConnection *entry)
Destroy a PooledConnection object.
static void add_to_lru(struct PooledConnection *entry)
Function to add a PooledConnection object into LRU and begin the expiry task.
static unsigned int max_size
The maximum number of entries that can be present in the connection pool.
#define CACHE_EXPIRY
Time to expire a cache entry.
static struct PooledConnection * tail_lru
DLL tail for maitaining the least recently used PooledConnection objects.
void GST_connection_pool_destroy()
Cleanup the connection pool.
static void oprelease_get_handle_ats_connectivity(void *cls)
Function called when the operation responsible for opening a ATS connection is marked as done.
static void opstart_get_handle_ats_connectivity(void *cls)
Function called when resources for opening a connection to ATS are available.
static struct GST_ConnectionPool_GetHandle * search_waiting(const struct PooledConnection *entry, struct GST_ConnectionPool_GetHandle *head)
Function to find a GST_ConnectionPool_GetHandle which is waiting for one of the handles in given entr...
static int cleanup_iterator(void *cls, uint32_t key, void *value)
This function will be called for every PooledConnection object in map.
static void core_startup_cb(void *cls, const struct GNUNET_PeerIdentity *my_identity)
Function called after GNUNET_CORE_connect() has succeeded (or failed for good).
void GST_connection_pool_get_handle_done(struct GST_ConnectionPool_GetHandle *gh)
Relinquish a GST_ConnectionPool_GetHandle object.
static struct PooledConnection * head_not_pooled
DLL head for maintaining PooledConnection objects that are not added into the connection pool as it w...
static void connection_ready(void *cls)
A handle in the PooledConnection object pointed by cls is ready and there is a GST_ConnectionPool_Get...
static void * core_peer_connect_cb(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a given peer connects at CORE level.
static struct PooledConnection * tail_not_pooled
DLL tail for maintaining PooledConnection objects that are not added into the connection pool as it w...
static struct PooledConnection * head_lru
DLL head for maitaining the least recently used PooledConnection objects.
static void expire(void *cls)
Expire a PooledConnection object.
static void oprelease_get_handle_core(void *cls)
Function called when the operation responsible for opening a CORE connection is marked as done.
static void opstart_get_handle_transport(void *cls)
Function called when resources for opening a connection to TRANSPORT are available.
static void * transport_peer_connect_notify_cb(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Function called to notify transport users that another peer connected to us.
static void expire_task_cancel(struct PooledConnection *entry)
Cancel the expiration task of the give PooledConnection object.
static void opstart_get_handle_core(void *cls)
Function called when resources for opening a connection to CORE are available.
void GST_connection_pool_init(unsigned int size)
Initialise the connection pool.
static void oprelease_get_handle_transport(void *cls)
Function called when the operation responsible for opening a TRANSPORT connection is marked as done.
static void peer_connect_notify_cb(void *cls, const struct GNUNET_PeerIdentity *peer, const enum GST_ConnectionPool_Service service)
Function called from peer connect notify callbacks from CORE and TRANSPORT connections.
Interface for connection pooling subroutines.
void(* GST_connection_pool_peer_connect_notify)(void *cls, const struct GNUNET_PeerIdentity *target)
Callback to notify when the target peer given to GST_connection_pool_get_handle() is connected.
GST_ConnectionPool_Service
The type of service.
@ GST_CONNECTIONPOOL_SERVICE_TRANSPORT
Transport service.
@ GST_CONNECTIONPOOL_SERVICE_CORE
Core service.
@ GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY
ATS service.
void(* GST_connection_pool_connection_ready_cb)(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *peer_id, const struct GNUNET_CONFIGURATION_Handle *cfg)
Functions of this type are called when the needed handle is available for usage.
struct GNUNET_TRANSPORT_CoreHandle * GNUNET_TRANSPORT_core_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd)
Connect to the transport service.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
struct GNUNET_CORE_Handle * GNUNET_CORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Connect to the core service.
Definition: core_api.c:691
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:729
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_contains(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Check if the map contains any value under the given key (including values that are NULL).
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
void * GNUNET_CONTAINER_multihashmap32_get(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Given a key find a value in the map matching the key.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1299
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1272
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2021
static unsigned int size
Size of the "table".
Definition: peer.c:68
Handle to the ATS subsystem for connectivity management.
Internal representation of the hash map.
Context for the core service connection.
Definition: core_api.c:78
Handle to a message queue.
Definition: mq.c:87
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition: scheduler.c:136
Opaque handle to an abstract operation to be executed by the testing framework.
void * cb_cls
Closure for callbacks.
Handle for the transport service (includes all of the state for the transport service).
The request handle for obtaining a pooled connection.
const struct GNUNET_PeerIdentity * target
The peer identity of the target peer.
void * cb_cls
The closure for the above callback.
enum GST_ConnectionPool_Service service
The service we want to connect to.
struct PooledConnection * entry
The pooled connection object this handle corresponds to.
struct GST_ConnectionPool_GetHandle * next
The next ptr for inclusion in the notification DLLs.
int notify_waiting
Are we waiting for any peer connect notifications?
GST_connection_pool_connection_ready_cb cb
The cache callback to call when a handle is available.
struct GST_ConnectionPool_GetHandle * prev
The prev ptr for inclusion in the notification DLLs.
GST_connection_pool_peer_connect_notify connect_notify_cb
The callback to be called for serving notification that the target peer is connected.
void * connect_notify_cb_cls
The closure for the notify callback.
int connection_ready_called
Did we call the pool_connection_ready_cb already?
struct GNUNET_TESTBED_Operation * op_ats_connectivity
The operation handle for ATS handle.
struct GST_ConnectionPool_GetHandle * tail_waiting
DLL tail for the queue of GST_ConnectionPool_GetHandle requests that are waiting for this connection ...
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration of the peer.
struct PooledConnection * next
Next ptr for placing this object in the DLL of least recently used pooled connections.
unsigned int demand
Number of active requests using this pooled connection.
struct GNUNET_ATS_ConnectivityHandle * handle_ats_connectivity
The ATS handle to the peer correspondign to this entry; can be NULL.
struct GNUNET_TRANSPORT_CoreHandle * handle_transport
The transport handle to the peer corresponding to this entry; can be NULL.
struct PooledConnection * prev
Prev ptr for placing this object in the DLL of the least recently used pooled connections.
int in_pool
Is this entry present in the connection pool.
struct GST_ConnectionPool_GetHandle * head_waiting
DLL head for the queue of GST_ConnectionPool_GetHandle requests that are waiting for this connection ...
struct GNUNET_TESTBED_Operation * op_transport
The operation handle for transport handle.
struct GST_ConnectionPool_GetHandle * tail_notify
DLL tail for the queue to serve notifications when a peer is connected.
struct GNUNET_SCHEDULER_Task * notify_task
The task to notify a waiting GST_ConnectionPool_GetHandle object.
struct GNUNET_CORE_Handle * handle_core
The core handle to the peer corresponding to this entry; can be NULL.
uint32_t index
The index of this peer.
struct GST_ConnectionPool_GetHandle * head_notify
DLL head for the queue to serve notifications when a peer is connected.
struct GNUNET_SCHEDULER_Task * expire_task
The task to expire this connection from the connection pool.
struct GNUNET_PeerIdentity * peer_identity
The peer identity of this peer.
struct GNUNET_TESTBED_Operation * op_core
The operation handle for core handle.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an 'operation' to be performed.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
internal API to access the 'operations' subsystem
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.