+2004-12-14 Ken Raeburn <raeburn@mit.edu>
+
+ * prof_tree.c (profile_node_iterator): When the iterator has a
+ current file, lock it, and unlock it before changing it or
+ returning.
+
2004-11-04 Alexandra Ellwood <lxs@mit.edu>
* prof_init.c, profile.hin: added profile_is_modified
* If the file has changed, then the node pointer is invalid,
* so we'll have search the file again looking for it.
*/
+ if (iter->file) {
+ retval = k5_mutex_lock(&iter->file->data->lock);
+ if (retval)
+ return retval;
+ }
if (iter->node && (iter->file->data->upd_serial != iter->file_serial)) {
iter->flags &= ~PROFILE_ITER_FINAL_SEEN;
skip_num = iter->num;
iter->node = 0;
}
- if (iter->node && iter->node->magic != PROF_MAGIC_NODE)
+ if (iter->node && iter->node->magic != PROF_MAGIC_NODE) {
+ if (iter->file)
+ k5_mutex_unlock(&iter->file->data->lock);
return PROF_MAGIC_NODE;
+ }
get_new_file:
if (iter->node == 0) {
if (iter->file == 0 ||
(iter->flags & PROFILE_ITER_FINAL_SEEN)) {
+ if (iter->file)
+ k5_mutex_unlock(&iter->file->data->lock);
profile_node_iterator_free(iter_p);
if (ret_node)
*ret_node = 0;
*ret_value =0;
return 0;
}
+ k5_mutex_unlock(&iter->file->data->lock);
if ((retval = profile_update_file(iter->file))) {
if (retval == ENOENT || retval == EACCES) {
/* XXX memory leak? */
iter->file = iter->file->next;
+ if (iter->file) {
+ retval = k5_mutex_lock(&iter->file->data->lock);
+ if (retval) {
+ profile_node_iterator_free(iter_p);
+ return retval;
+ }
+ }
skip_num = 0;
retval = 0;
goto get_new_file;
return retval;
}
}
+ retval = k5_mutex_lock(&iter->file->data->lock);
+ if (retval) {
+ profile_node_iterator_free(iter_p);
+ return retval;
+ }
iter->file_serial = iter->file->data->upd_serial;
/*
* Find the section to list if we are a LIST_SECTION,
iter->flags |= PROFILE_ITER_FINAL_SEEN;
}
if (!section) {
+ k5_mutex_unlock(&iter->file->data->lock);
iter->file = iter->file->next;
+ if (iter->file) {
+ retval = k5_mutex_lock(&iter->file->data->lock);
+ if (retval) {
+ profile_node_iterator_free(iter_p);
+ return retval;
+ }
+ }
skip_num = 0;
goto get_new_file;
}
}
iter->num++;
if (!p) {
+ k5_mutex_unlock(&iter->file->data->lock);
iter->file = iter->file->next;
+ if (iter->file) {
+ retval = k5_mutex_lock(&iter->file->data->lock);
+ if (retval) {
+ profile_node_iterator_free(iter_p);
+ return retval;
+ }
+ }
iter->node = 0;
skip_num = 0;
goto get_new_file;
}
+ k5_mutex_unlock(&iter->file->data->lock);
if ((iter->node = p->next) == NULL)
iter->file = iter->file->next;
if (ret_node)