PadicoTM

Documentation

« back to PM2 home.
addrdb.c File Reference

Address DB for easy connection establishment. More...

#include <Padico/Puk.h>
#include <Padico/Module.h>
#include <Padico/PadicoControl.h>
#include <Padico/Topology.h>
#include "AddrDB.h"
Include dependency graph for addrdb.c:

Go to the source code of this file.

Data Structures

struct  padico_address_key_s
 
struct  padico_address_entry_s
 
struct  padico_addrkey_hash_entry_s
 stores an entry in the hashtable More...
 
struct  padico_addrkey_hash_entry_block_lfstack_cell_s
 
struct  padico_addrkey_hash_entry_block_lfstack_s
 
struct  padico_addrkey_hash_entry_slice_lfstack_cell_s
 
struct  padico_addrkey_hash_entry_slice_lfstack_s
 
struct  padico_addrkey_hash_entry_allocator_s
 
struct  padico_addrkey_hashtable_s
 
struct  padico_addrkey_hashtable_enumerator_s
 

Typedefs

typedef uint32_t(* padico_addrkey_hash_hfunc_t) (struct padico_address_key_s *key)
 
typedef int(* padico_addrkey_hash_eqfunc_t) (struct padico_address_key_s *key1, struct padico_address_key_s *key2)
 
typedef void(* padico_addrkey_hash_destructor_t) (struct padico_address_key_s *key, struct padico_address_entry_s *data)
 
typedef struct padico_addrkey_hash_entry_block_lfstack_s padico_addrkey_hash_entry_block_lfstack_t
 
typedef struct padico_addrkey_hash_entry_slice_lfstack_s padico_addrkey_hash_entry_slice_lfstack_t
 
typedef struct padico_addrkey_hash_entry_allocator_s * padico_addrkey_hash_entry_allocator_t
 
typedef struct padico_addrkey_hashtable_s * padico_addrkey_hashtable_t
 
typedef struct padico_addrkey_hashtable_enumerator_s * padico_addrkey_hashtable_enumerator_t
 

Functions

static int padico_addrdb_init (void)
 
static void padico_addrdb_finalize (void)
 
static void padico_module_create_initializer__AddrDB (void)
 
static uint32_t padico_addrkey_hash (const struct padico_address_key_s *a)
 
static int padico_addrkey_eq (const struct padico_address_key_s *a1, struct padico_address_key_s *a2)
 
static void padico_addrdb_entry_destructor (struct padico_address_key_s *key, struct padico_address_entry_s *e)
 
struct padico_addrkey_hash_entry_block_lfstack_cell_s __attribute__ ((aligned(16)))
 
 __attribute__ ((unused))
 lookup in the oldtable; if found, migrate row and return cell in regular table
 
 __attribute__ ((unused, nonnull))
 initialize a new hashtable
 
static struct padico_addrkey_hash_entry_s * padico_addrkey_hash_entry_lookup (padico_addrkey_hashtable_t h, const struct padico_address_key_s *key)
 
static void padico_addrkey_hash_entry_insert (padico_addrkey_hashtable_t h, struct padico_address_key_s *key, struct padico_address_entry_s *data)
 
static int padico_addrkey_hash_entry_oldprobe (padico_addrkey_hashtable_t h, const struct padico_address_key_s *key)
 
static void padico_addrkey_hash_entry_rehash_row (padico_addrkey_hashtable_t h, ssize_t z)
 
static void padico_addrkey_hash_entry_rehash_n (padico_addrkey_hashtable_t h, ssize_t n)
 
static void padico_addrkey_hash_entry_rehash_flush (padico_addrkey_hashtable_t h)
 
 __attribute__ ((unused, nonnull(1)))
 insert an entry into a hashtable
 
static void padico_addrdb_free_entry (struct padico_address_entry_s *e)
 
static struct padico_address_key_s * padico_addrkey_new (padico_topo_node_t node, const char *component, const void *instance, size_t instance_size)
 
static void padico_addrkey_delete (struct padico_address_key_s *a)
 
static void padico_addrdb_insert (padico_topo_node_t node, const char *component_name, const void *instance, size_t instance_size, void *addr, size_t addr_size)
 
static void padico_addrdb_publish_handler (puk_parse_entity_t e)
 
void padico_addrdb_publish (padico_topo_node_t node, const char *component, const void *instance, size_t instance_size, const void *addr, size_t addr_size)
 
static struct padico_address_entry_s * padico_addrdb_new_entry (struct padico_address_key_s *k)
 
void padico_addrdb_get (padico_topo_node_t node, const char *component, const void *instance, size_t instance_size, void *addr, size_t addr_size, padico_req_t req)
 get address in static buffer
 
void padico_addrdb_dynget (padico_topo_node_t node, const char *component, const void *instance, size_t instance_size, void **addr, size_t *addr_size, padico_req_t req)
 get a dynamically allocated address
 

