Changeset 16d748ee in mainline for uspace/srv/taskman/main.c
- Timestamp:
- 2020-01-05T03:04:38Z (13 months ago)
- Children:
- 66b1075
- Parents:
- 2f04bdd
- git-author:
- Matthieu Riolo <matthieu.riolo@…> (2019-11-30 20:47:26)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2020-01-05 03:04:38)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/taskman/main.c
r2f04bdd r16d748ee 36 36 * @{ 37 37 */ 38 38 #include <abi/ipc/methods.h> 39 39 #include <adt/prodcons.h> 40 40 #include <assert.h> … … 124 124 async_exchange_end(exch); 125 125 126 if (rc != EOK) { 127 async_answer_0(icall, rc); 128 return; 129 } 126 if (rc != EOK) 127 async_answer_0(icall, rc); 130 128 } 131 129 … … 133 131 { 134 132 errno_t rc = task_intro(icall->task_id); 135 async_answer_0(icall, rc); 133 if (rc == EOK) { 134 async_accept_0(icall); 135 } else { 136 async_answer_0(icall, rc); 137 } 136 138 } 137 139 … … 158 160 finish: 159 161 fibril_mutex_unlock(&session_ns_mtx); 160 async_answer_0(icall, rc); 162 163 if (rc == EOK) { 164 async_accept_0(icall); 165 } else { 166 async_answer_0(icall, rc); 167 } 161 168 } 162 169 … … 240 247 } 241 248 242 static bool handle_call(ipc_call_t *icall) 243 { 244 switch (ipc_get_imethod(icall)) { 245 case TASKMAN_NEW_TASK: 246 taskman_new_task(icall); 247 break; 248 case TASKMAN_I_AM_NS: 249 taskman_i_am_ns(icall); 250 break; 251 case TASKMAN_WAIT: 252 taskman_ctl_wait(icall); 253 break; 254 case TASKMAN_RETVAL: 255 taskman_ctl_retval(icall); 256 break; 257 case TASKMAN_EVENT_CALLBACK: 258 taskman_ctl_ev_callback(icall); 259 break; 260 default: 261 return false; 262 } 263 return true; 264 } 265 266 static bool handle_implicit_call(ipc_call_t *icall) 267 { 268 if (ipc_get_imethod(icall) < IPC_FIRST_USER_METHOD) { 269 switch (ipc_get_arg1(icall)) { 249 static void taskman_connection(ipc_call_t *icall, void *arg) 250 { 251 /* handle new incoming calls */ 252 if (ipc_get_imethod(icall) == IPC_M_CONNECT_ME_TO) { 253 switch (ipc_get_arg2(icall)) { 254 case TASKMAN_NEW_TASK: 255 taskman_new_task(icall); 256 break; 270 257 case TASKMAN_CONNECT_TO_NS: 271 258 connect_to_ns(icall); 272 break;259 return; 273 260 case TASKMAN_CONNECT_TO_LOADER: 274 261 connect_to_loader(icall); 275 break; 262 return; 263 default: 264 async_answer_0(icall, ENOTSUP); 265 return; 266 } 267 } else if (ipc_get_imethod(icall) == IPC_M_CONNECT_TO_ME) { 268 switch (ipc_get_arg2(icall)) { 276 269 case TASKMAN_LOADER_CALLBACK: 277 270 loader_callback(icall); 278 break;271 return; 279 272 default: 280 return false;281 273 async_answer_0(icall, ENOTSUP); 274 return; 282 275 } 283 } else { 284 return handle_call(icall); 285 } 286 287 return true; 288 } 289 290 static void implicit_connection(ipc_call_t *icall, void *arg) 291 { 292 if (!handle_implicit_call(icall)) { 293 async_answer_0(icall, ENOTSUP); 294 return; 295 } 296 276 } 277 278 /* handle accepted calls */ 297 279 while (true) { 298 280 ipc_call_t call; 299 281 300 if (!async_get_call(&call) || !ipc_get_imethod(&call)) {282 if (!async_get_call(&call)) { 301 283 /* Client disconnected */ 302 break;284 return; 303 285 } 304 286 305 if (!handle_implicit_call(&call)) { 306 async_answer_0(icall, ENOTSUP); 307 break; 287 switch (ipc_get_imethod(&call)) { 288 case TASKMAN_I_AM_NS: 289 taskman_i_am_ns(&call); 290 break; 291 case TASKMAN_WAIT: 292 taskman_ctl_wait(&call); 293 break; 294 case TASKMAN_RETVAL: 295 taskman_ctl_retval(&call); 296 break; 297 case TASKMAN_EVENT_CALLBACK: 298 taskman_ctl_ev_callback(&call); 299 break; 300 default: 301 async_answer_0(&call, ENOTSUP); 308 302 } 309 }310 }311 312 static void taskman_connection(ipc_call_t *icall, void *arg)313 {314 /*315 * We don't expect (yet) clients to connect, having this function is316 * just to adapt to async framework that creates new connection for317 * each IPC_M_CONNECT_ME_TO.318 * In this case those are to be forwarded, so don't continue319 * "listening" on such connections.320 */321 if (!handle_implicit_call(icall)) {322 /* If cannot handle connection request, give up trying */323 async_answer_0(icall, EHANGUP);324 return;325 303 } 326 304 } … … 360 338 361 339 /* Start sysman server */ 362 async_set_implicit_connection(implicit_connection);363 340 async_set_fallback_port_handler(taskman_connection, NULL); 364 341
Note: See TracChangeset
for help on using the changeset viewer.