Part of ccnr - CCNx Repository Daemon. More...
Go to the source code of this file.
Data Structures | |
struct | content_entry |
The content hash table is keyed by the initial portion of the ContentObject that contains all the parts of the complete name. More... | |
Defines | |
#define | FAILIF(cond) do {} while ((cond) && r_store_fatal(h, __func__, __LINE__)) |
#define | CHKSYS(res) FAILIF((res) == -1) |
#define | CHKRES(res) FAILIF((res) < 0) |
#define | CHKPTR(p) FAILIF((p) == NULL) |
#define | CCN_BT_CLEAN_BATCH 3 |
Number of btree index writes to do in a batch. | |
#define | CCN_BT_CLEAN_TICK_MICROS 65536 |
Approximate delay between batches of btree index writes. | |
Functions | |
static int | r_store_set_flatname (struct ccnr_handle *h, struct content_entry *content, struct ccn_parsed_ContentObject *pco) |
Parses content object and sets content->flatname. | |
static int | r_store_content_btree_insert (struct ccnr_handle *h, struct content_entry *content, struct ccn_parsed_ContentObject *pco, ccnr_accession *accp) |
static int | r_store_fatal (struct ccnr_handle *h, const char *fn, int lineno) |
PUBLIC ccnr_accession | r_store_content_accession (struct ccnr_handle *h, struct content_entry *content) |
PUBLIC ccnr_cookie | r_store_content_cookie (struct ccnr_handle *h, struct content_entry *content) |
PUBLIC size_t | r_store_content_size (struct ccnr_handle *h, struct content_entry *content) |
static off_t | r_store_offset_from_accession (struct ccnr_handle *h, ccnr_accession a) |
static unsigned | r_store_repofile_from_accession (struct ccnr_handle *h, ccnr_accession a) |
static const unsigned char * | r_store_content_mapped (struct ccnr_handle *h, struct content_entry *content) |
static const unsigned char * | r_store_content_read (struct ccnr_handle *h, struct content_entry *content) |
PUBLIC int | r_store_content_trim (struct ccnr_handle *h, struct content_entry *content) |
If the content appears to be safely stored in the repository, removes any buffered copy. | |
PUBLIC void | r_store_trim (struct ccnr_handle *h, unsigned long limit) |
Evict recoverable content from in-memory buffers. | |
PUBLIC const unsigned char * | r_store_content_base (struct ccnr_handle *h, struct content_entry *content) |
Get the base address of the content object. | |
PUBLIC int | r_store_name_append_components (struct ccn_charbuf *dst, struct ccnr_handle *h, struct content_entry *content, int skip, int count) |
PUBLIC int | r_store_content_flags (struct content_entry *content) |
PUBLIC int | r_store_content_change_flags (struct content_entry *content, int set, int clear) |
static int | r_store_write_stable_point (struct ccnr_handle *h) |
Write a file named index/stable that contains the size of repoFile1 when the repository is shut down. | |
static void | r_store_read_stable_point (struct ccnr_handle *h) |
Read the former size of repoFile1 from index/stable, and remove the latter. | |
static int | r_store_reindexing (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags) |
Log a bit if we are taking a while to re-index. | |
static unsigned | choose_limit (unsigned l, unsigned m) |
Select power of 2 between l and m + 1 (if possible). | |
PUBLIC void | r_store_init (struct ccnr_handle *h) |
PUBLIC int | r_store_final (struct ccnr_handle *h, int stable) |
PUBLIC struct content_entry * | r_store_content_from_accession (struct ccnr_handle *h, ccnr_accession accession) |
PUBLIC struct content_entry * | r_store_content_from_cookie (struct ccnr_handle *h, ccnr_cookie cookie) |
PUBLIC ccnr_cookie | r_store_enroll_content (struct ccnr_handle *h, struct content_entry *content) |
This makes a cookie for content, and, if it has an accession number already, enters it into the content_by_accession_tab. | |
PUBLIC void | r_store_forget_content (struct ccnr_handle *h, struct content_entry **pentry) |
Remove internal representation of a content object. | |
static struct content_entry * | r_store_look (struct ccnr_handle *h, const unsigned char *key, size_t size) |
Get a handle on the content object that matches key, or if there is no match, the one that would come just after it. | |
static int | ccn_append_interest_bounds (const unsigned char *interest_msg, const struct ccn_parsed_interest *pi, struct ccn_charbuf *lower, struct ccn_charbuf *upper) |
Extract the flatname representations of the bounds for the next component after the name prefix of the interest. | |
static struct content_entry * | r_store_lookup_backwards (struct ccnr_handle *h, const unsigned char *interest_msg, const struct ccn_parsed_interest *pi, struct ccn_indexbuf *comps) |
PUBLIC struct content_entry * | r_store_find_first_match_candidate (struct ccnr_handle *h, const unsigned char *interest_msg, const struct ccn_parsed_interest *pi) |
PUBLIC int | r_store_content_matches_interest_prefix (struct ccnr_handle *h, struct content_entry *content, const unsigned char *interest_msg, size_t interest_size) |
PUBLIC struct content_entry * | r_store_content_next (struct ccnr_handle *h, struct content_entry *content) |
PUBLIC struct content_entry * | r_store_next_child_at_level (struct ccnr_handle *h, struct content_entry *content, int level) |
PUBLIC struct content_entry * | r_store_lookup (struct ccnr_handle *h, const unsigned char *msg, const struct ccn_parsed_interest *pi, struct ccn_indexbuf *comps) |
PUBLIC struct content_entry * | r_store_lookup_ccnb (struct ccnr_handle *h, const unsigned char *namish, size_t size) |
Find the first content handle that matches the prefix given by the namish, which may be a Name, Interest, ContentObject, . | |
PUBLIC void | r_store_mark_stale (struct ccnr_handle *h, struct content_entry *content) |
Mark content as stale. | |
static int | expire_content (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags) |
Scheduled event that makes content stale when its FreshnessSeconds has expired. | |
PUBLIC void | r_store_set_content_timer (struct ccnr_handle *h, struct content_entry *content, struct ccn_parsed_ContentObject *pco) |
Schedules content expiration based on its FreshnessSeconds. | |
PUBLIC struct ccn_charbuf * | r_store_content_flatname (struct ccnr_handle *h, struct content_entry *content) |
Get the flatname associated with content. | |
PUBLIC struct content_entry * | process_incoming_content (struct ccnr_handle *h, struct fdholder *fdholder, unsigned char *msg, size_t size, off_t *offsetp) |
PUBLIC int | r_store_content_field_access (struct ccnr_handle *h, struct content_entry *content, enum ccn_dtag dtag, const unsigned char **bufp, size_t *sizep) |
PUBLIC int | r_store_set_accession_from_offset (struct ccnr_handle *h, struct content_entry *content, struct fdholder *fdholder, off_t offset) |
PUBLIC void | r_store_send_content (struct ccnr_handle *h, struct fdholder *fdholder, struct content_entry *content) |
PUBLIC int | r_store_commit_content (struct ccnr_handle *h, struct content_entry *content) |
PUBLIC void | ccnr_debug_content (struct ccnr_handle *h, int lineno, const char *msg, struct fdholder *fdholder, struct content_entry *content) |
static int | r_store_index_cleaner (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags) |
PUBLIC void | r_store_index_needs_cleaning (struct ccnr_handle *h) |
Variables | |
static const unsigned char * | bogon = NULL |
const ccnr_accession | r_store_mark_repoFile1 = ((ccnr_accession)1) << 48 |
Part of ccnr - CCNx Repository Daemon.
Definition in file ccnr_store.c.
#define CCN_BT_CLEAN_BATCH 3 |
Number of btree index writes to do in a batch.
Definition at line 1502 of file ccnr_store.c.
Referenced by r_store_index_cleaner().
#define CCN_BT_CLEAN_TICK_MICROS 65536 |
Approximate delay between batches of btree index writes.
Definition at line 1504 of file ccnr_store.c.
Referenced by r_store_index_cleaner(), and r_store_index_needs_cleaning().
#define CHKPTR | ( | p | ) | FAILIF((p) == NULL) |
Definition at line 94 of file ccnr_store.c.
#define CHKRES | ( | res | ) | FAILIF((res) < 0) |
Definition at line 93 of file ccnr_store.c.
#define CHKSYS | ( | res | ) | FAILIF((res) == -1) |
Definition at line 92 of file ccnr_store.c.
#define FAILIF | ( | cond | ) | do {} while ((cond) && r_store_fatal(h, __func__, __LINE__)) |
Definition at line 91 of file ccnr_store.c.
static int ccn_append_interest_bounds | ( | const unsigned char * | interest_msg, | |
const struct ccn_parsed_interest * | pi, | |||
struct ccn_charbuf * | lower, | |||
struct ccn_charbuf * | upper | |||
) | [static] |
Extract the flatname representations of the bounds for the next component after the name prefix of the interest.
These are exclusive bounds. The results are appended to lower and upper (when not NULL). If there is no lower bound, lower will be unchanged. If there is no upper bound, a sentinel value is appended to upper.
Definition at line 845 of file ccnr_store.c.
Referenced by r_store_find_first_match_candidate(), and r_store_lookup_backwards().
PUBLIC void ccnr_debug_content | ( | struct ccnr_handle * | h, | |
int | lineno, | |||
const char * | msg, | |||
struct fdholder * | fdholder, | |||
struct content_entry * | content | |||
) |
Definition at line 1480 of file ccnr_store.c.
Referenced by process_incoming_content(), r_proto_continue_enumeration(), r_store_content_from_accession(), r_store_forget_content(), r_store_lookup(), r_store_mark_stale(), r_store_next_child_at_level(), r_store_send_content(), r_store_set_content_timer(), r_sync_enumerate_action(), r_sync_local_store(), r_sync_notify_content(), and r_sync_upcall_store().
static unsigned choose_limit | ( | unsigned | l, | |
unsigned | m | |||
) | [static] |
Select power of 2 between l and m + 1 (if possible).
Definition at line 445 of file ccnr_store.c.
Referenced by r_store_init().
static int expire_content | ( | struct ccn_schedule * | sched, | |
void * | clienth, | |||
struct ccn_scheduled_event * | ev, | |||
int | flags | |||
) | [static] |
Scheduled event that makes content stale when its FreshnessSeconds has expired.
Definition at line 1212 of file ccnr_store.c.
Referenced by r_store_set_content_timer().
PUBLIC struct content_entry* process_incoming_content | ( | struct ccnr_handle * | h, | |
struct fdholder * | fdholder, | |||
unsigned char * | msg, | |||
size_t | size, | |||
off_t * | offsetp | |||
) | [read] |
Definition at line 1316 of file ccnr_store.c.
PUBLIC int r_store_commit_content | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) |
Definition at line 1462 of file ccnr_store.c.
Referenced by process_input_message(), r_init_map_and_process_file(), r_proto_expect_content(), r_sync_local_store(), and r_sync_upcall_store().
PUBLIC ccnr_accession r_store_content_accession | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) |
Definition at line 109 of file ccnr_store.c.
Referenced by r_sync_enumerate(), r_sync_enumerate_action(), and r_sync_notify_content().
PUBLIC const unsigned char* r_store_content_base | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) |
Get the base address of the content object.
This may involve reading the object in. Caller should not assume that the address will stay valid after it relinquishes control, either by returning or by calling routines that might invalidate objects.
Definition at line 264 of file ccnr_store.c.
Referenced by load_policy(), r_match_consume_matching_interests(), r_proto_policy_update(), r_store_content_btree_insert(), r_store_content_field_access(), r_store_content_from_accession(), r_store_send_content(), r_store_set_content_timer(), r_store_set_flatname(), and r_sync_lookup().
static int r_store_content_btree_insert | ( | struct ccnr_handle * | h, | |
struct content_entry * | content, | |||
struct ccn_parsed_ContentObject * | pco, | |||
ccnr_accession * | accp | |||
) | [static] |
Definition at line 676 of file ccnr_store.c.
Referenced by process_incoming_content(), and r_store_content_from_accession().
PUBLIC int r_store_content_change_flags | ( | struct content_entry * | content, | |
int | set, | |||
int | clear | |||
) |
Definition at line 318 of file ccnr_store.c.
Referenced by r_store_commit_content().
PUBLIC ccnr_cookie r_store_content_cookie | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) |
Definition at line 115 of file ccnr_store.c.
Referenced by r_proto_expect_content(), r_sendq_face_send_queue_insert(), r_sync_enumerate(), r_sync_enumerate_action(), and r_sync_upcall_store().
PUBLIC int r_store_content_field_access | ( | struct ccnr_handle * | h, | |
struct content_entry * | content, | |||
enum ccn_dtag | dtag, | |||
const unsigned char ** | bufp, | |||
size_t * | sizep | |||
) |
Definition at line 1367 of file ccnr_store.c.
PUBLIC int r_store_content_flags | ( | struct content_entry * | content | ) |
Definition at line 312 of file ccnr_store.c.
Referenced by r_sendq_face_send_queue_insert(), r_store_commit_content(), r_sync_local_store(), and r_sync_upcall_store().
PUBLIC struct ccn_charbuf* r_store_content_flatname | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) | [read] |
Get the flatname associated with content.
Definition at line 1310 of file ccnr_store.c.
Referenced by r_sync_enumerate_action().
PUBLIC struct content_entry* r_store_content_from_accession | ( | struct ccnr_handle * | h, | |
ccnr_accession | accession | |||
) | [read] |
Definition at line 587 of file ccnr_store.c.
Referenced by process_incoming_content(), r_store_lookup(), and r_sync_enumerate_action().
PUBLIC struct content_entry* r_store_content_from_cookie | ( | struct ccnr_handle * | h, | |
ccnr_cookie | cookie | |||
) | [read] |
Definition at line 630 of file ccnr_store.c.
Referenced by content_sender(), expire_content(), r_store_lookup(), and r_sync_enumerate_action().
static const unsigned char* r_store_content_mapped | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) | [static] |
Definition at line 141 of file ccnr_store.c.
Referenced by r_store_content_base().
PUBLIC int r_store_content_matches_interest_prefix | ( | struct ccnr_handle * | h, | |
struct content_entry * | content, | |||
const unsigned char * | interest_msg, | |||
size_t | interest_size | |||
) |
Definition at line 1005 of file ccnr_store.c.
Referenced by r_proto_begin_enumeration(), r_proto_continue_enumeration(), r_store_lookup(), r_sync_enumerate(), and r_sync_enumerate_action().
PUBLIC struct content_entry* r_store_content_next | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) | [read] |
Definition at line 1022 of file ccnr_store.c.
Referenced by r_store_lookup(), and r_sync_enumerate_action().
static const unsigned char* r_store_content_read | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) | [static] |
Definition at line 147 of file ccnr_store.c.
Referenced by r_store_content_base().
PUBLIC size_t r_store_content_size | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) |
Definition at line 121 of file ccnr_store.c.
Referenced by load_policy(), r_match_consume_matching_interests(), r_proto_policy_update(), and r_sync_lookup().
PUBLIC int r_store_content_trim | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) |
If the content appears to be safely stored in the repository, removes any buffered copy.
Definition at line 215 of file ccnr_store.c.
Referenced by r_store_trim().
PUBLIC ccnr_cookie r_store_enroll_content | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) |
This makes a cookie for content, and, if it has an accession number already, enters it into the content_by_accession_tab.
Does not index by name.
Definition at line 645 of file ccnr_store.c.
Referenced by process_incoming_content(), r_store_content_from_accession(), and r_store_look().
static int r_store_fatal | ( | struct ccnr_handle * | h, | |
const char * | fn, | |||
int | lineno | |||
) | [static] |
Definition at line 97 of file ccnr_store.c.
PUBLIC int r_store_final | ( | struct ccnr_handle * | h, | |
int | stable | |||
) |
Definition at line 575 of file ccnr_store.c.
Referenced by r_init_destroy().
PUBLIC struct content_entry* r_store_find_first_match_candidate | ( | struct ccnr_handle * | h, | |
const unsigned char * | interest_msg, | |||
const struct ccn_parsed_interest * | pi | |||
) | [read] |
Definition at line 989 of file ccnr_store.c.
Referenced by r_proto_begin_enumeration(), r_store_lookup(), and r_sync_enumerate().
PUBLIC void r_store_forget_content | ( | struct ccnr_handle * | h, | |
struct content_entry ** | pentry | |||
) |
Remove internal representation of a content object.
Definition at line 739 of file ccnr_store.c.
Referenced by process_incoming_content(), r_store_content_from_accession(), and r_store_enroll_content().
static int r_store_index_cleaner | ( | struct ccn_schedule * | sched, | |
void * | clienth, | |||
struct ccn_scheduled_event * | ev, | |||
int | flags | |||
) | [static] |
Definition at line 1506 of file ccnr_store.c.
Referenced by r_store_index_needs_cleaning().
PUBLIC void r_store_index_needs_cleaning | ( | struct ccnr_handle * | h | ) |
Definition at line 1601 of file ccnr_store.c.
Referenced by r_store_content_btree_insert(), r_store_init(), and r_store_trim().
PUBLIC void r_store_init | ( | struct ccnr_handle * | h | ) |
Definition at line 457 of file ccnr_store.c.
Referenced by r_init_create().
static struct content_entry* r_store_look | ( | struct ccnr_handle * | h, | |
const unsigned char * | key, | |||
size_t | size | |||
) | [static, read] |
Get a handle on the content object that matches key, or if there is no match, the one that would come just after it.
The key is in flatname format.
Definition at line 789 of file ccnr_store.c.
Referenced by r_store_content_next(), r_store_find_first_match_candidate(), r_store_lookup_backwards(), r_store_lookup_ccnb(), and r_store_next_child_at_level().
PUBLIC struct content_entry* r_store_lookup | ( | struct ccnr_handle * | h, | |
const unsigned char * | msg, | |||
const struct ccn_parsed_interest * | pi, | |||
struct ccn_indexbuf * | comps | |||
) | [read] |
Definition at line 1074 of file ccnr_store.c.
Referenced by r_proto_answer_req(), r_proto_start_write_checked(), and r_sync_lookup().
static struct content_entry* r_store_lookup_backwards | ( | struct ccnr_handle * | h, | |
const unsigned char * | interest_msg, | |||
const struct ccn_parsed_interest * | pi, | |||
struct ccn_indexbuf * | comps | |||
) | [static, read] |
Definition at line 907 of file ccnr_store.c.
Referenced by r_store_lookup().
PUBLIC struct content_entry* r_store_lookup_ccnb | ( | struct ccnr_handle * | h, | |
const unsigned char * | namish, | |||
size_t | size | |||
) | [read] |
Find the first content handle that matches the prefix given by the namish, which may be a Name, Interest, ContentObject, .
..
Does not check the other parts of namish, in particular, does not generate the digest component of a ContentObject.
Definition at line 1161 of file ccnr_store.c.
Referenced by load_policy(), and r_proto_policy_update().
PUBLIC void r_store_mark_stale | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) |
Mark content as stale.
Definition at line 1192 of file ccnr_store.c.
Referenced by expire_content().
PUBLIC int r_store_name_append_components | ( | struct ccn_charbuf * | dst, | |
struct ccnr_handle * | h, | |||
struct content_entry * | content, | |||
int | skip, | |||
int | count | |||
) |
Definition at line 297 of file ccnr_store.c.
Referenced by r_match_match_interests(), r_proto_continue_enumeration(), and r_sync_notify_content().
PUBLIC struct content_entry* r_store_next_child_at_level | ( | struct ccnr_handle * | h, | |
struct content_entry * | content, | |||
int | level | |||
) | [read] |
Definition at line 1033 of file ccnr_store.c.
Referenced by r_proto_continue_enumeration(), and r_store_lookup().
static off_t r_store_offset_from_accession | ( | struct ccnr_handle * | h, | |
ccnr_accession | a | |||
) | [static] |
Definition at line 127 of file ccnr_store.c.
Referenced by r_store_content_read().
static void r_store_read_stable_point | ( | struct ccnr_handle * | h | ) | [static] |
Read the former size of repoFile1 from index/stable, and remove the latter.
Definition at line 375 of file ccnr_store.c.
Referenced by r_store_init().
static int r_store_reindexing | ( | struct ccn_schedule * | sched, | |
void * | clienth, | |||
struct ccn_scheduled_event * | ev, | |||
int | flags | |||
) | [static] |
Log a bit if we are taking a while to re-index.
Definition at line 420 of file ccnr_store.c.
Referenced by r_store_init().
static unsigned r_store_repofile_from_accession | ( | struct ccnr_handle * | h, | |
ccnr_accession | a | |||
) | [static] |
Definition at line 133 of file ccnr_store.c.
Referenced by r_store_content_read().
PUBLIC void r_store_send_content | ( | struct ccnr_handle * | h, | |
struct fdholder * | fdholder, | |||
struct content_entry * | content | |||
) |
Definition at line 1437 of file ccnr_store.c.
Referenced by r_link_send_content(), and r_store_commit_content().
PUBLIC int r_store_set_accession_from_offset | ( | struct ccnr_handle * | h, | |
struct content_entry * | content, | |||
struct fdholder * | fdholder, | |||
off_t | offset | |||
) |
Definition at line 1392 of file ccnr_store.c.
Referenced by r_store_send_content().
PUBLIC void r_store_set_content_timer | ( | struct ccnr_handle * | h, | |
struct content_entry * | content, | |||
struct ccn_parsed_ContentObject * | pco | |||
) |
Schedules content expiration based on its FreshnessSeconds.
Definition at line 1233 of file ccnr_store.c.
Referenced by process_incoming_content().
static int r_store_set_flatname | ( | struct ccnr_handle * | h, | |
struct content_entry * | content, | |||
struct ccn_parsed_ContentObject * | pco | |||
) | [static] |
Parses content object and sets content->flatname.
Definition at line 1269 of file ccnr_store.c.
Referenced by process_incoming_content(), and r_store_content_from_accession().
PUBLIC void r_store_trim | ( | struct ccnr_handle * | h, | |
unsigned long | limit | |||
) |
Evict recoverable content from in-memory buffers.
Definition at line 229 of file ccnr_store.c.
Referenced by r_dispatch_run(), and r_init_create().
static int r_store_write_stable_point | ( | struct ccnr_handle * | h | ) | [static] |
Write a file named index/stable that contains the size of repoFile1 when the repository is shut down.
Definition at line 331 of file ccnr_store.c.
Referenced by r_store_final().
const unsigned char* bogon = NULL [static] |
Definition at line 79 of file ccnr_store.c.
Referenced by r_store_content_base().
const ccnr_accession r_store_mark_repoFile1 = ((ccnr_accession)1) << 48 |
Definition at line 80 of file ccnr_store.c.
Referenced by process_incoming_content(), and r_store_set_accession_from_offset().