Variables

struct puk_mod_binary_s padico_mod_binary__AddrDB = { .name = "AddrDB", .funcs = &padico_mod_funcs__AddrDB , .mod = NULL, .profile = { .total_mem = 0, .max_mem = 0, .num_malloc = 0, .num_free = 0 } , .auto_deps = & puk_mod_dep_AddrDB , .n_deps = sizeof((char*[]){ 0, "Topology", "PadicoControl" }) / sizeof(char*), .deps = { NULL, "Topology", "PadicoControl" } }
 
static const struct puk_mod_funcs_s padico_mod_funcs__AddrDB = { .init = ( padico_addrdb_init ), .run = ( NULL ), .finalize = ( padico_addrdb_finalize ) }
 
struct padico_addrkey_hash_entry_block_lfstack_cell_s * _next = _stack->_head
 
struct padico_addrkey_hash_entry_block_lfstack_s __attribute__
 hint whether the queue is empty.
 
struct padico_addrkey_hash_entry_block_lfstack_cell_s block [] = NULL
 
struct { 
 
   struct padico_addrkey_hashtable_s   table 
 
   pthread_mutex_t   lock 
 
   pthread_cond_t   event 
 
} addr_db 
 

Detailed Description

Address DB for easy connection establishment.

Definition in file addrdb.c.

Typedef Documentation

◆ padico_addrkey_hash_destructor_t

typedef void(* padico_addrkey_hash_destructor_t) (struct padico_address_key_s *key, struct padico_address_entry_s *data)

Definition at line 68 of file addrdb.c.

◆ padico_addrkey_hash_entry_allocator_t

◆ padico_addrkey_hash_entry_block_lfstack_t

◆ padico_addrkey_hash_entry_slice_lfstack_t

◆ padico_addrkey_hash_eqfunc_t

Definition at line 68 of file addrdb.c.

◆ padico_addrkey_hash_hfunc_t

typedef uint32_t(* padico_addrkey_hash_hfunc_t) (struct padico_address_key_s *key)

Definition at line 68 of file addrdb.c.

◆ padico_addrkey_hashtable_enumerator_t

◆ padico_addrkey_hashtable_t

Function Documentation

◆ __attribute__() [1/4]

◆ __attribute__() [2/4]

__attribute__ ( (unused)  )

lookup in the oldtable; if found, migrate row and return cell in regular table

get the seq part of a tagged ptr

pop key & data of any element in the table

remove entry with given key from hashtable; does nothing if key not found

allocate a new hashtable

trigger progressive rehashing

flush all rows of a pending rehash

lookup an entry in the hashtable

insert an entry in the given table, without rehashing

make progress on rehash for n rows

force rehashing of given row

Definition at line 68 of file addrdb.c.

◆ __attribute__() [3/4]

__attribute__ ( (unused, nonnull(1))  )

insert an entry into a hashtable

returns <key,value> associated with given key, outkey is set to NULL if key not found

probes whether an entry with given key exists in the hashtable

returns value associated with key, NULL if not found

Definition at line 68 of file addrdb.c.

◆ __attribute__() [4/4]

__attribute__ ( (unused, nonnull)  )

initialize a new hashtable

deallocate a hashtable

destroy a hashtable

Definition at line 68 of file addrdb.c.

◆ padico_addrdb_entry_destructor()

static void padico_addrdb_entry_destructor ( struct padico_address_key_s *  key,
struct padico_address_entry_s *  e 
)
static

Definition at line 116 of file addrdb.c.

References e, and padico_addrdb_free_entry().

◆ padico_addrdb_finalize()

static void padico_addrdb_finalize ( void  )
static

Definition at line 158 of file addrdb.c.

References addr_db, and done.

◆ padico_addrdb_free_entry()

◆ padico_addrdb_init()

static int padico_addrdb_init ( void  )
static

Definition at line 143 of file addrdb.c.

References addr_db, done, NULL, and padico_addrdb_publish_handler().

◆ padico_addrdb_insert()

◆ padico_addrdb_new_entry()

static struct padico_address_entry_s * padico_addrdb_new_entry ( struct padico_address_key_s *  k)
static

Definition at line 179 of file addrdb.c.

References done, e, ns_rulebucket_hash_entry_s::key, and NULL.

Referenced by padico_addrdb_dynget(), padico_addrdb_get(), and padico_addrdb_insert().

◆ padico_addrdb_publish_handler()

static void padico_addrdb_publish_handler ( puk_parse_entity_t  e)
static

◆ padico_addrkey_delete()

static void padico_addrkey_delete ( struct padico_address_key_s *  a)
static

Definition at line 109 of file addrdb.c.

References a, and done.

