[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/4] check for a module INIT response just right after it was sen
From: |
Andrei Kholodnyi |
Subject: |
[PATCH 3/4] check for a module INIT response just right after it was sent |
Date: |
Tue, 5 Oct 2010 00:00:14 +0200 |
When the server sent the INIT command to an output module, it was not
checking the status code returned by the module.
As of now, the server detects a failed initialization as soon as it
can, by examining the status code of the reply.
---
src/server/module.c | 35 ++++++++++++++++++-----------------
1 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/src/server/module.c b/src/server/module.c
index 1bb1109..3cd2d42 100644
--- a/src/server/module.c
+++ b/src/server/module.c
@@ -204,6 +204,23 @@ load_output_module(char* mod_name, char* mod_prog, char*
mod_cfgfile, char* mod_
g_string_append(reply, rep_line + 4);
}
+ fclose(f);
+ g_string_append_printf(reply, "---------------\n");
+
+ if (s == '3'){
+ MSG(1, "ERROR: Module %s failed to initialize. Reason: %s",
module->name, reply->str);
+ module->working = 0;
+ kill(module->pid, 9);
+ waitpid(module->pid, NULL, WNOHANG);
+ destroy_module(module);
+ return NULL;
+ }
+
+ if (s == '2')
+ MSG(2, "Module %s started sucessfully with message: %s", module->name,
reply->str);
+
+ g_string_free(reply, 1);
+
if (SpeechdOptions.debug){
MSG(4, "Switching debugging on for output module %s", module->name);
output_module_debug(module);
@@ -233,23 +250,7 @@ load_output_module(char* mod_name, char* mod_prog, char*
mod_cfgfile, char* mod_
/* Get a list of supported voices */
_output_get_voices(module);
- fclose(f);
- g_string_append_printf(reply, "---------------\n");
-
- if (s == '3'){
- MSG(1, "ERROR: Module %s failed to initialize. Reason: %s",
module->name, reply->str);
- module->working = 0;
- kill(module->pid, 9);
- waitpid(module->pid, NULL, WNOHANG);
- destroy_module(module);
- return NULL;
- }
-
- if (s == '2')
- MSG(2, "Module %s started sucessfully with message: %s", module->name,
reply->str);
-
- g_string_free(reply, 1);
-
+
return module;
}
--
1.6.0.4