]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
handle some errors on missing db handle conditions
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 30 Mar 2010 03:13:49 +0000 (03:13 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 30 Mar 2010 03:13:49 +0000 (03:13 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@17136 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_commands/mod_commands.c
src/mod/applications/mod_dptools/mod_dptools.c
src/mod/formats/mod_shout/mod_shout.c
src/switch_console.c

index 78fed4bad005f48ecb4f616e5c0a92ff2933ff74..0f3bc011603aa7b22374a5333211a1bf08b820f2 100644 (file)
@@ -3232,7 +3232,10 @@ SWITCH_STANDARD_API(show_function)
        switch_core_flag_t cflags = switch_core_flags();
        switch_status_t status = SWITCH_STATUS_SUCCESS;
 
-       switch_core_db_handle(&db);
+       if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
+               stream->write_function(stream, "%s", "-ERR Databse Error!\n");
+               return SWITCH_STATUS_SUCCESS;
+       }
 
        holder.justcount = 0;
 
index 0dcd869fc29f3621d180378c956a3ea9de7fdf0e..9990871df31cade59b6e8f4ad7826689d06c092e 100644 (file)
@@ -358,7 +358,9 @@ SWITCH_STANDARD_APP(eavesdrop_function)
                        char terminator;
                        switch_status_t status;
 
-                       switch_core_db_handle(&db);
+                       if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Database Error!\n");
+                       }
 
                        while (switch_channel_ready(channel)) {
                                for (x = 0; x < MAX_SPY; x++) {
index 1eef2e42d3bb23a2819557972396020c70a4f673..61a4211ea1c5de6bd7381d52e1cbcec120e1ce56 100644 (file)
@@ -1356,7 +1356,9 @@ void do_index(switch_stream_handle_t *stream)
        struct holder holder;
        char *errmsg;
 
-       switch_core_db_handle(&db);
+       if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
+               return;
+       }
 
        holder.host = switch_event_get_header(stream->param_event, "http-host");
        holder.port = switch_event_get_header(stream->param_event, "http-port");
index 7879664aa346f5b4a7d1f36a50f898b88d58bd47..68f7df3575948e7bd307d367edadd4945bf37a83 100644 (file)
@@ -240,8 +240,11 @@ SWITCH_DECLARE(char *) switch_console_expand_alias(char *cmd, char *arg)
        switch_cache_db_handle_t *db = NULL;
        int full = 0;
 
-
-       switch_core_db_handle(&db);
+       
+       if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database Error\n");
+               return NULL;
+       }
 
 
        if (db->type == SCDB_TYPE_CORE_DB) {
@@ -563,7 +566,11 @@ SWITCH_DECLARE(switch_status_t) switch_console_list_uuid(const char *line, const
        switch_status_t status = SWITCH_STATUS_FALSE;
        char *errmsg;
 
-       switch_core_db_handle(&db);
+
+       if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database Error\n");
+               return SWITCH_STATUS_GENERR;
+       }
 
        if (!zstr(cursor)) {
                sql = switch_mprintf("select distinct uuid from channels where uuid like '%q%%' and hostname='%q' order by uuid",
@@ -609,7 +616,10 @@ SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const ch
 #endif
 #endif
 
-       switch_core_db_handle(&db);
+       if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database Error\n");
+               return CC_ERROR;
+       }
 
        if (!zstr(cursor) && !zstr(line)) {
                pos = (cursor - line);
@@ -1688,7 +1698,14 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)
                        switch_stream_handle_t mystream = { 0 };
                        SWITCH_STANDARD_STREAM(mystream);
 
-                       switch_core_db_handle(&db);
+
+                       if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database Error\n");
+                               free(mystream.data);
+                               free(mydata);
+                               return SWITCH_STATUS_FALSE;
+                       }
+
 
                        if (!strcasecmp(argv[0], "stickyadd")) {
                                mystream.write_function(&mystream, "insert into complete values (1,");
@@ -1765,8 +1782,12 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_alias(const char *string)
                        switch_cache_db_handle_t *db = NULL;
                        char *sql = NULL;
 
-                       switch_core_db_handle(&db);
-
+                       if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database Error\n");
+                               free(mydata);
+                               return SWITCH_STATUS_FALSE;
+                       }
+                       
                        if (!strcasecmp(argv[0], "stickyadd") && argc == 3) {
                                sql = switch_mprintf("delete from aliases where alias='%q' and hostname='%q'", argv[1], switch_core_get_variable("hostname"));
                                switch_cache_db_persistant_execute(db, sql, 5);