MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / init_ds_data

Function init_ds_data

modules/dispatcher/dispatch.c:76–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74};
75
76int init_ds_data(ds_partition_t *partition)
77{
78#define PART_SR_EVENTS_SUFFIX ";events"
79#define PART_SR_EVENTS_SUFFIX_LEN (sizeof(PART_SR_EVENTS_SUFFIX)-1)
80
81 partition->data = (ds_data_t**)shm_malloc( sizeof(ds_data_t*) );
82 if (partition->data==NULL) {
83 LM_ERR("failed to allocate data holder in shm\n");
84 return -1;
85 }
86
87 *partition->data = NULL;
88
89 /* create & init lock */
90 if ((partition->lock = lock_init_rw()) == NULL) {
91 LM_CRIT("failed to init reader/writer lock\n");
92 return -1;
93 }
94
95 if (sr_register_identifier( ds_srg, STR2CI(partition->name),
96 SR_STATUS_NO_DATA, CHAR_INT("no data loaded"), 20 ) ) {
97 LM_ERR("failed to register status report identifier\n");
98 return -1;
99 }
100
101 /* status report stuff */
102 partition->sr_events_ident.s = shm_malloc(partition->name.len +
103 PART_SR_EVENTS_SUFFIX_LEN);
104 if (partition->sr_events_ident.s==NULL) {
105 LM_ERR("failed to allocate SR identifier name for events\n");
106 return -1;
107 }
108 memcpy(partition->sr_events_ident.s, partition->name.s,
109 partition->name.len);
110 memcpy(partition->sr_events_ident.s + partition->name.len,
111 PART_SR_EVENTS_SUFFIX , PART_SR_EVENTS_SUFFIX_LEN);
112 partition->sr_events_ident.len = partition->name.len +
113 PART_SR_EVENTS_SUFFIX_LEN;
114
115 if (sr_register_identifier( ds_srg, STR2CI(partition->sr_events_ident),
116 SR_STATUS_READY, NULL, 0, 200 ) ) {
117 LM_ERR("failed to register status report event identifier\n");
118 return -1;
119 }
120
121
122 return 0;
123}
124
125
126/* destroy entire dispatching data */

Callers 1

mod_initFunction · 0.85

Calls 3

shm_mallocFunction · 0.85
lock_init_rwFunction · 0.85
sr_register_identifierFunction · 0.85

Tested by

no test coverage detected