Re-introduce proper error handling that was removed in recent commits.
authorRussell Bryant <russell@russellbryant.com>
Tue, 13 May 2008 17:42:17 +0000 (17:42 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 13 May 2008 17:42:17 +0000 (17:42 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@115850 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_jack.c
apps/app_skel.c
funcs/func_speex.c

index 2aa253f..1b5f4e7 100644 (file)
@@ -977,12 +977,16 @@ static int unload_module(void)
 
 static int load_module(void)
 {
-       int res = 0;
+       if (ast_register_application(jack_app, jack_exec, jack_synopsis, jack_desc)) {
+               return AST_MODULE_LOAD_DECLINE;
+       }
 
-       res |= ast_register_application(jack_app, jack_exec, jack_synopsis, jack_desc);
-       res |= ast_custom_function_register(&jack_hook_function);
+       if (ast_custom_function_register(&jack_hook_function)) {
+               ast_unregister_application(jack_app);
+               return AST_MODULE_LOAD_DECLINE;
+       }
 
-       return res;
+       return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "JACK Interface");
index 061f1e8..588563d 100644 (file)
@@ -114,7 +114,8 @@ static int unload_module(void)
 
 static int load_module(void)
 {
-       return ast_register_application(app, app_exec, synopsis, descrip);
+       return ast_register_application(app, app_exec, synopsis, descrip) ? 
+               AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Skeleton (sample) Application");
index f4d5fe4..fc4eb8e 100644 (file)
@@ -336,12 +336,16 @@ static int unload_module(void)
 
 static int load_module(void)
 {
-       int res = 0;
+       if (ast_custom_function_register(&agc_function)) {
+               return AST_MODULE_LOAD_DECLINE;
+       }
 
-       res |= ast_custom_function_register(&agc_function);
-       res |= ast_custom_function_register(&denoise_function);
+       if (ast_custom_function_register(&denoise_function)) {
+               ast_custom_function_unregister(&agc_function);
+               return AST_MODULE_LOAD_DECLINE;
+       }
 
-       return res;
+       return AST_MODULE_LOAD_SUCCESS;
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Noise reduction and Automatic Gain Control (AGC)");