}
-static void event_handler(switch_event_t *event)
+static void do_rotate_all()
{
- const char *sig = switch_event_get_header(event, "Trapped-Signal");
switch_hash_index_t *hi;
void *val;
cdr_fd_t *fd;
return;
}
+ for (hi = switch_hash_first(NULL, globals.fd_hash); hi; hi = switch_hash_next(hi)) {
+ switch_hash_this(hi, NULL, NULL, &val);
+ fd = (cdr_fd_t *) val;
+ switch_mutex_lock(fd->mutex);
+ do_rotate(fd);
+ switch_mutex_unlock(fd->mutex);
+ }
+}
+
+
+static void event_handler(switch_event_t *event)
+{
+ const char *sig = switch_event_get_header(event, "Trapped-Signal");
+
if (sig && !strcmp(sig, "HUP")) {
- for (hi = switch_hash_first(NULL, globals.fd_hash); hi; hi = switch_hash_next(hi)) {
- switch_hash_this(hi, NULL, NULL, &val);
- fd = (cdr_fd_t *) val;
- switch_mutex_lock(fd->mutex);
- do_rotate(fd);
- switch_mutex_unlock(fd->mutex);
- }
+ do_rotate_all();
}
}
+SWITCH_STANDARD_API(cdr_csv_function)
+{
+ if (!strcmp(cmd, "rotate")) {
+ do_rotate_all();
+ stream->write_function(stream, "+OK");
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_FALSE;
+}
+
+
static switch_state_handler_table_t state_handlers = {
/*.on_init */ NULL,
/*.on_routing */ NULL,
SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_csv_load)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
+ switch_api_interface_t *api_interface;
load_config(pool);
switch_core_add_state_handler(&state_handlers);
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
+ SWITCH_ADD_API(api_interface, "cdr_csv", "cdr_csv controls", cdr_csv_function, "parameters");
+ switch_console_set_complete("add cdr_csv rotate");
return status;
}
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_csv_shutdown)
{
+ switch_console_set_complete("del cdr_csv");
globals.shutdown = 1;
switch_event_unbind_callback(event_handler);