Skip to content

Commit

Permalink
resource: worker-control: make worker initial cleanup a part of the w…
Browse files Browse the repository at this point in the history
…orker init callback

It is actually the responsibility of the worker init callback as defined by
struct worker_control_resource_params.init_cb_spec to set up everything needed
for the worker, including any cleanup.
  • Loading branch information
prajnoha committed Feb 3, 2021
1 parent 6587ce2 commit 42a8157
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/resource/ubridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -3889,12 +3889,17 @@ static int _worker_init_fn(sid_resource_t *worker_res, void *arg)
&sid_resource_type_kv_store, MAIN_KV_STORE_NAME)))
return -ENOMEDIUM;

/* we take only inherited modules and kv_store for the worker */
(void) sid_resource_isolate_with_children(modules_res);
(void) sid_resource_isolate_with_children(kv_store_res);

(void) sid_resource_add_child(worker_res, modules_res, SID_RESOURCE_NO_FLAGS);
(void) sid_resource_add_child(worker_res, kv_store_res, SID_RESOURCE_RESTRICT_WALK_UP);


/* destroy the rest */
(void) sid_resource_unref(sid_resource_search(ubridge_internal_res, SID_RESOURCE_SEARCH_TOP, NULL, NULL));

return 0;
}

Expand Down
3 changes: 0 additions & 3 deletions src/resource/worker-control.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,6 @@ sid_resource_t *worker_control_get_new_worker(sid_resource_t *worker_control_res

if (worker_control->init_cb_spec.cb)
(void) worker_control->init_cb_spec.cb(res, worker_control->init_cb_spec.arg);

/* destroy the unneeded and inherited "sid" resource from parent */
(void) sid_resource_unref(sid_resource_search(worker_control_res, SID_RESOURCE_SEARCH_TOP, NULL, NULL));
} else {
/*
* WORKER_TYPE_EXTERNAL
Expand Down

0 comments on commit 42a8157

Please sign in to comment.