Skip to content
Snippets Groups Projects
Commit 44d68bd5 authored by Sean Bright's avatar Sean Bright Committed by George Joseph
Browse files

app_voicemail: Prevent deadlocks when out of ODBC database connections

ASTERISK-28992 #close

Change-Id: Ia7d608924036139ee2520b840d077762d02668d0
parent ffa87eca
No related branches found
No related tags found
3 merge requests!138Merge branch asterisk-20.3.0 into devel properly,!123Merge asterisk '20.3.0' into devel,!118Draft: manager: AOC-S support for AOCMessage
...@@ -3834,6 +3834,7 @@ static int retrieve_file(char *dir, int msgnum) ...@@ -3834,6 +3834,7 @@ static int retrieve_file(char *dir, int msgnum)
char fn[PATH_MAX]; char fn[PATH_MAX];
char full_fn[PATH_MAX]; char full_fn[PATH_MAX];
char msgnums[80]; char msgnums[80];
char msg_id[MSG_ID_LEN] = "";
char *argv[] = { dir, msgnums }; char *argv[] = { dir, msgnums };
struct generic_prepare_struct gps = { .sql = sql, .argc = 2, .argv = argv }; struct generic_prepare_struct gps = { .sql = sql, .argc = 2, .argv = argv };
struct odbc_obj *obj; struct odbc_obj *obj;
...@@ -3938,10 +3939,10 @@ static int retrieve_file(char *dir, int msgnum) ...@@ -3938,10 +3939,10 @@ static int retrieve_file(char *dir, int msgnum)
} else { } else {
res = SQLGetData(stmt, x + 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL); res = SQLGetData(stmt, x + 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
if (res == SQL_NULL_DATA && !strcasecmp(coltitle, "msg_id")) { if (res == SQL_NULL_DATA && !strcasecmp(coltitle, "msg_id")) {
char msg_id[MSG_ID_LEN]; /* Generate msg_id now, but don't store it until we're done with this
connection */
generate_msg_id(msg_id); generate_msg_id(msg_id);
snprintf(rowdata, sizeof(rowdata), "%s", msg_id); snprintf(rowdata, sizeof(rowdata), "%s", msg_id);
odbc_update_msg_id(dir, msgnum, msg_id);
} else if (res == SQL_NULL_DATA && !strcasecmp(coltitle, "category")) { } else if (res == SQL_NULL_DATA && !strcasecmp(coltitle, "category")) {
/* Ignore null column value for category */ /* Ignore null column value for category */
ast_debug(3, "Ignoring null category column in ODBC voicemail retrieve_file.\n"); ast_debug(3, "Ignoring null category column in ODBC voicemail retrieve_file.\n");
...@@ -3967,6 +3968,13 @@ bail: ...@@ -3967,6 +3968,13 @@ bail:
   
ast_odbc_release_obj(obj); ast_odbc_release_obj(obj);
   
/* If res_odbc is configured to only allow a single database connection, we
will deadlock if we try to do this before releasing the connection we
were just using. */
if (!ast_strlen_zero(msg_id)) {
odbc_update_msg_id(dir, msgnum, msg_id);
}
return x - 1; return x - 1;
} }
   
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment