mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
stratum: attempt to fix a list corruption (shares)
This commit is contained in:
parent
abc134ced9
commit
4ccd8248bd
2 changed files with 37 additions and 6 deletions
|
@ -44,25 +44,56 @@ void object_delete(YAAMP_OBJECT *object)
|
|||
void object_prune(CommonList *list, YAAMP_OBJECT_DELETE_FUNC deletefunc)
|
||||
{
|
||||
list->Enter();
|
||||
for(CLI li = list->first; li; )
|
||||
for(CLI li = list->first; li && list->count > 0; )
|
||||
{
|
||||
CLI todel = li;
|
||||
YAAMP_OBJECT *object = (YAAMP_OBJECT *)li->data;
|
||||
li = li->next;
|
||||
|
||||
// if(object->deleted && object->locked)
|
||||
// debuglog("object set for delete is locked\n");
|
||||
if(!object) continue;
|
||||
|
||||
if(object->deleted && !object->lock_count)
|
||||
{
|
||||
list->Delete(object);
|
||||
deletefunc(object);
|
||||
todel->data = NULL;
|
||||
list->Delete(todel);
|
||||
}
|
||||
|
||||
else if(object->lock_count && object->unlock)
|
||||
object->lock_count--;
|
||||
}
|
||||
|
||||
// debuglog("still %d objects in list\n", list->count);
|
||||
list->Leave();
|
||||
}
|
||||
|
||||
void object_prune_debug(CommonList *list, YAAMP_OBJECT_DELETE_FUNC deletefunc)
|
||||
{
|
||||
list->Enter();
|
||||
for(CLI li = list->first; li && list->count > 0; )
|
||||
{
|
||||
CLI todel = li;
|
||||
YAAMP_OBJECT *object = (YAAMP_OBJECT *)li->data;
|
||||
li = li->next;
|
||||
|
||||
if(!object) continue;
|
||||
|
||||
if(object->deleted && object->lock_count)
|
||||
debuglog("object set for delete is locked\n");
|
||||
|
||||
if(object->deleted && !object->lock_count)
|
||||
{
|
||||
deletefunc(object);
|
||||
todel->data = NULL;
|
||||
list->Delete(todel);
|
||||
}
|
||||
|
||||
else if(object->lock_count && object->unlock)
|
||||
object->lock_count--;
|
||||
}
|
||||
|
||||
if (list->count)
|
||||
debuglog("still %d objects in list\n", list->count);
|
||||
|
||||
list->Leave();
|
||||
}
|
||||
|
||||
|
@ -70,4 +101,3 @@ void object_prune(CommonList *list, YAAMP_OBJECT_DELETE_FUNC deletefunc)
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ typedef void (*YAAMP_OBJECT_DELETE_FUNC)(YAAMP_OBJECT *);
|
|||
|
||||
YAAMP_OBJECT *object_find(CommonList *list, int id, bool lock=false);
|
||||
void object_prune(CommonList *list, YAAMP_OBJECT_DELETE_FUNC deletefunc);
|
||||
void object_prune_debug(CommonList *list, YAAMP_OBJECT_DELETE_FUNC deletefunc);
|
||||
|
||||
void object_lock(YAAMP_OBJECT *object);
|
||||
void object_unlock(YAAMP_OBJECT *object);
|
||||
|
|
Loading…
Add table
Reference in a new issue