Made first use of queued messages and fixed several bugs with that
This commit is contained in:
@ -44,10 +44,11 @@ int burn_msgs_initialize(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if(libdax_messenger == NULL)
|
||||
if(libdax_messenger == NULL) {
|
||||
ret = libdax_msgs_new(&libdax_messenger,0);
|
||||
if (ret <= 0)
|
||||
return 0;
|
||||
if (ret <= 0)
|
||||
return 0;
|
||||
}
|
||||
libdax_msgs_set_severities(libdax_messenger, LIBDAX_MSGS_SEV_NEVER,
|
||||
LIBDAX_MSGS_SEV_FATAL, "libburn: ", 0);
|
||||
return 1;
|
||||
@ -173,7 +174,6 @@ int burn_msgs_obtain(char *minimum_severity,
|
||||
LIBDAX_MSGS_PRIO_ZERO, 0);
|
||||
if (ret <= 0)
|
||||
goto ex;
|
||||
|
||||
ret = libdax_msgs_item_get_msg(item, error_code, &textpt, os_errno, 0);
|
||||
if (ret <= 0)
|
||||
goto ex;
|
||||
|
@ -1110,7 +1110,7 @@ int burn_msgs_set_severities(char *queue_severity,
|
||||
char *print_severity, char *print_id);
|
||||
|
||||
/* ts A60924 : ticket 74 */
|
||||
#define BURM_MSGS_MESSAGE_LEN 4096
|
||||
#define BURN_MSGS_MESSAGE_LEN 4096
|
||||
|
||||
/** Obtain the oldest pending libburn message from the queue which has at
|
||||
least the given minimum_severity. This message and any older message of
|
||||
@ -1120,7 +1120,7 @@ int burn_msgs_set_severities(char *queue_severity,
|
||||
will discard the whole queue.
|
||||
@param error_code Will become a unique error code as liste in
|
||||
libburn/libdax_msgs.h
|
||||
@param msg_text Must provide at least BURM_MSGS_MESSAGE_LEN bytes.
|
||||
@param msg_text Must provide at least BURN_MSGS_MESSAGE_LEN bytes.
|
||||
@param os_errno Will become the eventual errno related to the message
|
||||
@param severity Will become the severity related to the message and
|
||||
should provide at least 80 bytes.
|
||||
|
@ -58,20 +58,38 @@ static int libdax_msgs_item_new(struct libdax_msgs_item **item,
|
||||
}
|
||||
|
||||
|
||||
int libdax_msgs_item_destroy(struct libdax_msgs_item **item,
|
||||
int flag)
|
||||
/** Detaches item from its queue and eventually readjusts start, end pointers
|
||||
of the queue */
|
||||
int libdax_msgs_item_unlink(struct libdax_msgs_item *o,
|
||||
struct libdax_msgs_item **chain_start,
|
||||
struct libdax_msgs_item **chain_end, int flag)
|
||||
{
|
||||
struct libdax_msgs_item *o;
|
||||
|
||||
o= *item;
|
||||
if(o==NULL)
|
||||
return(0);
|
||||
if(o->msg_text!=NULL)
|
||||
free((char *) o->msg_text);
|
||||
if(o->prev!=NULL)
|
||||
o->prev->next= o->next;
|
||||
if(o->next!=NULL)
|
||||
o->next->prev= o->prev;
|
||||
if(chain_start!=NULL)
|
||||
if(*chain_start == o)
|
||||
*chain_start= o->next;
|
||||
if(chain_end!=NULL)
|
||||
if(*chain_end == o)
|
||||
*chain_end= o->prev;
|
||||
o->next= o->prev= NULL;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int libdax_msgs_item_destroy(struct libdax_msgs_item **item,
|
||||
int flag)
|
||||
{
|
||||
struct libdax_msgs_item *o;
|
||||
|
||||
o= *item;
|
||||
if(o==NULL)
|
||||
return(0);
|
||||
libdax_msgs_item_unlink(o,NULL,NULL,0);
|
||||
if(o->msg_text!=NULL)
|
||||
free((char *) o->msg_text);
|
||||
free((char *) o);
|
||||
*item= NULL;
|
||||
return(1);
|
||||
@ -314,6 +332,8 @@ int libdax_msgs_submit(struct libdax_msgs *m, int driveno, int error_code,
|
||||
strcpy(item->msg_text,msg_text);
|
||||
}
|
||||
item->os_errno= os_errno;
|
||||
if(m->oldest==NULL)
|
||||
m->oldest= item;
|
||||
m->youngest= item;
|
||||
m->count++;
|
||||
libdax_msgs_unlock(m,0);
|
||||
@ -337,6 +357,7 @@ int libdax_msgs_obtain(struct libdax_msgs *m, struct libdax_msgs_item **item,
|
||||
int ret;
|
||||
struct libdax_msgs_item *im, *next_im= NULL;
|
||||
|
||||
*item= NULL;
|
||||
ret= libdax_msgs_lock(m,0);
|
||||
if(ret<=0)
|
||||
return(-1);
|
||||
@ -345,6 +366,7 @@ int libdax_msgs_obtain(struct libdax_msgs *m, struct libdax_msgs_item **item,
|
||||
next_im= im->next;
|
||||
if(im->severity>=severity)
|
||||
break;
|
||||
libdax_msgs_item_unlink(im,&(m->oldest),&(m->youngest),0);
|
||||
libdax_msgs_item_destroy(&im,0); /* severity too low: delete */
|
||||
}
|
||||
if(im==NULL)
|
||||
@ -354,6 +376,7 @@ int libdax_msgs_obtain(struct libdax_msgs *m, struct libdax_msgs_item **item,
|
||||
}
|
||||
if(im==NULL)
|
||||
{ret= 0; goto ex;}
|
||||
libdax_msgs_item_unlink(im,&(m->oldest),&(m->youngest),0);
|
||||
*item= im;
|
||||
ret= 1;
|
||||
ex:;
|
||||
|
Reference in New Issue
Block a user