- hash_pair_t *hp;
- u8 *name_copy;
-
- stat_segment_name = cm->stat_segment_name ?
- cm->stat_segment_name : cm->name;
-
- clib_spinlock_lock (sm->stat_segment_lockp);
-
- /* Update hash table. The name must be copied into the segment */
- hp = hash_get_pair (sm->counter_vector_by_name, stat_segment_name);
- if (hp)
- {
- name_copy = (u8 *) hp->key;
- ep = (stat_segment_directory_entry_t *) (hp->value[0]);
- hash_unset_mem (sm->counter_vector_by_name, stat_segment_name);
- vec_free (name_copy);
- clib_mem_free (ep);
- }
- name_copy = format (0, "%s%c", stat_segment_name, 0);
- ep = clib_mem_alloc (sizeof (*ep));
- ep->type = STAT_DIR_TYPE_COUNTER_VECTOR;
- ep->value = cm->counters;
- hash_set_mem (sm->counter_vector_by_name, name_copy, ep);
-
- /* Reset the client hash table pointer, since it WILL change! */
- shared_header->opaque[STAT_SEGMENT_OPAQUE_DIR]
- = sm->counter_vector_by_name;
-
- /* Warn clients to refresh any pointers they might be holding */
- shared_header->opaque[STAT_SEGMENT_OPAQUE_EPOCH] = (void *)
- ((u64) shared_header->opaque[STAT_SEGMENT_OPAQUE_EPOCH] + 1);
- clib_spinlock_unlock (sm->stat_segment_lockp);