Skip to content

Commit 40a6606

Browse files
committed
Do not use mutex lock during mca_base_source_get_by_name()
Signed-off-by: Kingshuk Haldar <[email protected]>
1 parent 2233aef commit 40a6606

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

opal/mca/base/mca_base_source.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,12 @@ int mca_base_source_get_count (int *count)
160160
return OPAL_SUCCESS;
161161
}
162162

163+
/* This function should be under mca_base_source_lock. */
164+
/* Due to this being called only from mca_base_source_register() currently, */
165+
/* and that is under such lock, there aren't any locks here. */
166+
/* This should be considered if this needs to be called from somewhere else. */
163167
static inline int mca_base_source_get_by_name (const char *name, mca_base_source_t **source_out)
164168
{
165-
OPAL_THREAD_LOCK(&mca_base_source_lock);
166-
167169
/* there are expected to be a relatively small number of sources so a linear search should be fine */
168170
for (int i = 0 ; i < source_count ; ++i) {
169171
mca_base_source_t *source = opal_pointer_array_get_item (&registered_sources, i);
@@ -172,12 +174,10 @@ static inline int mca_base_source_get_by_name (const char *name, mca_base_source
172174
*source_out = source;
173175
}
174176

175-
OPAL_THREAD_UNLOCK(&mca_base_source_lock);
176177
return OPAL_SUCCESS;
177178
}
178179
}
179180

180-
OPAL_THREAD_UNLOCK(&mca_base_source_lock);
181181
return OPAL_ERR_NOT_FOUND;
182182
}
183183

0 commit comments

Comments
 (0)