Changeset e8f9b6b02ee1b13c36af920f47f12b3c129cd498
- Timestamp:
- 11/30/10 00:13:11 (3 years ago)
- Author:
- Nedko Arnaudov <nedko@…>
- Children:
- 0cfdeec2e7ebf3612de07bea5c64d3e256b2b13e
- Parents:
- a5d878cdc4363738db31c771dace7c14c4c75d3b
- git-committer:
- Nedko Arnaudov <nedko@arnaudov.name> / 2010-11-30T00:13:11Z+0200
- Message:
-
ladishd: Deassociate pids of disappearing clients. Fix for #119
- Location:
- daemon
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r4248abe
|
re8f9b6b
|
|
| 226 | 226 | } |
| 227 | 227 | |
| | 228 | ladish_app_handle ladish_app_supervisor_find_app_by_uuid(ladish_app_supervisor_handle supervisor_handle, const uuid_t uuid) |
| | 229 | { |
| | 230 | struct list_head * node_ptr; |
| | 231 | struct ladish_app * app_ptr; |
| | 232 | |
| | 233 | list_for_each(node_ptr, &supervisor_ptr->applist) |
| | 234 | { |
| | 235 | app_ptr = list_entry(node_ptr, struct ladish_app, siblings); |
| | 236 | if (uuid_compare(app_ptr->uuid, uuid) == 0) |
| | 237 | { |
| | 238 | return (ladish_app_handle)app_ptr; |
| | 239 | } |
| | 240 | } |
| | 241 | |
| | 242 | return NULL; |
| | 243 | } |
| | 244 | |
| 228 | 245 | ladish_app_handle |
| 229 | 246 | ladish_app_supervisor_add( |
| … |
… |
|
| 599 | 616 | } |
| 600 | 617 | |
| | 618 | void ladish_app_del_pid(ladish_app_handle app_handle, pid_t pid) |
| | 619 | { |
| | 620 | if (app_ptr->firstborn_pid != 0 && app_ptr->firstborn_pid == pid) |
| | 621 | { |
| | 622 | log_info("First grandchild with pid %u has gone", (unsigned int)pid); |
| | 623 | app_ptr->firstborn_pid = 0; |
| | 624 | } |
| | 625 | } |
| | 626 | |
| 601 | 627 | #undef app_ptr |
| 602 | 628 | |
-
|
r99b1ab0
|
re8f9b6b
|
|
| 288 | 288 | |
| 289 | 289 | /** |
| | 290 | * Search app by uuid |
| | 291 | * |
| | 292 | * @param[in] supervisor_handle supervisor object handle |
| | 293 | * @param[in] uuid uuid of the app to search for |
| | 294 | * |
| | 295 | * @return app handle on if found; NULL if app is not found; the app handle is owned by the app supervisor object |
| | 296 | */ |
| | 297 | ladish_app_handle |
| | 298 | ladish_app_supervisor_find_app_by_uuid( |
| | 299 | ladish_app_supervisor_handle supervisor_handle, |
| | 300 | const uuid_t uuid); |
| | 301 | |
| | 302 | /** |
| 290 | 303 | * The the D-Bus object path for the supervisor. |
| 291 | 304 | * |
| … |
… |
|
| 394 | 407 | |
| 395 | 408 | /** |
| | 409 | * Deassociate pid with app. |
| | 410 | * |
| | 411 | * @param[in] app_handle Handle of app |
| | 412 | * @param[in] pid PID to deassociate with the app |
| | 413 | */ |
| | 414 | void ladish_app_del_pid(ladish_app_handle app_handle, pid_t pid); |
| | 415 | |
| | 416 | /** |
| 396 | 417 | * D-Bus interface descriptor for the app supervisor interface. The call context must be a ::ladish_app_supervisor_handle |
| 397 | 418 | */ |
-
|
rfb15df6
|
re8f9b6b
|
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | | struct ladish_studio_app_supervisor_match_context |
| | 776 | struct ladish_studio_app_supervisor_match_opath_context |
| 777 | 777 | { |
| 778 | 778 | const char * opath; |
| … |
… |
|
| 780 | 780 | }; |
| 781 | 781 | |
| 782 | | #define iterate_context_ptr ((struct ladish_studio_app_supervisor_match_context *)context) |
| 783 | | |
| 784 | | static bool ladish_studio_app_supervisor_match(void * context, ladish_graph_handle graph, ladish_app_supervisor_handle app_supervisor) |
| | 782 | #define iterate_context_ptr ((struct ladish_studio_app_supervisor_match_opath_context *)context) |
| | 783 | |
| | 784 | static bool ladish_studio_app_supervisor_match_opath(void * context, ladish_graph_handle graph, ladish_app_supervisor_handle app_supervisor) |
| 785 | 785 | { |
| 786 | 786 | ASSERT(strcmp(ladish_app_supervisor_get_opath(app_supervisor), ladish_graph_get_opath(graph)) == 0); |
| … |
… |
|
| 799 | 799 | ladish_app_supervisor_handle ladish_studio_find_app_supervisor(const char * opath) |
| 800 | 800 | { |
| 801 | | struct ladish_studio_app_supervisor_match_context ctx; |
| | 801 | struct ladish_studio_app_supervisor_match_opath_context ctx; |
| 802 | 802 | |
| 803 | 803 | ctx.opath = opath; |
| 804 | 804 | ctx.supervisor = NULL; |
| 805 | | ladish_studio_iterate_virtual_graphs(&ctx, ladish_studio_app_supervisor_match); |
| | 805 | ladish_studio_iterate_virtual_graphs(&ctx, ladish_studio_app_supervisor_match_opath); |
| 806 | 806 | return ctx.supervisor; |
| | 807 | } |
| | 808 | |
| | 809 | struct ladish_studio_app_supervisor_match_app_context |
| | 810 | { |
| | 811 | uuid_t app_uuid; |
| | 812 | ladish_app_handle app; |
| | 813 | }; |
| | 814 | |
| | 815 | #define iterate_context_ptr ((struct ladish_studio_app_supervisor_match_app_context *)context) |
| | 816 | |
| | 817 | static bool ladish_studio_app_supervisor_match_app(void * context, ladish_graph_handle graph, ladish_app_supervisor_handle app_supervisor) |
| | 818 | { |
| | 819 | ASSERT(strcmp(ladish_app_supervisor_get_opath(app_supervisor), ladish_graph_get_opath(graph)) == 0); |
| | 820 | ASSERT(iterate_context_ptr->app == NULL); |
| | 821 | |
| | 822 | iterate_context_ptr->app = ladish_app_supervisor_find_app_by_uuid(app_supervisor, iterate_context_ptr->app_uuid); |
| | 823 | if (iterate_context_ptr->app != NULL) |
| | 824 | { |
| | 825 | return false; /* stop iteration */ |
| | 826 | } |
| | 827 | |
| | 828 | return true; /* continue iteration */ |
| | 829 | } |
| | 830 | |
| | 831 | #undef iterate_context_ptr |
| | 832 | |
| | 833 | ladish_app_handle ladish_studio_find_app_by_uuid(const uuid_t app_uuid) |
| | 834 | { |
| | 835 | struct ladish_studio_app_supervisor_match_app_context ctx; |
| | 836 | |
| | 837 | uuid_copy(ctx.app_uuid, app_uuid); |
| | 838 | ctx.app = NULL; |
| | 839 | ladish_studio_iterate_virtual_graphs(&ctx, ladish_studio_app_supervisor_match_app); |
| | 840 | return ctx.app; |
| 807 | 841 | } |
| 808 | 842 | |
-
|
ra9a55b0
|
re8f9b6b
|
|
| 61 | 61 | void ladish_studio_stop_app_supervisors(void); |
| 62 | 62 | ladish_app_supervisor_handle ladish_studio_find_app_supervisor(const char * opath); |
| | 63 | ladish_app_handle ladish_studio_find_app_by_uuid(const uuid_t app_uuid); |
| 63 | 64 | struct ladish_cqueue * ladish_studio_get_cmd_queue(void); |
| 64 | 65 | ladish_virtualizer_handle ladish_studio_get_virtualizer(void); |
-
|
r416c652
|
re8f9b6b
|
|
| 384 | 384 | ladish_client_handle client; |
| 385 | 385 | pid_t pid; |
| | 386 | uuid_t app_uuid; |
| | 387 | ladish_app_handle app; |
| 386 | 388 | ladish_graph_handle vgraph; |
| 387 | 389 | |
| … |
… |
|
| 400 | 402 | |
| 401 | 403 | pid = ladish_client_get_pid(client); |
| 402 | | if (ladish_client_has_app(client)) |
| | 404 | if (ladish_client_get_app(client, app_uuid)) |
| 403 | 405 | { |
| 404 | 406 | virtualizer_ptr->our_clients_count--; |
| | 407 | app = ladish_studio_find_app_by_uuid(app_uuid); |
| | 408 | if (app != NULL) |
| | 409 | { |
| | 410 | ladish_app_del_pid(app, pid); |
| | 411 | } |
| | 412 | else |
| | 413 | { |
| | 414 | log_error("app of disappearing client %"PRIu64" not found. pid is %"PRIu64, id, (uint64_t)pid); |
| | 415 | ASSERT_NO_PASS; |
| | 416 | } |
| 405 | 417 | } |
| 406 | 418 | |