| ... | ... |
@@ -501,58 +501,19 @@ static inline void cacheset_add(struct cache_set *cs, unsigned char *md5, size_t |
| 501 | 501 |
|
| 502 | 502 |
ptree("1:\n");
|
| 503 | 503 |
if(printtree(cs, cs->root, 0)) {
|
| 504 |
- abort(); |
|
| 504 |
+ cli_errmsg("cacheset_add: inconsistent tree before choosing newnode, good luck\n");
|
|
| 505 |
+ return; |
|
| 505 | 506 |
} |
| 506 | 507 |
|
| 507 | 508 |
newnode = cs->first; |
| 508 |
- /*#define TAKE_FIRST*/ |
|
| 509 |
-#ifdef TAKE_FIRST |
|
| 510 |
- if((newnode->left || newnode->right || newnode->up)) {
|
|
| 511 |
- if(!splay(newnode->digest, newnode->size, cs)) {
|
|
| 512 |
- cli_errmsg("WTF\n");
|
|
| 513 |
- abort(); |
|
| 514 |
- } |
|
| 515 |
- if(!newnode->left) {
|
|
| 516 |
- cs->root = newnode->right; |
|
| 517 |
- newnode->right->up = NULL; |
|
| 518 |
- } else if(!newnode->right) {
|
|
| 519 |
- cs->root = newnode->left; |
|
| 520 |
- newnode->left->up = NULL; |
|
| 521 |
- } else {
|
|
| 522 |
- cs->root = newnode->left; |
|
| 523 |
- newnode->left->up = NULL; |
|
| 524 |
- if(splay(newnode->digest, newnode->size, cs)) {
|
|
| 525 |
- cli_errmsg("WTF #2\n");
|
|
| 526 |
- abort(); |
|
| 527 |
- } |
|
| 528 |
- cs->root->up = NULL; |
|
| 529 |
- cs->root->right = newnode->right; |
|
| 530 |
- if(newnode->right) newnode->right->up = cs->root; |
|
| 531 |
- } |
|
| 532 |
- newnode->up = NULL; |
|
| 533 |
- newnode->right = NULL; |
|
| 534 |
- newnode->left = NULL; |
|
| 535 |
- if(splay(hash, size, cs)) {
|
|
| 536 |
- cli_errmsg("WTF #3\n");
|
|
| 537 |
- abort(); |
|
| 538 |
- } |
|
| 539 |
- } |
|
| 540 |
- newnode->prev = cs->last; |
|
| 541 |
- cs->last->next = newnode; |
|
| 542 |
- cs->last = newnode; |
|
| 543 |
- newnode->next->prev = NULL; |
|
| 544 |
- cs->first = newnode->next; |
|
| 545 |
- newnode->next = NULL; |
|
| 546 |
- |
|
| 547 |
-#else |
|
| 548 | 509 |
while(newnode) {
|
| 549 | 510 |
if(!newnode->right && !newnode->left) |
| 550 | 511 |
break; |
| 551 | 512 |
newnode = newnode->next; |
| 552 | 513 |
} |
| 553 | 514 |
if(!newnode) {
|
| 554 |
- cli_errmsg("NO NEWNODE!\n");
|
|
| 555 |
- abort(); |
|
| 515 |
+ cli_errmsg("cacheset_add: tree has got no end nodes\n");
|
|
| 516 |
+ return; |
|
| 556 | 517 |
} |
| 557 | 518 |
if(newnode->up) {
|
| 558 | 519 |
if(newnode->up->left == newnode) |
| ... | ... |
@@ -571,11 +532,11 @@ static inline void cacheset_add(struct cache_set *cs, unsigned char *md5, size_t |
| 571 | 571 |
newnode->next = NULL; |
| 572 | 572 |
cs->last->next = newnode; |
| 573 | 573 |
cs->last = newnode; |
| 574 |
-#endif |
|
| 575 | 574 |
|
| 576 | 575 |
ptree("2:\n");
|
| 577 | 576 |
if(printtree(cs, cs->root, 0)) {
|
| 578 |
- abort(); |
|
| 577 |
+ cli_errmsg("cacheset_add: inconsistent tree before adding newnode, good luck\n");
|
|
| 578 |
+ return; |
|
| 579 | 579 |
} |
| 580 | 580 |
|
| 581 | 581 |
if(!cs->root) {
|
| ... | ... |
@@ -603,7 +564,8 @@ static inline void cacheset_add(struct cache_set *cs, unsigned char *md5, size_t |
| 603 | 603 |
|
| 604 | 604 |
ptree("3: %lld\n", hash[1]);
|
| 605 | 605 |
if(printtree(cs, cs->root, 0)) {
|
| 606 |
- abort(); |
|
| 606 |
+ cli_errmsg("cacheset_add: inconsistent tree after adding newnode, good luck\n");
|
|
| 607 |
+ return; |
|
| 607 | 608 |
} |
| 608 | 609 |
} |
| 609 | 610 |
#endif /* USE_SPLAY */ |