Avoiding to use message system while result_msglists_lock is acquired. Coverity CID 28726.

This commit is contained in:
Thomas Schmitt 2015-11-15 15:38:43 +00:00
parent 84c3e88eb3
commit dea1aa5182
2 changed files with 37 additions and 15 deletions

View File

@ -888,7 +888,8 @@ static int Xorriso_write_to_msglist(struct XorrisO *xorriso,
struct Xorriso_lsT *msglist;
ret= Xorriso_lock_outlists(xorriso, 0);
if(ret > 0)
if(ret <= 0)
goto ex;
locked= 1;
msglist= *xorriso_msglist;
ret= Xorriso_lst_append_binary(&msglist, text, strlen(text) + 1, 0);
@ -1174,9 +1175,12 @@ int Xorriso_push_outlists(struct XorrisO *xorriso, int *stack_handle,
int ret, locked= 0;
ret= Xorriso_lock_outlists(xorriso, 0);
if(ret > 0)
if(ret <= 0)
goto ex;
locked= 1;
if(xorriso->msglist_stackfill + 1 >= Xorriso_max_outlist_stacK) {
Xorriso_unlock_outlists(xorriso, 0);
locked= 0;
Xorriso_msgs_submit(xorriso, 0,
"Overflow of message output redirection stack", 0, "FATAL", 0);
ret= -1; goto ex;
@ -1215,12 +1219,15 @@ int Xorriso_fetch_outlists(struct XorrisO *xorriso, int stack_handle,
flag|= 3;
ret= Xorriso_lock_outlists(xorriso, 0);
if(ret > 0)
if(ret <= 0)
goto ex;
locked= 1;
if(stack_handle == -1)
stack_handle= xorriso->msglist_stackfill - 1;
if(stack_handle < 0 || stack_handle >= xorriso->msglist_stackfill) {
Xorriso_unlock_outlists(xorriso, 0);
locked= 0;
Xorriso_msgs_submit(xorriso, 0,
"Program error: Wrong message output redirection stack handle",
0, "FATAL", 0);
@ -1304,12 +1311,15 @@ int Xorriso_pull_outlists(struct XorrisO *xorriso, int stack_handle,
int i, ret, locked= 0;
ret= Xorriso_lock_outlists(xorriso, 0);
if(ret > 0)
if(ret <= 0)
goto ex;
locked= 1;
if(stack_handle == -1)
stack_handle= xorriso->msglist_stackfill - 1;
if(stack_handle < 0 || stack_handle >= xorriso->msglist_stackfill) {
Xorriso_unlock_outlists(xorriso, 0);
locked= 0;
Xorriso_msgs_submit(xorriso, 0,
"Program error: Wrong message output redirection stack handle",
0, "FATAL", 0);
@ -1442,7 +1452,7 @@ int Xorriso_process_msg_lists(struct XorrisO *xorriso,
static void *Xorriso_msg_watcher(void *state_pt)
{
struct XorrisO *xorriso;
int ret, u_wait= 25000, line_count, sleep_thresh= 20;
int ret, u_wait= 25000, line_count, sleep_thresh= 20, lock_failure= 0;
struct Xorriso_lsT *result_list= NULL, *info_list= NULL;
static int debug_sev= 0;
@ -1464,8 +1474,12 @@ static void *Xorriso_msg_watcher(void *state_pt)
if(xorriso->msg_watcher_state == 3)
break;
Xorriso_obtain_lock(xorriso, &(xorriso->msgw_fetch_lock),
ret= Xorriso_obtain_lock(xorriso, &(xorriso->msgw_fetch_lock),
"message watcher fetch operation", 1);
if(ret <= 0) {
lock_failure= 1;
break;
}
xorriso->msgw_msg_pending= 1;
ret= Xorriso_fetch_outlists(xorriso, -1, &result_list, &info_list, 3);
if(ret > 0) {
@ -1495,7 +1509,8 @@ static void *Xorriso_msg_watcher(void *state_pt)
}
if(xorriso->msgw_info_handler != NULL &&
debug_sev < xorriso->report_about_severity &&
debug_sev < xorriso->abort_on_severity)
debug_sev < xorriso->abort_on_severity &&
!lock_failure)
(*xorriso->msgw_info_handler)(xorriso,
"xorriso : DEBUG : Concurrent message watcher ended\n");
xorriso->msg_watcher_state= 0;
@ -1631,8 +1646,15 @@ int Xorriso_stop_msg_watcher(struct XorrisO *xorriso, int flag)
usleep(u_wait);
}
Xorriso_obtain_lock(xorriso, &(xorriso->msgw_fetch_lock),
ret= Xorriso_obtain_lock(xorriso, &(xorriso->msgw_fetch_lock),
"message watcher fetch operation", 1);
if(ret <= 0) {
Xorriso_msgs_submit(xorriso, 0,
"Cannot obtain mutex lock for managing concurrent message watcher",
ret, "FATAL", 0);
ret= -1;
goto ex;
}
xorriso->msgw_msg_pending= 1;
ret= Xorriso_pull_outlists(xorriso, xorriso->msgw_stack_handle,
&result_list, &info_list, 0);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2015.11.13.202241"
#define Xorriso_timestamP "2015.11.15.153822"