Changeset 102f641 in mainline for uspace/srv
- Timestamp:
- 2019-09-02T19:01:50Z (6 years ago)
- Children:
- 25697163
- Parents:
- 241f1985
- Location:
- uspace/srv
- Files:
-
- 40 edited
-
devman/drv_conn.c (modified) (1 diff)
-
hid/compositor/compositor.c (modified) (2 diffs)
-
loader/main.c (modified) (3 diffs)
-
locsrv/locsrv.c (modified) (4 diffs)
-
net/loopip/loopip.c (modified) (1 diff)
-
ns/ns.c (modified) (2 diffs)
-
sysman/connection_broker.c (modified) (3 diffs)
-
sysman/connection_ctl.c (modified) (10 diffs)
-
sysman/edge.c (modified) (1 diff)
-
sysman/edge.h (modified) (1 diff)
-
sysman/job.c (modified) (2 diffs)
-
sysman/job.h (modified) (1 diff)
-
sysman/job_closure.c (modified) (8 diffs)
-
sysman/job_queue.c (modified) (3 diffs)
-
sysman/log.c (modified) (2 diffs)
-
sysman/main.c (modified) (4 diffs)
-
sysman/repo.c (modified) (3 diffs)
-
sysman/repo.h (modified) (1 diff)
-
sysman/sm_task.c (modified) (4 diffs)
-
sysman/sysman.c (modified) (4 diffs)
-
sysman/sysman.h (modified) (1 diff)
-
sysman/test/job_closure.c (modified) (7 diffs)
-
sysman/test/job_queue.c (modified) (10 diffs)
-
sysman/test/main.c (modified) (1 diff)
-
sysman/test/mock_unit.c (modified) (1 diff)
-
sysman/unit.c (modified) (4 diffs)
-
sysman/unit.h (modified) (1 diff)
-
sysman/units/unit_cfg.c (modified) (4 diffs)
-
sysman/units/unit_mnt.c (modified) (5 diffs)
-
sysman/units/unit_mnt.h (modified) (2 diffs)
-
sysman/units/unit_svc.c (modified) (6 diffs)
-
sysman/units/unit_svc.h (modified) (1 diff)
-
sysman/units/unit_tgt.c (modified) (1 diff)
-
sysman/util.c (modified) (2 diffs)
-
taskman/event.c (modified) (8 diffs)
-
taskman/main.c (modified) (7 diffs)
-
taskman/task.c (modified) (8 diffs)
-
taskman/task.h (modified) (2 diffs)
-
vfs/vfs.c (modified) (1 diff)
-
vfs/vfs_register.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/drv_conn.c
r241f1985 r102f641 115 115 sysman_main_exposee_added(unit_name, call->task_id); 116 116 free(unit_name); 117 117 118 118 switch (driver->state) { 119 119 case DRIVER_NOT_STARTED: -
uspace/srv/hid/compositor/compositor.c
r241f1985 r102f641 2305 2305 /* Finally, register compositor server. */ 2306 2306 async_set_fallback_port_handler(client_connection, NULL); 2307 2307 2308 2308 rc = loc_server_register(NAME); 2309 2309 if (rc != EOK) { … … 2311 2311 return rc; 2312 2312 } 2313 2313 2314 2314 server_name = name; 2315 2315 2316 2316 /* Prepare window registrator (entrypoint for clients). */ 2317 2317 char winreg[LOC_NAME_MAXLEN + 1]; -
uspace/srv/loader/main.c
r241f1985 r102f641 43 43 * and completely hidden from applications. 44 44 */ 45 46 45 47 46 #include <stdio.h> … … 443 442 /* Set a handler of incomming connections. */ 444 443 async_set_fallback_port_handler(ldr_connection, NULL); 445 444 446 445 /* Announce to taskman. */ 447 446 errno_t rc = taskman_intro_loader(); … … 457 456 */ 458 457 async_manager(); 459 458 460 459 /* Never reached */ 461 460 return 0; -
uspace/srv/locsrv/locsrv.c
r241f1985 r102f641 608 608 609 609 list_append(&service->server_services, &service->server->services); 610 610 611 611 fibril_mutex_unlock(&service->server->services_mutex); 612 612 fibril_condvar_broadcast(&services_list_cv); … … 841 841 int flags = ipc_get_arg1(icall); 842 842 bool start_requested = false; 843 843 844 844 recheck: 845 845 … … 853 853 */ 854 854 if (svc == NULL) { 855 /* TODO: 855 /* 856 * TODO: 856 857 * Consider non-blocking service start, return some dummy id 857 858 * and block only after connection request (actually makes more … … 892 893 async_answer_0(icall, rc); 893 894 } 894 895 895 896 fibril_mutex_unlock(&services_list_mutex); 896 897 free(ns_name); -
uspace/srv/net/loopip/loopip.c
r241f1985 r102f641 116 116 117 117 prodcons_initialize(&loopip_rcv_queue); 118 118 119 119 const char *svc_name = SERVICE_NAME_LOOPBACK; 120 120 service_id_t sid; -
uspace/srv/ns/ns.c
r241f1985 r102f641 118 118 if (rc != EOK) 119 119 return rc; 120 120 121 121 rc = taskman_intro_ns_noasync(); 122 122 if (rc != EOK) { … … 125 125 } 126 126 task_retval_noasync(0); 127 127 128 128 async_set_fallback_port_handler(ns_connection, NULL); 129 129 130 130 printf("%s: Accepting connections\n", NAME); 131 131 132 132 async_manager(); 133 133 -
uspace/srv/sysman/connection_broker.c
r241f1985 r102f641 96 96 } 97 97 98 99 98 retval = ENOTSUP; 100 99 … … 119 118 while (true) { 120 119 ipc_call_t call; 121 120 122 121 if (!async_get_call(&call) || !ipc_get_imethod(&call)) { 123 122 /* Client disconnected */ … … 146 145 } 147 146 } 148 149 -
uspace/srv/sysman/connection_ctl.c
r241f1985 r102f641 41 41 #include "sysman.h" 42 42 43 44 43 // TODO possibly provide as type-safe function + macro in sysman.h for generic boxing 45 44 static ipc_call_t *box_callid(ipc_call_t *icall) … … 215 214 size_t act_size; 216 215 int rc; 217 216 218 217 if (!async_data_read_receive(&call, &size)) { 219 218 async_answer_0(&call, EREFUSED); … … 221 220 return; 222 221 } 223 224 222 225 223 unit_handle_t *handles = malloc(size); 226 224 if (handles == NULL && size > 0) { … … 229 227 return; 230 228 } 231 232 229 233 230 rc = fill_handles_buffer(handles, size, &act_size); 234 231 if (rc != EOK) { … … 237 234 return; 238 235 } 239 236 240 237 size_t real_size = min(act_size, size); 241 238 sysarg_t retval = async_data_read_finalize(&call, handles, real_size); 242 239 free(handles); 243 240 244 241 async_answer_1(icall, retval, act_size); 245 242 } … … 249 246 ipc_call_t call; 250 247 size_t size; 251 248 252 249 if (!async_data_read_receive(&call, &size)) { 253 250 async_answer_0(&call, EREFUSED); … … 255 252 return; 256 253 } 257 254 258 255 unit_t *u = repo_find_unit_by_handle(ipc_get_arg1(icall)); 259 256 if (u == NULL) { … … 262 259 return; 263 260 } 264 261 265 262 size_t real_size = min(str_size(u->name) + 1, size); 266 263 sysarg_t retval = async_data_read_finalize(&call, u->name, real_size); 267 264 268 265 async_answer_0(icall, retval); 269 266 } … … 303 300 while (true) { 304 301 ipc_call_t call; 305 302 306 303 if (!async_get_call(&call) || !ipc_get_imethod(&call)) { 307 304 /* Client disconnected */ … … 339 336 } 340 337 } 341 -
uspace/srv/sysman/edge.c
r241f1985 r102f641 118 118 } 119 119 120 121 120 /** 122 121 * @return EOK on success -
uspace/srv/sysman/edge.h
r241f1985 r102f641 71 71 extern void edge_remove(unit_edge_t **); 72 72 73 74 73 #endif 75 76 -
uspace/srv/sysman/job.c
r241f1985 r102f641 39 39 #include "sysman.h" 40 40 41 42 41 /* 43 42 * Static functions 44 43 */ 45 46 44 47 45 /** Remove blocking_job from blocked job structure … … 273 271 sysman_raise_event(&sysman_event_job_finished, job); 274 272 } 275 -
uspace/srv/sysman/job.h
r241f1985 r102f641 65 65 /** Jobs that this job is preventing from running */ 66 66 dyn_array_t blocked_jobs; 67 /** No. of jobs that the job is actually blocking (may differ from size 68 * of blocked_jobs for not fully merged job */ 67 /** 68 * No. of jobs that the job is actually blocking (may differ from size 69 * of blocked_jobs for not fully merged job 70 */ 69 71 size_t blocked_jobs_count; 70 72 /** No. of jobs that must finish before this job */ -
uspace/srv/sysman/job_closure.c
r241f1985 r102f641 37 37 #include "log.h" 38 38 39 40 39 /** Struct describes how to traverse units graph */ 41 40 struct bfs_ops; … … 52 51 * return result of visit (error stops further traversal) 53 52 */ 54 int (* visit)(unit_t *, unit_edge_t *, bfs_ops_t *, void *);53 int (*visit)(unit_t *, unit_edge_t *, bfs_ops_t *, void *); 55 54 56 55 /** Clean units remaining in BFS queue after error */ 57 void (* clean)(unit_t *, bfs_ops_t *, void *);56 void (*clean)(unit_t *, bfs_ops_t *, void *); 58 57 }; 59 58 … … 65 64 { 66 65 assert(blocking_job->blocked_jobs.size == 67 blocking_job->blocked_jobs_count);66 blocking_job->blocked_jobs_count); 68 67 69 68 int rc = dyn_array_append(&blocking_job->blocked_jobs, job_t *, … … 203 202 unit->bfs_tag = true; 204 203 list_append(&unit->bfs_link, &units_fifo); 205 204 206 205 while (!list_empty(&units_fifo)) { 207 206 unit = list_get_instance(list_first(&units_fifo), unit_t, … … 209 208 list_remove(&unit->bfs_link); 210 209 211 212 if (ops->direction == BFS_FORWARD) 213 list_foreach(unit->edges_out, edges_out, unit_edge_t, e) { 214 unit_t *u = e->output; 215 if (!u->bfs_tag) { 216 u->bfs_tag = true; 217 list_append(&u->bfs_link, &units_fifo); 210 if (ops->direction == BFS_FORWARD) { 211 list_foreach(unit->edges_out, edges_out, unit_edge_t, e) { 212 unit_t *u = e->output; 213 if (!u->bfs_tag) { 214 u->bfs_tag = true; 215 list_append(&u->bfs_link, &units_fifo); 216 } 217 rc = ops->visit(u, e, ops, arg); 218 if (rc != EOK) { 219 goto finish; 220 } 218 221 } 219 rc = ops->visit(u, e, ops, arg); 220 if (rc != EOK) { 221 goto finish; 222 } 223 } else 224 list_foreach(unit->edges_in, edges_in, unit_edge_t, e) { 225 unit_t *u = e->input; 226 if (!u->bfs_tag) { 227 u->bfs_tag = true; 228 list_append(&u->bfs_link, &units_fifo); 229 } 230 rc = ops->visit(u, e, ops, arg); 231 if (rc != EOK) { 232 goto finish; 222 } else { 223 list_foreach(unit->edges_in, edges_in, unit_edge_t, e) { 224 unit_t *u = e->input; 225 if (!u->bfs_tag) { 226 u->bfs_tag = true; 227 list_append(&u->bfs_link, &units_fifo); 228 } 229 rc = ops->visit(u, e, ops, arg); 230 if (rc != EOK) { 231 goto finish; 232 } 233 233 } 234 234 } … … 243 243 list_remove(cur_link); 244 244 } 245 245 246 246 return rc; 247 247 } … … 349 349 } 350 350 351 352 351 /* Clean after ourselves (BFS tag jobs) */ 353 352 dyn_array_foreach(*job_closure, job_t *, job_it) { … … 360 359 return rc; 361 360 } 362 -
uspace/srv/sysman/job_queue.c
r241f1985 r102f641 230 230 } 231 231 232 /* Unmerged jobs are enqueued, merged are disposed 232 /* 233 * Unmerged jobs are enqueued, merged are disposed 233 234 * 234 235 * TODO Ensure that jobs that block merged jobs contain the corrent job … … 242 243 } 243 244 244 245 245 unit_t *u = job->unit; 246 246 assert(u->job == NULL); … … 274 274 } 275 275 } 276 277 -
uspace/srv/sysman/log.c
r241f1985 r102f641 39 39 static log_level_t max_level = LVL_NOTE; 40 40 41 externvoid sysman_log_init(log_level_t level)41 void sysman_log_init(log_level_t level) 42 42 { 43 43 max_level = level; … … 51 51 va_list args; 52 52 va_start(args, fmt); 53 53 54 54 vprintf(fmt, args); 55 55 printf("\n"); -
uspace/srv/sysman/main.c
r241f1985 r102f641 83 83 84 84 /** Build hard coded configuration */ 85 static errno_t create_entry_configuration(void) { 85 static errno_t create_entry_configuration(void) 86 { 86 87 errno_t rc; 87 88 unit_t *mnt_initrd = NULL; … … 108 109 cfg_init->name = str_dup(UNIT_CFG_INITRD); 109 110 CAST_CFG(cfg_init)->path = str_dup(INITRD_CFG_PATH); 110 111 111 112 tgt_init = unit_create(UNIT_TARGET); 112 113 if (tgt_init == NULL) { … … 115 116 } 116 117 tgt_init->name = str_dup(TARGET_INIT); 117 118 118 119 119 /* … … 160 160 } 161 161 job_del_ref(&job); 162 162 163 163 const char **target_name_ptr = arg; 164 164 prepare_and_run_job(target_name_ptr + 1); -
uspace/srv/sysman/repo.c
r241f1985 r102f641 107 107 } 108 108 109 110 109 static hash_table_ops_t units_by_name_ht_ops = { 111 110 .hash = &units_by_name_ht_hash, … … 133 132 { 134 133 sysman_log(LVL_DEBUG2, "%s(%s, %i)", __func__, name, lock); 135 if (lock) fibril_rwlock_read_lock(&repo_lock); 134 if (lock) 135 fibril_rwlock_read_lock(&repo_lock); 136 136 ht_link_t *ht_link = hash_table_find(&units_by_name, (void *)name); 137 if (lock) fibril_rwlock_read_unlock(&repo_lock); 137 if (lock) 138 fibril_rwlock_read_unlock(&repo_lock); 138 139 139 140 if (ht_link != NULL) { … … 177 178 } 178 179 179 void repo_begin_update(void) { 180 void repo_begin_update(void) 181 { 180 182 sysman_log(LVL_DEBUG2, "%s", __func__); 181 183 fibril_rwlock_write_lock(&repo_lock); -
uspace/srv/sysman/repo.h
r241f1985 r102f641 83 83 84 84 #endif 85 86 -
uspace/srv/sysman/sm_task.c
r241f1985 r102f641 38 38 #include "sm_task.h" 39 39 40 41 40 /** Structure for boxing task event */ 42 41 struct sm_task_event { … … 103 102 CAST_SVC(u_svc)->main_task_id = tid; 104 103 CAST_SVC(u_svc)->anonymous = true; 105 /* exec_start is left undefined, maybe could be hinted by kernel's task 106 * name */ 104 /* 105 * exec_start is left undefined, maybe could be hinted by kernel's task 106 * name 107 */ 107 108 108 109 /* … … 125 126 126 127 return CAST_SVC(u_svc); 127 128 128 129 fail: 129 130 if (in_repo_update) { … … 177 178 u_svc->unit.state = STATE_STARTING; 178 179 } 179 180 180 181 181 /* Simple incomplete state automaton */ -
uspace/srv/sysman/sysman.c
r241f1985 r102f641 40 40 #include "unit.h" 41 41 42 43 42 /* Do not expose this generally named type */ 44 43 typedef struct { … … 99 98 { 100 99 void *object = *(void **)key; 101 return ( 102 hash_table_get_inst(item, observed_object_t, ht_link)->object == 103 object); 100 return hash_table_get_inst(item, observed_object_t, ht_link)->object == 101 object; 104 102 } 105 103 … … 357 355 } 358 356 359 360 357 /* 361 358 * Event handlers … … 436 433 notify_observers(data); 437 434 } 438 -
uspace/srv/sysman/sysman.h
r241f1985 r102f641 53 53 extern errno_t sysman_run_job(unit_t *, unit_state_t, int, callback_handler_t, void *); 54 54 55 56 55 extern void sysman_raise_event(event_handler_t, void *); 57 56 extern void sysman_process_queue(void); -
uspace/srv/sysman/test/job_closure.c
r241f1985 r102f641 38 38 PCUT_INIT 39 39 40 40 PCUT_TEST_SUITE(job_closure); 41 41 42 static dyn_array_t exp_closure; 42 43 static dyn_array_t act_closure; … … 107 108 } 108 109 109 PCUT_TEST_SUITE(job_closure); 110 111 PCUT_TEST_BEFORE { 110 PCUT_TEST_BEFORE 111 { 112 112 mock_create_units(); 113 113 mock_set_units_state(STATE_STOPPED); … … 124 124 } 125 125 126 PCUT_TEST_AFTER { 126 PCUT_TEST_AFTER 127 { 127 128 destroy_job_closure(&act_closure); 128 129 dyn_array_destroy(&act_closure); … … 134 135 } 135 136 136 PCUT_TEST(job_closure_linear) { 137 PCUT_TEST(job_closure_linear) 138 { 137 139 unit_t *u0 = mock_units[UNIT_SERVICE][0]; 138 140 unit_t *u1 = mock_units[UNIT_SERVICE][1]; … … 165 167 } 166 168 167 PCUT_TEST(job_closure_fork) { 169 PCUT_TEST(job_closure_fork) 170 { 168 171 unit_t *u0 = mock_units[UNIT_SERVICE][0]; 169 172 unit_t *u1 = mock_units[UNIT_SERVICE][1]; … … 196 199 } 197 200 198 PCUT_TEST(job_closure_triangle) { 201 PCUT_TEST(job_closure_triangle) 202 { 199 203 unit_t *u0 = mock_units[UNIT_SERVICE][0]; 200 204 unit_t *u1 = mock_units[UNIT_SERVICE][1]; … … 230 234 } 231 235 232 PCUT_TEST(job_closure_isolate_linears) { 236 PCUT_TEST(job_closure_isolate_linears) 237 { 233 238 unit_t *u0 = mock_units[UNIT_SERVICE][0]; 234 239 unit_t *u1 = mock_units[UNIT_SERVICE][1]; -
uspace/srv/sysman/test/job_queue.c
r241f1985 r102f641 38 38 PCUT_INIT 39 39 40 PCUT_TEST_SUITE(job_queue); 41 40 42 static bool initialized = false; 41 43 … … 51 53 } 52 54 53 PCUT_TEST_SUITE(job_queue); 54 55 PCUT_TEST_BEFORE { 55 PCUT_TEST_BEFORE 56 { 56 57 mock_create_units(); 57 58 mock_set_units_state(STATE_STOPPED); … … 73 74 } 74 75 75 PCUT_TEST_AFTER { 76 PCUT_TEST_AFTER 77 { 76 78 mock_destroy_units(); 77 79 } 78 80 79 PCUT_TEST(single_start_sync) { 81 PCUT_TEST(single_start_sync) 82 { 80 83 unit_type_vmts[UNIT_TARGET]->start = &mock_unit_vmt_start_sync; 81 84 … … 94 97 } 95 98 96 PCUT_TEST(single_start_async) { 99 PCUT_TEST(single_start_async) 100 { 97 101 unit_type_vmts[UNIT_TARGET]->start = &mock_unit_vmt_start_async; 98 102 unit_type_vmts[UNIT_TARGET]->exposee_created = … … 117 121 } 118 122 119 PCUT_TEST(multipath_to_started_unit) { 123 PCUT_TEST(multipath_to_started_unit) 124 { 120 125 /* Setup mock behavior */ 121 126 unit_type_vmts[UNIT_SERVICE]->start = &mock_unit_vmt_start_sync; … … 133 138 mock_add_edge(s0, m0); 134 139 mock_add_edge(s1, m0); 135 140 136 141 /* S1 requires another mount and S0 */ 137 142 mock_add_edge(s1, s0); … … 152 157 } 153 158 154 PCUT_TEST(merge_jobs_with_callback) { 159 PCUT_TEST(merge_jobs_with_callback) 160 { 155 161 /* Setup mock behavior */ 156 162 unit_type_vmts[UNIT_SERVICE]->start = &mock_unit_vmt_start_async; … … 169 175 /* Job not finished */ 170 176 PCUT_ASSERT_NULL(j0); 171 172 177 173 178 /* … … 188 193 PCUT_ASSERT_NOT_NULL(j0); 189 194 PCUT_ASSERT_NOT_NULL(j1); 190 195 191 196 /* 192 197 * Jobs were, merged so both callbacks should have been called with the … … 202 207 } 203 208 204 205 209 PCUT_EXPORT(job_queue); -
uspace/srv/sysman/test/main.c
r241f1985 r102f641 34 34 PCUT_IMPORT(job_queue); 35 35 36 PCUT_MAIN() 36 PCUT_MAIN(); -
uspace/srv/sysman/test/mock_unit.c
r241f1985 r102f641 104 104 unit_notify_state(unit); 105 105 } 106 -
uspace/srv/sysman/unit.c
r241f1985 r102f641 55 55 56 56 static config_item_t unit_configuration[] = { 57 { "After", &unit_parse_unit_list, 0, ""},57 { "After", &unit_parse_unit_list, 0, "" }, 58 58 CONFIGURATION_ITEM_SENTINEL 59 59 }; 60 60 61 62 61 static void unit_init(unit_t *unit, unit_type_t type) 63 62 { … … 66 65 size_t size = unit_type_vmts[type]->size; 67 66 memset(unit, 0, size); 68 67 69 68 unit->type = type; 70 69 unit->state = STATE_STOPPED; … … 97 96 98 97 UNIT_VMT(unit)->destroy(unit); 99 /* TODO: 98 /* 99 * TODO: 100 100 * edges 101 101 */ … … 116 116 unit_section, unit, text_parse); 117 117 } 118 118 119 119 if (rc != EOK) { 120 120 return rc; -
uspace/srv/sysman/unit.h
r241f1985 r102f641 99 99 #include "unit_svc.h" 100 100 101 #define DEFINE_CAST(NAME, TYPE, ENUM_TYPE) \102 static inline TYPE *CAST_##NAME(unit_t *u) \103 { \104 if (u->type == ENUM_TYPE) \101 #define DEFINE_CAST(NAME, TYPE, ENUM_TYPE) \ 102 static inline TYPE *CAST_##NAME(unit_t *u) \ 103 { \ 104 if (u->type == ENUM_TYPE) \ 105 105 return (TYPE *)u; \ 106 else \106 else \ 107 107 return NULL; \ 108 } \108 } 109 109 110 DEFINE_CAST(CFG, unit_cfg_t, UNIT_CONFIGURATION) 111 DEFINE_CAST(MNT, unit_mnt_t, UNIT_MOUNT) 112 DEFINE_CAST(TGT, unit_tgt_t, UNIT_TARGET) 113 DEFINE_CAST(SVC, unit_svc_t, UNIT_SERVICE) 110 DEFINE_CAST(CFG, unit_cfg_t, UNIT_CONFIGURATION); 111 DEFINE_CAST(MNT, unit_mnt_t, UNIT_MOUNT); 112 DEFINE_CAST(TGT, unit_tgt_t, UNIT_TARGET); 113 DEFINE_CAST(SVC, unit_svc_t, UNIT_SERVICE); 114 114 115 115 struct unit_vmt { -
uspace/srv/sysman/units/unit_cfg.c
r241f1985 r102f641 46 46 47 47 static config_item_t unit_configuration[] = { 48 { "Path", &config_parse_string, offsetof(unit_cfg_t, path), NULL},48 { "Path", &config_parse_string, offsetof(unit_cfg_t, path), NULL }, 49 49 CONFIGURATION_ITEM_SENTINEL 50 50 }; … … 81 81 goto finish; 82 82 } 83 83 84 84 /* We parse files as part of ongoing repo transaction (locked). */ 85 85 unit_t *u = repo_find_unit_by_name_unsafe(unit_name); … … 231 231 232 232 errno_t rc = cfg_load_configuration(u_cfg->path); 233 233 234 234 if (rc == EOK) { 235 235 unit->state = STATE_STARTED; … … 267 267 } 268 268 269 DEFINE_UNIT_VMT(unit_cfg) 270 269 DEFINE_UNIT_VMT(unit_cfg); -
uspace/srv/sysman/units/unit_mnt.c
r241f1985 r102f641 41 41 42 42 static config_item_t unit_configuration[] = { 43 { "What", &config_parse_string, offsetof(unit_mnt_t, device), NULL},44 { "Where", &config_parse_string, offsetof(unit_mnt_t, mountpoint), NULL},45 { "Type", &config_parse_string, offsetof(unit_mnt_t, type), NULL},46 { "Autostart", &config_parse_bool, offsetof(unit_mnt_t, autostart), "true"},47 { "Blocking", &config_parse_bool, offsetof(unit_mnt_t, blocking), "true"},43 { "What", &config_parse_string, offsetof(unit_mnt_t, device), NULL }, 44 { "Where", &config_parse_string, offsetof(unit_mnt_t, mountpoint), NULL }, 45 { "Type", &config_parse_string, offsetof(unit_mnt_t, type), NULL }, 46 { "Autostart", &config_parse_bool, offsetof(unit_mnt_t, autostart), "true" }, 47 { "Blocking", &config_parse_bool, offsetof(unit_mnt_t, blocking), "true" }, 48 48 CONFIGURATION_ITEM_SENTINEL 49 49 }; … … 195 195 assert(!u_mnt->autostart || u_mnt->blocking); 196 196 197 198 197 assert(unit->state == STATE_STOPPED); 199 198 … … 203 202 mnt_data.mountpoint = u_mnt->mountpoint; 204 203 mnt_data.device = u_mnt->device; 205 /* TODO use other mount parameters 204 /* 205 * TODO use other mount parameters 206 206 * mnt_data.options = u_mnt->options; 207 207 * mnt_data.instance = u_mnt->instance; … … 235 235 assert(!u_mnt->autostart || u_mnt->blocking); 236 236 237 238 237 // note: we should never hit STATE_STARTING, since it'd mean there are 239 238 // two jobs running at once (unless job cancellation is implemented) … … 284 283 } 285 284 286 287 DEFINE_UNIT_VMT(unit_mnt) 288 285 DEFINE_UNIT_VMT(unit_mnt); -
uspace/srv/sysman/units/unit_mnt.h
r241f1985 r102f641 39 39 char *device; 40 40 41 /** Should be underlying units (FS server, device) be autostarted 42 * (implies blocking) */ 41 /** 42 * Should be underlying units (FS server, device) be autostarted 43 * (implies blocking) 44 */ 43 45 bool autostart; 44 46 … … 50 52 51 53 #endif 52 -
uspace/srv/sysman/units/unit_svc.c
r241f1985 r102f641 40 40 41 41 static config_item_t unit_configuration[] = { 42 { "ExecStart", &util_parse_command, offsetof(unit_svc_t, exec_start), NULL},42 { "ExecStart", &util_parse_command, offsetof(unit_svc_t, exec_start), NULL }, 43 43 CONFIGURATION_ITEM_SENTINEL 44 44 }; … … 82 82 assert(u_svc); 83 83 84 85 84 assert(unit->state == STATE_STOPPED); 86 85 … … 117 116 assert(u_svc); 118 117 119 120 118 // note: May change when job cancellation is possible. 121 119 assert(unit->state == STATE_STARTED); … … 133 131 134 132 if (rc != EOK) { 135 /* Task may still be running, but be conservative about unit's 136 * state. */ 133 /* 134 * Task may still be running, but be conservative about unit's 135 * state. 136 */ 137 137 unit->state = STATE_FAILED; 138 138 return rc; … … 144 144 } 145 145 146 147 146 static void unit_svc_exposee_created(unit_t *unit) 148 147 { 149 148 assert(CAST_SVC(unit)); 150 assert(unit->state == STATE_STOPPED || unit->state == STATE_STARTING || unit->state ==STATE_STARTED);149 assert(unit->state == STATE_STOPPED || unit->state == STATE_STARTING || unit->state == STATE_STARTED); 151 150 152 151 /* Exposee itself doesn't represent started unit. */ … … 160 159 } 161 160 162 DEFINE_UNIT_VMT(unit_svc) 163 161 DEFINE_UNIT_VMT(unit_svc); -
uspace/srv/sysman/units/unit_svc.h
r241f1985 r102f641 51 51 52 52 #endif 53 -
uspace/srv/sysman/units/unit_tgt.c
r241f1985 r102f641 82 82 } 83 83 84 85 DEFINE_UNIT_VMT(unit_tgt) 86 84 DEFINE_UNIT_VMT(unit_tgt); -
uspace/srv/sysman/util.c
r241f1985 r102f641 86 86 command->argv[command->argc] = NULL; 87 87 88 89 88 if (command->argc > MAX_COMMAND_ARGS) { 90 89 text_parse_raise_error(parse, lineno, … … 95 94 } 96 95 } 97 98 96 99 97 void util_command_init(command_t *command) -
uspace/srv/taskman/event.c
r241f1985 r102f641 167 167 async_answer_1(pr->icall, EINTR, t->exit); 168 168 } else { 169 /* Send both exit status and retval, caller 170 * should know what is valid */ 169 /* 170 * Send both exit status and retval, caller 171 * should know what is valid 172 */ 171 173 async_answer_3(pr->icall, EOK, t->exit, 172 174 t->retval, rest); … … 180 182 } 181 183 182 183 184 list_remove(&pr->link); 184 185 free(pr); … … 233 234 234 235 void wait_for_task(task_id_t id, int flags, ipc_call_t *icall, 235 task_id_t waiter_id)236 task_id_t waiter_id) 236 237 { 237 238 assert(!(flags & TASK_WAIT_BOTH) || … … 247 248 return; 248 249 } 249 250 250 251 if (t->exit != TASK_EXIT_RUNNING) { 251 252 //TODO are flags BOTH processed correctly here? … … 253 254 return; 254 255 } 255 256 256 257 /* 257 258 * Add request to pending list or reuse existing item for a second … … 274 275 goto finish; 275 276 } 276 277 277 278 link_initialize(&pr->link); 278 279 pr->id = id; … … 305 306 } 306 307 307 308 308 errno_t task_set_retval(task_id_t sender, int retval, bool wait_for_exit) 309 309 { 310 310 errno_t rc = EOK; 311 311 312 312 fibril_rwlock_write_lock(&task_hash_table_lock); 313 313 task_t *t = task_get_by_id(sender); … … 317 317 goto finish; 318 318 } 319 319 320 320 t->retval = retval; 321 321 t->retval_type = wait_for_exit ? RVAL_SET_EXIT : RVAL_SET; 322 322 323 323 event_notify_all(t); 324 324 process_pending_wait(); 325 325 326 326 finish: 327 327 fibril_rwlock_write_unlock(&task_hash_table_lock); -
uspace/srv/taskman/main.c
r241f1985 r102f641 54 54 #include "taskman.h" 55 55 56 57 56 typedef struct { 58 57 link_t link; … … 74 73 { 75 74 DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->task_id); 76 /* We don't accept the connection request, we forward it instead to 77 * freshly spawned loader. */ 75 /* 76 * We don't accept the connection request, we forward it instead to 77 * freshly spawned loader. 78 */ 78 79 errno_t rc = loader_spawn("loader"); 79 80 80 81 if (rc != EOK) { 81 82 async_answer_0(icall, rc); 82 83 return; 83 84 } 84 85 85 86 /* Wait until spawned task presents itself to us. */ 86 87 link_t *link = prodcons_consume(&sess_queue); … … 148 149 /* Used only for connection forwarding -- atomic */ 149 150 session_ns = async_callback_receive(EXCHANGE_ATOMIC); 150 151 151 152 if (session_ns == NULL) { 152 153 rc = ENOENT; … … 218 219 // TODO check that loader is expected, would probably discard prodcons 219 220 // scheme 220 221 221 222 /* Preallocate session container */ 222 223 sess_ref_t *sess_ref = malloc(sizeof(sess_ref_t)); … … 265 266 static bool handle_implicit_call(ipc_call_t *icall) 266 267 { 267 /*DPRINTF("%s:%i %i(%i) from %llu\n", __func__, __LINE__,268 IPC_GET_IMETHOD(*icall),269 IPC_GET_ARG1(*icall),270 icall->in_task_id);*/271 272 268 if (ipc_get_imethod(icall) < IPC_FIRST_USER_METHOD) { 273 269 switch (ipc_get_arg1(icall)) { … … 330 326 } 331 327 332 333 334 328 int main(int argc, char *argv[]) 335 329 { … … 358 352 return rc; 359 353 } 360 354 361 355 task_id_t self_id = task_get_id(); 362 356 rc = task_intro(self_id); -
uspace/srv/taskman/task.c
r241f1985 r102f641 46 46 void *arg; 47 47 } walker_context_t; 48 48 49 49 /* 50 50 * Forwards … … 59 59 static size_t ht_task_key_hash(const void *key) 60 60 { 61 return *(task_id_t *)key;61 return *(task_id_t *)key; 62 62 } 63 63 … … 71 71 { 72 72 task_t *ht = hash_table_get_inst(item, task_t, link); 73 return ht->id == *(task_id_t *)key;73 return ht->id == *(task_id_t *)key; 74 74 } 75 75 … … 127 127 128 128 fibril_rwlock_initialize(&task_hash_table_lock); 129 129 130 130 return EOK; 131 131 } … … 145 145 return NULL; 146 146 } 147 147 148 148 task_t *t = hash_table_get_inst(link, task_t, link); 149 149 return t; … … 202 202 goto finish; 203 203 } 204 204 205 205 t = malloc(sizeof(task_t)); 206 206 if (t == NULL) { … … 217 217 hash_table_insert(&task_hash_table, &t->link); 218 218 DPRINTF("%s: %llu\n", __func__, t->id); 219 219 220 220 finish: 221 221 fibril_rwlock_write_unlock(&task_hash_table_lock); … … 223 223 } 224 224 225 226 225 /** 227 226 * @} -
uspace/srv/taskman/task.h
r241f1985 r102f641 43 43 /** What type of retval from the task we have */ 44 44 typedef enum { 45 RVAL_UNSET, /**< unset */ 46 RVAL_SET, /**< retval set, e.g. by server */ 47 RVAL_SET_EXIT /**< retval set, wait for expected task exit */ 45 /* unset */ 46 RVAL_UNSET, 47 48 /* retval set, e.g. by server */ 49 RVAL_SET, 50 51 /* retval set, wait for expected task exit */ 52 RVAL_SET_EXIT 48 53 } retval_t; 49 54 … … 51 56 typedef struct { 52 57 ht_link_t link; 53 54 task_id_t id; /**< Task id. */55 task_exit_t exit; /**< Task's uspace exit status. */56 bool failed; /**< Task failed (task can exit unexpectedly57 even w/out failure). */58 retval_t retval_type; /**< Task returned a value. */59 int retval; /**< The return value. */60 58 61 link_t listeners; /**< Link to listeners list. */ 62 async_sess_t *sess; /**< Session for notifications to task. */ 59 /* Task id. */ 60 task_id_t id; 61 /* Task's uspace exit status. */ 62 task_exit_t exit; 63 /* Task failed (task can exit unexpectedly even w/out failure). */ 64 bool failed; 65 /* Task returned a value. */ 66 retval_t retval_type; 67 /* The return value. */ 68 int retval; 69 /* Link to listeners list. */ 70 link_t listeners; 71 /* Session for notifications to task. */ 72 async_sess_t *sess; 63 73 } task_t; 64 74 65 typedef bool (* task_walker_t)(task_t *, void *);75 typedef bool (*task_walker_t)(task_t *, void *); 66 76 67 77 extern fibril_rwlock_t task_hash_table_lock; -
uspace/srv/vfs/vfs.c
r241f1985 r102f641 155 155 return rc; 156 156 } 157 157 158 158 /* 159 159 * Start accepting connections. -
uspace/srv/vfs/vfs_register.c
r241f1985 r102f641 174 174 sysman_main_exposee_added(unit_name, req->task_id); 175 175 free(unit_name); 176 176 177 177 /* 178 178 * Add fs_info to the list of registered FS's.
Note:
See TracChangeset
for help on using the changeset viewer.
