| 649 |
return p_section; |
return p_section; |
| 650 |
} |
} |
| 651 |
|
|
| 652 |
|
int section_list_update(SECTION_LIST *p_section, const char *sname, const char *stitle, const char *master_list) |
| 653 |
|
{ |
| 654 |
|
int64_t index; |
| 655 |
|
|
| 656 |
|
if (p_section == NULL || sname == NULL || stitle == NULL || master_list == NULL) |
| 657 |
|
{ |
| 658 |
|
log_error("NULL pointer error\n"); |
| 659 |
|
return -1; |
| 660 |
|
} |
| 661 |
|
|
| 662 |
|
index = get_section_index(p_section); |
| 663 |
|
|
| 664 |
|
strncpy(p_section->sname, sname, sizeof(p_section->sname) - 1); |
| 665 |
|
p_section->sname[sizeof(p_section->sname) - 1] = '\0'; |
| 666 |
|
|
| 667 |
|
strncpy(p_section->stitle, stitle, sizeof(p_section->stitle) - 1); |
| 668 |
|
p_section->stitle[sizeof(p_section->stitle) - 1] = '\0'; |
| 669 |
|
|
| 670 |
|
strncpy(p_section->master_list, master_list, sizeof(p_section->master_list) - 1); |
| 671 |
|
p_section->master_list[sizeof(p_section->master_list) - 1] = '\0'; |
| 672 |
|
|
| 673 |
|
if (trie_dict_set(p_section_list_pool->p_trie_dict_section_by_name, sname, index) < 0) |
| 674 |
|
{ |
| 675 |
|
log_error("trie_dict_set(section, %s, %d) error\n", sname, index); |
| 676 |
|
return -2; |
| 677 |
|
} |
| 678 |
|
|
| 679 |
|
return 0; |
| 680 |
|
} |
| 681 |
|
|
| 682 |
void section_list_reset_articles(SECTION_LIST *p_section) |
void section_list_reset_articles(SECTION_LIST *p_section) |
| 683 |
{ |
{ |
| 684 |
p_section->article_count = 0; |
p_section->article_count = 0; |
| 1715 |
timer++; |
timer++; |
| 1716 |
if (timer % SECTION_TRY_LOCK_TIMES == 0) |
if (timer % SECTION_TRY_LOCK_TIMES == 0) |
| 1717 |
{ |
{ |
| 1718 |
log_error("section_list_try_rd_lock() tried %d times on section %d\n", sid, timer); |
log_error("section_list_try_rd_lock() tried %d times on section %d\n", timer, sid); |
| 1719 |
} |
} |
| 1720 |
} |
} |
| 1721 |
else // failed |
else // failed |
| 1746 |
timer++; |
timer++; |
| 1747 |
if (timer % SECTION_TRY_LOCK_TIMES == 0) |
if (timer % SECTION_TRY_LOCK_TIMES == 0) |
| 1748 |
{ |
{ |
| 1749 |
log_error("section_list_try_rw_lock() tried %d times on section %d\n", sid, timer); |
log_error("section_list_try_rw_lock() tried %d times on section %d\n", timer, sid); |
| 1750 |
} |
} |
| 1751 |
} |
} |
| 1752 |
else // failed |
else // failed |