Changed the way blockbuffers are used after they fill up.
The blockbuffers that get full are now moved to the end of the list of blocks. This prevents messages being written to the disk in the wrong order.
This commit is contained in:
@ -874,6 +874,7 @@ static char* blockbuf_get_writepos(
|
|||||||
size_t str_len,
|
size_t str_len,
|
||||||
bool flush)
|
bool flush)
|
||||||
{
|
{
|
||||||
|
int depth = 0;
|
||||||
logfile_t* lf;
|
logfile_t* lf;
|
||||||
mlist_t* bb_list;
|
mlist_t* bb_list;
|
||||||
char* pos = NULL;
|
char* pos = NULL;
|
||||||
@ -897,6 +898,7 @@ static char* blockbuf_get_writepos(
|
|||||||
*/
|
*/
|
||||||
node = bb_list->mlist_first;
|
node = bb_list->mlist_first;
|
||||||
|
|
||||||
|
|
||||||
/** Loop over blockbuf list to find write position */
|
/** Loop over blockbuf list to find write position */
|
||||||
while (true) {
|
while (true) {
|
||||||
CHK_MLIST_NODE(node);
|
CHK_MLIST_NODE(node);
|
||||||
@ -918,19 +920,9 @@ static char* blockbuf_get_writepos(
|
|||||||
*/
|
*/
|
||||||
blockbuf_register(bb);
|
blockbuf_register(bb);
|
||||||
|
|
||||||
#if defined(SS_DEBUG)
|
|
||||||
if(!bb->bb_isfull){
|
|
||||||
char* tmp = (char*)calloc(128,sizeof(char));
|
|
||||||
sprintf(tmp,"[full:%d]",atomic_add(&block_end_index,1));
|
|
||||||
memcpy(bb->bb_buf,tmp,strlen(tmp));
|
|
||||||
free(tmp);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bb->bb_isfull = true;
|
bb->bb_isfull = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
blockbuf_unregister(bb);
|
blockbuf_unregister(bb);
|
||||||
|
|
||||||
|
|
||||||
@ -940,6 +932,16 @@ static char* blockbuf_get_writepos(
|
|||||||
/** Lock list */
|
/** Lock list */
|
||||||
simple_mutex_lock(&bb_list->mlist_mutex, true);
|
simple_mutex_lock(&bb_list->mlist_mutex, true);
|
||||||
|
|
||||||
|
/**Move the full buffer to the end of the list*/
|
||||||
|
if(node->mlnode_next){
|
||||||
|
bb_list->mlist_first = node->mlnode_next;
|
||||||
|
bb_list->mlist_last->mlnode_next = node;
|
||||||
|
node->mlnode_next = NULL;
|
||||||
|
bb_list->mlist_last = node;
|
||||||
|
node = bb_list->mlist_first;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If next node exists move forward. Else check if there is
|
* If next node exists move forward. Else check if there is
|
||||||
* space for a new block buffer on the list.
|
* space for a new block buffer on the list.
|
||||||
|
|||||||
@ -45,7 +45,7 @@ error=0
|
|||||||
for i in $MESSAGES
|
for i in $MESSAGES
|
||||||
do
|
do
|
||||||
|
|
||||||
if [[ $i -le $prev ]]
|
if [[ $i -ne $(( prev + 1 )) ]]
|
||||||
then
|
then
|
||||||
error=1
|
error=1
|
||||||
echo "message mismatch: $i was after $prev."
|
echo "message mismatch: $i was after $prev."
|
||||||
|
|||||||
Reference in New Issue
Block a user