Referenced by padico_addrdb_dynget(), padico_addrdb_free_entry(), padico_addrdb_get(), and padico_addrdb_insert().

◆ padico_addrkey_eq()

static int padico_addrkey_eq ( const struct padico_address_key_s *  a1,
struct padico_address_key_s *  a2 
)
static

Definition at line 90 of file addrdb.c.

References done.

◆ padico_addrkey_hash()

static uint32_t padico_addrkey_hash ( const struct padico_address_key_s *  a)
static

Definition at line 82 of file addrdb.c.

References a, done, padico_topo_node_getuuid(), PADICO_TOPO_UUID_SIZE, and z.

◆ padico_addrkey_hash_entry_insert()

static void padico_addrkey_hash_entry_insert ( padico_addrkey_hashtable_t  h,
struct padico_address_key_s *  key,
struct padico_address_entry_s *  data 
)
inlinestatic

◆ padico_addrkey_hash_entry_lookup()

static struct padico_addrkey_hash_entry_s * padico_addrkey_hash_entry_lookup ( padico_addrkey_hashtable_t  h,
const struct padico_address_key_s *  key 
)
inlinestatic

◆ padico_addrkey_hash_entry_oldprobe()

static int padico_addrkey_hash_entry_oldprobe ( padico_addrkey_hashtable_t  h,
const struct padico_address_key_s *  key 
)
inlinestatic

◆ padico_addrkey_hash_entry_rehash_flush()

static void padico_addrkey_hash_entry_rehash_flush ( padico_addrkey_hashtable_t  h)
inlinestatic

◆ padico_addrkey_hash_entry_rehash_n()

static void padico_addrkey_hash_entry_rehash_n ( padico_addrkey_hashtable_t  h,
ssize_t  n 
)
inlinestatic

◆ padico_addrkey_hash_entry_rehash_row()

static void padico_addrkey_hash_entry_rehash_row ( padico_addrkey_hashtable_t  h,
ssize_t  z 
)
inlinestatic

◆ padico_addrkey_new()

static struct padico_address_key_s * padico_addrkey_new ( padico_topo_node_t  node,
const char *  component,
const void *  instance,
size_t  instance_size 
)
static

◆ padico_module_create_initializer__AddrDB()

static void padico_module_create_initializer__AddrDB ( void  )
static

Definition at line 40 of file addrdb.c.

Variable Documentation

◆ __attribute__

__attribute__

hint whether the queue is empty.

add a binding to a node; take ownership of binding

get the seq part of a tagged ptr

insert an entry into a hashtable

default compile-time thread level

explicit thread level

check consistency of cells in list

pop key & data of any element in the table

remove entry with given key from hashtable; does nothing if key not found

returns <key,value> associated with given key, outkey is set to NULL if key not found

probes whether an entry with given key exists in the hashtable

returns value associated with key, NULL if not found

deallocate a hashtable

destroy a hashtable

allocate a new hashtable

initialize a new hashtable

trigger progressive rehashing

flush all rows of a pending rehash

lookup an entry in the hashtable

insert an entry in the given table, without rehashing

make progress on rehash for n rows

force rehashing of given row

lookup in the oldtable; if found, migrate row and return cell in regular table

get the allocated queue size

hint about the number of elements in queue .

  • Do not rely on it: state may have changed before dequeue * Usefull to reduce active polling, though

Do not rely on it: state may have changed before function return.

insert e after r

Definition at line 32 of file bench_lfqueue.c.

Referenced by padico_vio_fcntl(), sfplain_close(), sfsnc_close(), sfsnc_create(), sfsrtun_close(), sfssh2_close(), sfssh2_create(), sfstun_close(), vlink_ps_send_post(), and vlink_resolver_resolve_node().

◆ _next

◆ [struct]

◆ block

◆ event

Definition at line 74 of file addrdb.c.

◆ lock

Definition at line 73 of file addrdb.c.

◆ padico_mod_binary__AddrDB

struct puk_mod_binary_s padico_mod_binary__AddrDB = { .name = "AddrDB", .funcs = &padico_mod_funcs__AddrDB , .mod = NULL, .profile = { .total_mem = 0, .max_mem = 0, .num_malloc = 0, .num_free = 0 } , .auto_deps = & puk_mod_dep_AddrDB , .n_deps = sizeof((char*[]){ 0, "Topology", "PadicoControl" }) / sizeof(char*), .deps = { NULL, "Topology", "PadicoControl" } }

Definition at line 40 of file addrdb.c.

◆ padico_mod_funcs__AddrDB

const struct puk_mod_funcs_s padico_mod_funcs__AddrDB = { .init = ( padico_addrdb_init ), .run = ( NULL ), .finalize = ( padico_addrdb_finalize ) }
static

Definition at line 40 of file addrdb.c.

◆ table

Definition at line 72 of file addrdb.c.

Referenced by padico_group_topology().