aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2011-01-05 18:47:46 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2011-01-05 18:47:46 +0000
commit3125c268cca575d2931cc0ea59b4aa6036dd18c3 (patch)
tree8803b63afee4309ce3b6295261cf4815392f6ac8
parent03b9bf997e4d0b4780c4ecdd8fffb55fcdf5179a (diff)
Use the sanity check in place of the disconnect/connect cycle.
The disconnect/connect cycle has the potential to cause random crashes. (closes issue #18243) Reported by: ks3 Patches: res_odbc.patch uploaded by ks3 (license 1147) Tested by: ks3 git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@300621 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--res/res_odbc.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 961e30044..9a86f401d 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -110,26 +110,20 @@ SQLHSTMT ast_odbc_prepare_and_execute(struct odbc_obj *obj, SQLHSTMT (*prepare_c
}
}
- ast_log(LOG_WARNING, "SQL Execute error %d! Attempting a reconnect...\n", res);
+ ast_log(LOG_WARNING, "SQL Execute error %d! Verifying connection to %s [%s]...\n", res, obj->parent->name, obj->parent->dsn);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
stmt = NULL;
- obj->up = 0;
- /*
- * While this isn't the best way to try to correct an error, this won't automatically
- * fail when the statement handle invalidates.
- */
- /* XXX Actually, it might, if we're using a non-pooled connection. Possible race here. XXX */
- odbc_obj_disconnect(obj);
- odbc_obj_connect(obj);
+ if (!ast_odbc_sanity_check(obj)) {
+ break;
+ }
continue;
} else
obj->last_used = ast_tvnow();
break;
} else {
- ast_log(LOG_WARNING, "SQL Prepare failed. Attempting a reconnect...\n");
- odbc_obj_disconnect(obj);
- odbc_obj_connect(obj);
+ ast_log(LOG_WARNING, "SQL Prepare failed. Verifying connection to %s [%s]\n", obj->parent->name, obj->parent->dsn);
+ ast_odbc_sanity_check(obj);
}
}