Made Xorriso_process_msg_queues() thread-safe
This commit is contained in:
@ -30,12 +30,16 @@
|
||||
#include <sys/wait.h>
|
||||
|
||||
|
||||
|
||||
#include "xorriso.h"
|
||||
#include "xorriso_private.h"
|
||||
#include "xorrisoburn.h"
|
||||
|
||||
|
||||
#ifdef Xorriso_fetch_with_msg_queueS
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* @param flag bit0= do not warn of wildcards
|
||||
bit1= these are disk_paths
|
||||
*/
|
||||
@ -207,17 +211,55 @@ int Xorriso_set_problem_status(struct XorrisO *xorriso, char *severity,
|
||||
char *sev_text= "ALL";
|
||||
int sev, ret;
|
||||
|
||||
#ifdef Xorriso_fetch_with_msg_queueS
|
||||
int locked= 0, uret;
|
||||
static int complaints= 0, complaint_limit= 5;
|
||||
#endif
|
||||
|
||||
if(severity[0])
|
||||
sev_text= severity;
|
||||
ret= Xorriso__text_to_sev(sev_text, &sev, 0);
|
||||
if(ret<=0)
|
||||
return(0);
|
||||
|
||||
#ifdef Xorriso_fetch_with_msg_queueS
|
||||
|
||||
ret= pthread_mutex_lock(&(xorriso->problem_status_lock));
|
||||
if(ret != 0) {
|
||||
/* Cannot report failure through the failing message output system */
|
||||
complaints++;
|
||||
if(complaints < complaint_limit)
|
||||
fprintf(stderr,
|
||||
"xorriso : pthread_mutex_lock() for problem_status returns %d\n",
|
||||
ret);
|
||||
} else
|
||||
locked= 1;
|
||||
|
||||
#endif /* Xorriso_fetch_with_msg_queueS */
|
||||
|
||||
xorriso->problem_status= sev;
|
||||
strcpy(xorriso->problem_status_text, sev_text);
|
||||
if(sev > xorriso->eternal_problem_status) {
|
||||
xorriso->eternal_problem_status= sev;
|
||||
strcpy(xorriso->eternal_problem_status_text, sev_text);
|
||||
}
|
||||
|
||||
#ifdef Xorriso_fetch_with_msg_queueS
|
||||
|
||||
if(locked) {
|
||||
uret= pthread_mutex_unlock(&(xorriso->problem_status_lock));
|
||||
if(uret != 0) {
|
||||
/* Cannot report failure through the failing message output system */
|
||||
complaints++;
|
||||
if(complaints < complaint_limit)
|
||||
fprintf(stderr,
|
||||
"xorriso : pthread_mutex_unlock() for problem_status returns %d\n",
|
||||
uret);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Xorriso_fetch_with_msg_queueS */
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user