Ejemplo n.º 1
0
void profile_dereference_data(prf_data_t data)
{
    int err;
    err = k5_mutex_lock(&g_shared_trees_mutex);
    if (err)
	return;
    profile_dereference_data_locked(data);
    (void) k5_mutex_unlock(&g_shared_trees_mutex);
}
Ejemplo n.º 2
0
static errcode_t rw_setup(profile_t profile)
{
   	prf_file_t	file;
	errcode_t	retval = 0;

	if (!profile)
		return PROF_NO_PROFILE;

	if (profile->magic != PROF_MAGIC_PROFILE)
		return PROF_MAGIC_PROFILE;

	file = profile->first_file;

	retval = profile_lock_global();
	if (retval)
	    return retval;

	/* Don't update the file if we've already made modifications */
	if (file->data->flags & PROFILE_FILE_DIRTY) {
	    profile_unlock_global();
	    return 0;
	}

	if ((file->data->flags & PROFILE_FILE_SHARED) != 0) {
	    prf_data_t new_data;
	    new_data = profile_make_prf_data(file->data->filespec);
	    if (new_data == NULL) {
		retval = ENOMEM;
	    } else {
		retval = k5_mutex_init(&new_data->lock);
		if (retval == 0) {
		    new_data->root = NULL;
		    new_data->flags = file->data->flags & ~PROFILE_FILE_SHARED;
		    new_data->timestamp = 0;
		    new_data->upd_serial = file->data->upd_serial;
		}
	    }

	    if (retval != 0) {
		profile_unlock_global();
		free(new_data);
		return retval;
	    }
	    profile_dereference_data_locked(file->data);
	    file->data = new_data;
	}

	profile_unlock_global();
	retval = profile_update_file(file);

	return retval;
}
Ejemplo n.º 3
0
void profile_dereference_data(prf_data_t data)
{
    k5_mutex_lock(&g_shared_trees_mutex);
    profile_dereference_data_locked(data);
    k5_mutex_unlock(&g_shared_trees_mutex);
}