@@ -65,14 +65,18 @@ OBJ_CLASS_INSTANCE(opal_info_entry_t, opal_list_item_t, info_entry_constructor,
6565 info_entry_destructor );
6666
6767/*
68- * Duplicate an info
68+ * Duplicate an info into newinfo. If public_info is true we only duplicate
69+ * key-value pairs that are not internal and that had been referenced,
70+ * either through opal_info_get or opal_info_set.
6971 */
70- int opal_info_dup (opal_info_t * info , opal_info_t * * newinfo )
72+ static int opal_info_dup_impl (opal_info_t * info , opal_info_t * * newinfo , bool public_only )
7173{
7274 opal_info_entry_t * iterator ;
7375
7476 OPAL_THREAD_LOCK (info -> i_lock );
7577 OPAL_LIST_FOREACH (iterator , & info -> super , opal_info_entry_t ) {
78+ /* skip keys that are internal if we didn't ask for them */
79+ if (public_only && (iterator -> ie_internal || iterator -> ie_referenced == 0 )) continue ;
7680 /* create a new info entry and retain the string objects */
7781 opal_info_entry_t * newentry = OBJ_NEW (opal_info_entry_t );
7882 newentry -> ie_key = iterator -> ie_key ;
@@ -85,6 +89,16 @@ int opal_info_dup(opal_info_t *info, opal_info_t **newinfo)
8589 return OPAL_SUCCESS ;
8690}
8791
92+ int opal_info_dup_public (opal_info_t * info , opal_info_t * * newinfo )
93+ {
94+ return opal_info_dup_impl (info , newinfo , true);
95+ }
96+
97+ int opal_info_dup (opal_info_t * info , opal_info_t * * newinfo )
98+ {
99+ return opal_info_dup_impl (info , newinfo , false);
100+ }
101+
88102static void opal_info_get_nolock (opal_info_t * info , const char * key , opal_cstring_t * * value ,
89103 int * flag )
90104{
@@ -136,7 +150,7 @@ static int opal_info_set_cstring_nolock(opal_info_t *info, const char *key, opal
136150 return OPAL_SUCCESS ;
137151}
138152
139- static int opal_info_set_nolock (opal_info_t * info , const char * key , const char * value )
153+ static int opal_info_set_nolock (opal_info_t * info , const char * key , const char * value , bool internal )
140154{
141155 opal_info_entry_t * old_info ;
142156
@@ -147,6 +161,7 @@ static int opal_info_set_nolock(opal_info_t *info, const char *key, const char *
147161 */
148162 size_t value_len = strlen (value );
149163 old_info -> ie_referenced ++ ;
164+ old_info -> ie_internal = internal ;
150165 if (old_info -> ie_value -> length == value_len
151166 && 0 == strcmp (old_info -> ie_value -> string , value )) {
152167 return OPAL_SUCCESS ;
@@ -171,6 +186,7 @@ static int opal_info_set_nolock(opal_info_t *info, const char *key, const char *
171186 return OPAL_ERR_OUT_OF_RESOURCE ;
172187 }
173188 new_info -> ie_referenced ++ ;
189+ new_info -> ie_internal = internal ;
174190 opal_list_append (& (info -> super ), (opal_list_item_t * ) new_info );
175191 }
176192 return OPAL_SUCCESS ;
@@ -184,7 +200,20 @@ int opal_info_set(opal_info_t *info, const char *key, const char *value)
184200 int ret ;
185201
186202 OPAL_THREAD_LOCK (info -> i_lock );
187- ret = opal_info_set_nolock (info , key , value );
203+ ret = opal_info_set_nolock (info , key , value , false);
204+ OPAL_THREAD_UNLOCK (info -> i_lock );
205+ return ret ;
206+ }
207+
208+ /*
209+ * Set a value on the info
210+ */
211+ int opal_info_set_internal (opal_info_t * info , const char * key , const char * value )
212+ {
213+ int ret ;
214+
215+ OPAL_THREAD_LOCK (info -> i_lock );
216+ ret = opal_info_set_nolock (info , key , value , true);
188217 OPAL_THREAD_UNLOCK (info -> i_lock );
189218 return ret ;
190219}
@@ -372,6 +401,7 @@ static void info_entry_constructor(opal_info_entry_t *entry)
372401 entry -> ie_key = NULL ;
373402 entry -> ie_value = NULL ;
374403 entry -> ie_referenced = 0 ;
404+ entry -> ie_internal = false;
375405}
376406
377407static void info_entry_destructor (opal_info_entry_t * entry )
@@ -410,52 +440,3 @@ static opal_info_entry_t *info_find_key(opal_info_t *info, const char *key)
410440 }
411441 return NULL ;
412442}
413-
414- /**
415- * Mark the entry \c key as referenced.
416- */
417- int opal_info_mark_referenced (opal_info_t * info , const char * key )
418- {
419- opal_info_entry_t * entry ;
420-
421- OPAL_THREAD_LOCK (info -> i_lock );
422- entry = info_find_key (info , key );
423- entry -> ie_referenced ++ ;
424- OPAL_THREAD_UNLOCK (info -> i_lock );
425-
426- return OPAL_SUCCESS ;
427- }
428-
429- /**
430- * Remove a reference from the entry \c key.
431- */
432- int opal_info_unmark_referenced (opal_info_t * info , const char * key )
433- {
434- opal_info_entry_t * entry ;
435-
436- OPAL_THREAD_LOCK (info -> i_lock );
437- entry = info_find_key (info , key );
438- entry -> ie_referenced -- ;
439- OPAL_THREAD_UNLOCK (info -> i_lock );
440-
441- return OPAL_SUCCESS ;
442- }
443-
444- /**
445- * Remove any entries that are not marked as referenced
446- */
447- int opal_info_remove_unreferenced (opal_info_t * info )
448- {
449- opal_info_entry_t * iterator , * next ;
450- /* iterate over all entries and remove the ones that are not referenced */
451- OPAL_THREAD_LOCK (info -> i_lock );
452- OPAL_LIST_FOREACH_SAFE (iterator , next , & info -> super , opal_info_entry_t ) {
453- if (!iterator -> ie_referenced ) {
454- opal_list_remove_item (& info -> super , & iterator -> super );
455- }
456- }
457- OPAL_THREAD_UNLOCK (info -> i_lock );
458-
459-
460- return OPAL_SUCCESS ;
461- }
0 commit comments