daemon: on studio stop, stop room apps as well
This commit is contained in:
parent
91d5fceade
commit
81c3e70f33
|
@ -30,6 +30,7 @@
|
|||
#include "studio_internal.h"
|
||||
#include "loader.h"
|
||||
#include "../common/time.h"
|
||||
#include "studio.h"
|
||||
|
||||
#define STOP_STATE_WAITING_FOR_JACK_CLIENTS_DISAPPEAR 1
|
||||
#define STOP_STATE_WAITING_FOR_CHILDS_TERMINATION 2
|
||||
|
@ -63,7 +64,7 @@ static bool run(void * context)
|
|||
ladish_graph_dump(g_studio.jack_graph);
|
||||
ladish_graph_dump(g_studio.studio_graph);
|
||||
|
||||
ladish_app_supervisor_stop(g_studio.app_supervisor);
|
||||
studio_stop_app_supervisors();
|
||||
|
||||
cmd_ptr->command.state = LADISH_COMMAND_STATE_WAITING;
|
||||
cmd_ptr->stop_state = STOP_STATE_WAITING_FOR_JACK_CLIENTS_DISAPPEAR;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "dirhelpers.h"
|
||||
#include "graph_dict.h"
|
||||
#include "escape.h"
|
||||
#include "studio.h"
|
||||
|
||||
#define STUDIOS_DIR "/studios/"
|
||||
char * g_studios_dir;
|
||||
|
@ -498,30 +499,41 @@ void studio_uninit(void)
|
|||
log_info("studio object destroy");
|
||||
}
|
||||
|
||||
struct on_child_exit_context
|
||||
{
|
||||
pid_t pid;
|
||||
bool found;
|
||||
};
|
||||
|
||||
#define child_exit_context_ptr ((struct on_child_exit_context *)context)
|
||||
|
||||
static
|
||||
bool
|
||||
studio_on_child_exit_callback(
|
||||
void * context,
|
||||
ladish_app_supervisor_handle app_supervisor)
|
||||
{
|
||||
child_exit_context_ptr->found = ladish_app_supervisor_child_exit(app_supervisor, child_exit_context_ptr->pid);
|
||||
/* if child is found, return false - it will cause iteration to stop */
|
||||
/* if child is not found, return true - it will cause next supervisor to be checked */
|
||||
return !child_exit_context_ptr->found;
|
||||
}
|
||||
|
||||
#undef child_exit_context_ptr
|
||||
|
||||
void studio_on_child_exit(pid_t pid)
|
||||
{
|
||||
struct list_head * node_ptr;
|
||||
ladish_room_handle room;
|
||||
ladish_app_supervisor_handle room_app_supervisor;
|
||||
struct on_child_exit_context context;
|
||||
|
||||
if (ladish_app_supervisor_child_exit(g_studio.app_supervisor, pid))
|
||||
context.pid = pid;
|
||||
context.found = false;
|
||||
|
||||
studio_iterate_app_supervisors(&context, studio_on_child_exit_callback);
|
||||
|
||||
if (!context.found)
|
||||
{
|
||||
return;
|
||||
log_error("unknown child exit detected. pid is %llu", (unsigned long long)pid);
|
||||
}
|
||||
|
||||
list_for_each(node_ptr, &g_studio.rooms)
|
||||
{
|
||||
room = ladish_room_from_list_node(node_ptr);
|
||||
room_app_supervisor = ladish_room_get_app_supervisor(room);
|
||||
ASSERT(room_app_supervisor != NULL);
|
||||
|
||||
if (ladish_app_supervisor_child_exit(room_app_supervisor, pid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log_error("unknown child exit detected. pid is %llu", (unsigned long long)pid);
|
||||
}
|
||||
|
||||
bool studio_is_loaded(void)
|
||||
|
@ -695,6 +707,48 @@ exit:
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
studio_iterate_app_supervisors(
|
||||
void * context,
|
||||
bool (* callback)(
|
||||
void * context,
|
||||
ladish_app_supervisor_handle app_supervisor))
|
||||
{
|
||||
struct list_head * node_ptr;
|
||||
ladish_room_handle room;
|
||||
ladish_app_supervisor_handle room_app_supervisor;
|
||||
|
||||
if (!callback(context, g_studio.app_supervisor))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
list_for_each(node_ptr, &g_studio.rooms)
|
||||
{
|
||||
room = ladish_room_from_list_node(node_ptr);
|
||||
room_app_supervisor = ladish_room_get_app_supervisor(room);
|
||||
ASSERT(room_app_supervisor != NULL);
|
||||
|
||||
if (!callback(context, room_app_supervisor))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool studio_stop_app_supervisor(void * context, ladish_app_supervisor_handle app_supervisor)
|
||||
{
|
||||
ladish_app_supervisor_stop(app_supervisor);
|
||||
return true; /* iterate all supervisors */
|
||||
}
|
||||
|
||||
void studio_stop_app_supervisors(void)
|
||||
{
|
||||
studio_iterate_app_supervisors(NULL, studio_stop_app_supervisor);
|
||||
}
|
||||
|
||||
void emit_studio_renamed()
|
||||
{
|
||||
dbus_signal_emit(g_dbus_connection, STUDIO_OBJECT_PATH, IFACE_STUDIO, "StudioRenamed", "s", &g_studio.name);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/*
|
||||
* LADI Session Handler (ladish)
|
||||
*
|
||||
* Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
* Copyright (C) 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
**************************************************************************
|
||||
* This file contains interface of the studio singleton object
|
||||
|
@ -27,6 +27,8 @@
|
|||
#ifndef STUDIO_H__0BEDE85E_4FB3_4D74_BC08_C373A22409C0__INCLUDED
|
||||
#define STUDIO_H__0BEDE85E_4FB3_4D74_BC08_C373A22409C0__INCLUDED
|
||||
|
||||
#include "app_supervisor.h"
|
||||
|
||||
bool studio_init(void);
|
||||
void studio_uninit(void);
|
||||
void studio_run(void);
|
||||
|
@ -37,4 +39,13 @@ bool studio_delete(void * call_ptr, const char * studio_name);
|
|||
|
||||
void studio_on_child_exit(pid_t pid);
|
||||
|
||||
bool
|
||||
studio_iterate_app_supervisors(
|
||||
void * context,
|
||||
bool (* callback)(
|
||||
void * context,
|
||||
ladish_app_supervisor_handle app_supervisor));
|
||||
|
||||
void studio_stop_app_supervisors(void);
|
||||
|
||||
#endif /* #ifndef STUDIO_H__0BEDE85E_4FB3_4D74_BC08_C373A22409C0__INCLUDED */
|
||||
|
|
Loading…
Reference in New Issue