| 75 |
|
|
| 76 |
static ARTICLE_BLOCK_POOL *p_article_block_pool = NULL; |
static ARTICLE_BLOCK_POOL *p_article_block_pool = NULL; |
| 77 |
|
|
| 78 |
struct section_list_pool_t |
SECTION_LIST_POOL *p_section_list_pool = NULL; |
|
{ |
|
|
int shmid; |
|
|
SECTION_LIST sections[BBS_max_section]; |
|
|
int section_count; |
|
|
int semid; |
|
|
TRIE_NODE *p_trie_dict_section_by_name; |
|
|
TRIE_NODE *p_trie_dict_section_by_sid; |
|
|
}; |
|
|
typedef struct section_list_pool_t SECTION_LIST_POOL; |
|
|
|
|
|
static SECTION_LIST_POOL *p_section_list_pool = NULL; |
|
| 79 |
|
|
| 80 |
int article_block_init(const char *filename, int block_count) |
int article_block_init(const char *filename, int block_count) |
| 81 |
{ |
{ |
| 619 |
p_section = p_section_list_pool->sections + p_section_list_pool->section_count; |
p_section = p_section_list_pool->sections + p_section_list_pool->section_count; |
| 620 |
|
|
| 621 |
p_section->sid = sid; |
p_section->sid = sid; |
| 622 |
|
p_section->ex_menu_tm = 0; |
| 623 |
|
|
| 624 |
strncpy(p_section->sname, sname, sizeof(p_section->sname) - 1); |
strncpy(p_section->sname, sname, sizeof(p_section->sname) - 1); |
| 625 |
p_section->sname[sizeof(p_section->sname) - 1] = '\0'; |
p_section->sname[sizeof(p_section->sname) - 1] = '\0'; |
| 664 |
p_section->ontop_article_count = 0; |
p_section->ontop_article_count = 0; |
| 665 |
} |
} |
| 666 |
|
|
| 667 |
SECTION_LIST *section_list_find_by_name(const char *sname) |
SECTION_LIST *section_list_find_by_name(const char *sname, int64_t *p_index) |
| 668 |
{ |
{ |
| 669 |
int64_t index; |
int64_t index; |
| 670 |
int ret; |
int ret; |
| 686 |
return NULL; |
return NULL; |
| 687 |
} |
} |
| 688 |
|
|
| 689 |
|
if (p_index != NULL) |
| 690 |
|
{ |
| 691 |
|
*p_index = index; |
| 692 |
|
} |
| 693 |
|
|
| 694 |
return (p_section_list_pool->sections + index); |
return (p_section_list_pool->sections + index); |
| 695 |
} |
} |
| 696 |
|
|
| 697 |
SECTION_LIST *section_list_find_by_sid(int32_t sid) |
SECTION_LIST *section_list_find_by_sid(int32_t sid, int64_t *p_index) |
| 698 |
{ |
{ |
| 699 |
int64_t index; |
int64_t index; |
| 700 |
int ret; |
int ret; |
| 719 |
return NULL; |
return NULL; |
| 720 |
} |
} |
| 721 |
|
|
| 722 |
|
if (p_index != NULL) |
| 723 |
|
{ |
| 724 |
|
*p_index = index; |
| 725 |
|
} |
| 726 |
|
|
| 727 |
return (p_section_list_pool->sections + index); |
return (p_section_list_pool->sections + index); |
| 728 |
} |
} |
| 729 |
|
|
| 1033 |
return -1; |
return -1; |
| 1034 |
} |
} |
| 1035 |
|
|
| 1036 |
page_count = p_section->page_count - 1 + |
page_count = p_section->page_count - (p_section->last_page_visible_article_count > 0 ? 1 : 0) + |
| 1037 |
(p_section->last_page_visible_article_count + p_section->ontop_article_count) / BBS_article_limit_per_page + |
(p_section->last_page_visible_article_count + p_section->ontop_article_count) / BBS_article_limit_per_page + |
| 1038 |
((p_section->last_page_visible_article_count + p_section->ontop_article_count) % BBS_article_limit_per_page == 0 ? 0 : 1); |
((p_section->last_page_visible_article_count + p_section->ontop_article_count) % BBS_article_limit_per_page == 0 ? 0 : 1); |
| 1039 |
|
|
| 1695 |
timer++; |
timer++; |
| 1696 |
if (timer % SECTION_TRY_LOCK_TIMES == 0) |
if (timer % SECTION_TRY_LOCK_TIMES == 0) |
| 1697 |
{ |
{ |
| 1698 |
log_error("section_list_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", sid, timer); |
| 1699 |
} |
} |
| 1700 |
} |
} |
| 1701 |
else // failed |
else // failed |
| 1702 |
{ |
{ |
| 1703 |
log_error("section_list_rd_lock() failed on section %d\n", sid); |
log_error("section_list_try_rd_lock() failed on section %d\n", sid); |
| 1704 |
break; |
break; |
| 1705 |
} |
} |
| 1706 |
} |
} |
| 1726 |
timer++; |
timer++; |
| 1727 |
if (timer % SECTION_TRY_LOCK_TIMES == 0) |
if (timer % SECTION_TRY_LOCK_TIMES == 0) |
| 1728 |
{ |
{ |
| 1729 |
log_error("acquire_section_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", sid, timer); |
| 1730 |
} |
} |
| 1731 |
} |
} |
| 1732 |
else // failed |
else // failed |
| 1733 |
{ |
{ |
| 1734 |
log_error("acquire_section_rw_lock() failed on section %d\n", sid); |
log_error("section_list_try_rw_lock() failed on section %d\n", sid); |
| 1735 |
break; |
break; |
| 1736 |
} |
} |
| 1737 |
} |
} |