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. | |
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) |
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 |
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 1351 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 1353 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 93 of file ccnr_store.c.
#define CHKRES | ( | res | ) | FAILIF((res) < 0) |
Definition at line 92 of file ccnr_store.c.
#define CHKSYS | ( | res | ) | FAILIF((res) == -1) |
Definition at line 91 of file ccnr_store.c.
#define FAILIF | ( | cond | ) | do {} while ((cond) && r_store_fatal(h, __func__, __LINE__)) |
Definition at line 90 of file ccnr_store.c.
PUBLIC void ccnr_debug_content | ( | struct ccnr_handle * | h, | |
int | lineno, | |||
const char * | msg, | |||
struct fdholder * | fdholder, | |||
struct content_entry * | content | |||
) |
Definition at line 1329 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 436 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 1081 of file ccnr_store.c.
PUBLIC struct content_entry* process_incoming_content | ( | struct ccnr_handle * | h, | |
struct fdholder * | fdholder, | |||
unsigned char * | msg, | |||
size_t | size | |||
) | [read] |
Definition at line 1180 of file ccnr_store.c.
PUBLIC int r_store_commit_content | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) |
Definition at line 1318 of file ccnr_store.c.
Referenced by 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 108 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 265 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 667 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 | |||
) |
PUBLIC ccnr_cookie r_store_content_cookie | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) |
Definition at line 114 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 1226 of file ccnr_store.c.
PUBLIC int r_store_content_flags | ( | struct content_entry * | content | ) |
Definition at line 313 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 1174 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 578 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 621 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] |
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 887 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 904 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] |
PUBLIC size_t r_store_content_size | ( | struct ccnr_handle * | h, | |
struct content_entry * | content | |||
) |
Definition at line 120 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 216 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 636 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 96 of file ccnr_store.c.
PUBLIC int r_store_final | ( | struct ccnr_handle * | h, | |
int | stable | |||
) |
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 825 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 730 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] |
PUBLIC void r_store_index_needs_cleaning | ( | struct ccnr_handle * | h | ) |
Definition at line 1450 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 | ) |
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 780 of file ccnr_store.c.
Referenced by r_store_content_next(), r_store_find_first_match_candidate(), 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 956 of file ccnr_store.c.
Referenced by r_proto_answer_req(), r_proto_start_write_checked(), and r_sync_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 1030 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 1061 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 298 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 915 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] |
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 366 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 411 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] |
PUBLIC void r_store_send_content | ( | struct ccnr_handle * | h, | |
struct fdholder * | fdholder, | |||
struct content_entry * | content | |||
) |
Definition at line 1297 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 1252 of file ccnr_store.c.
Referenced by process_input_message(), and 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 1102 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 1133 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 230 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 332 of file ccnr_store.c.
Referenced by r_store_final().
const unsigned char* bogon = NULL [static] |
const ccnr_accession r_store_mark_repoFile1 = ((ccnr_accession)1) << 48 |