| 153 |
} |
} |
| 154 |
|
|
| 155 |
cleanup: |
cleanup: |
| 156 |
|
mysql_free_result(rs2); |
| 157 |
mysql_free_result(rs); |
mysql_free_result(rs); |
| 158 |
mysql_close(db); |
mysql_close(db); |
| 159 |
|
|
| 321 |
mysql_free_result(rs); |
mysql_free_result(rs); |
| 322 |
mysql_close(db); |
mysql_close(db); |
| 323 |
|
|
| 324 |
|
article_cache_cleanup(); |
| 325 |
|
|
| 326 |
return (ret < 0 ? ret : article_count); |
return (ret < 0 ? ret : article_count); |
| 327 |
} |
} |
| 328 |
|
|
| 589 |
p_article->excerption = 0; |
p_article->excerption = 0; |
| 590 |
break; |
break; |
| 591 |
case 'F': // Set article on top |
case 'F': // Set article on top |
|
p_article->ontop = 1; |
|
|
break; |
|
| 592 |
case 'V': // Unset article on top |
case 'V': // Unset article on top |
| 593 |
p_article->ontop = 0; |
p_article->ontop = (row[2][0] == 'F' ? 1 : 0); |
| 594 |
|
if (section_list_update_article_ontop(p_section, p_article) < 0) |
| 595 |
|
{ |
| 596 |
|
log_error("section_list_update_article_ontop(sid=%d, aid=%d) error\n", |
| 597 |
|
p_section->sid, p_article->aid); |
| 598 |
|
} |
| 599 |
break; |
break; |
| 600 |
case 'Z': // Set article as trnasship |
case 'Z': // Set article as trnasship |
| 601 |
p_article->transship = 1; |
p_article->transship = 1; |
| 753 |
|
|
| 754 |
// Child process exit |
// Child process exit |
| 755 |
|
|
| 756 |
|
article_cache_cleanup(); |
| 757 |
|
|
| 758 |
// Detach data pools shm |
// Detach data pools shm |
| 759 |
detach_section_list_shm(); |
detach_section_list_shm(); |
| 760 |
detach_article_block_shm(); |
detach_article_block_shm(); |
| 792 |
ARTICLE *p_article; |
ARTICLE *p_article; |
| 793 |
ARTICLE *p_next_page_first_article; |
ARTICLE *p_next_page_first_article; |
| 794 |
int ret = 0; |
int ret = 0; |
| 795 |
|
int i; |
| 796 |
|
|
| 797 |
if (p_section == NULL || p_articles == NULL || p_article_count == NULL || p_page_count == NULL) |
if (p_section == NULL || p_articles == NULL || p_article_count == NULL || p_page_count == NULL) |
| 798 |
{ |
{ |
| 807 |
return -2; |
return -2; |
| 808 |
} |
} |
| 809 |
|
|
| 810 |
*p_page_count = p_section->page_count; |
*p_page_count = section_list_page_count_with_ontop(p_section); |
| 811 |
|
*p_article_count = 0; |
| 812 |
|
|
| 813 |
if (p_section->visible_article_count == 0) |
if (p_section->visible_article_count == 0) |
| 814 |
{ |
{ |
| 815 |
*p_article_count = 0; |
// empty section |
| 816 |
} |
} |
| 817 |
else if (page_id < 0 || page_id >= p_section->page_count) |
else if (page_id < 0 || page_id >= *p_page_count) |
| 818 |
{ |
{ |
| 819 |
log_error("Invalid page_id=%d, not in range [0, %d)\n", page_id, p_section->page_count); |
log_error("Invalid page_id=%d, not in range [0, %d)\n", page_id, *p_page_count); |
| 820 |
ret = -3; |
ret = -3; |
| 821 |
} |
} |
| 822 |
else |
else |
| 823 |
{ |
{ |
| 824 |
ret = page_id; |
ret = page_id; |
|
p_article = p_section->p_page_first_article[page_id]; |
|
|
p_next_page_first_article = |
|
|
(page_id == p_section->page_count - 1 ? p_section->p_article_head : p_section->p_page_first_article[page_id + 1]); |
|
|
*p_article_count = 0; |
|
| 825 |
|
|
| 826 |
do |
if (page_id <= p_section->page_count - 1) |
| 827 |
{ |
{ |
| 828 |
if (p_article->visible) |
p_article = p_section->p_page_first_article[page_id]; |
| 829 |
|
p_next_page_first_article = |
| 830 |
|
(page_id == p_section->page_count - 1 ? p_section->p_article_head : p_section->p_page_first_article[page_id + 1]); |
| 831 |
|
|
| 832 |
|
do |
| 833 |
{ |
{ |
| 834 |
p_articles[*p_article_count] = p_article; |
if (p_article->visible) |
| 835 |
(*p_article_count)++; |
{ |
| 836 |
|
p_articles[*p_article_count] = p_article; |
| 837 |
|
(*p_article_count)++; |
| 838 |
|
} |
| 839 |
|
p_article = p_article->p_next; |
| 840 |
|
} while (p_article != p_next_page_first_article && (*p_article_count) <= BBS_article_limit_per_page); |
| 841 |
|
|
| 842 |
|
if (*p_article_count != (page_id < p_section->page_count - 1 ? BBS_article_limit_per_page : p_section->last_page_visible_article_count)) |
| 843 |
|
{ |
| 844 |
|
log_error("Inconsistent visible article count %d detected in section %d page %d\n", *p_article_count, p_section->sid, page_id); |
| 845 |
} |
} |
| 846 |
p_article = p_article->p_next; |
} |
|
} while (p_article != p_next_page_first_article && (*p_article_count) <= BBS_article_limit_per_page); |
|
| 847 |
|
|
| 848 |
if (*p_article_count != (page_id < p_section->page_count - 1 ? BBS_article_limit_per_page : p_section->last_page_visible_article_count)) |
// Append ontop articles |
| 849 |
|
if (page_id >= p_section->page_count - 1) |
| 850 |
{ |
{ |
| 851 |
log_error("Inconsistent visible article count %d detected in section %d page %d\n", *p_article_count, p_section->sid, page_id); |
i = (page_id == p_section->page_count - 1 |
| 852 |
|
? 0 |
| 853 |
|
: (page_id - p_section->page_count + 1) * BBS_article_limit_per_page - p_section->last_page_visible_article_count); |
| 854 |
|
while (*p_article_count < BBS_article_limit_per_page && i < p_section->ontop_article_count) |
| 855 |
|
{ |
| 856 |
|
p_articles[(*p_article_count)++] = p_section->p_ontop_articles[i++]; |
| 857 |
|
} |
| 858 |
} |
} |
| 859 |
} |
} |
| 860 |
|
|
| 951 |
} |
} |
| 952 |
p_article = p_article->p_next; |
p_article = p_article->p_next; |
| 953 |
} |
} |
| 954 |
|
|
| 955 |
|
// Include ontop articles |
| 956 |
|
*p_article_count = section_list_page_article_count_with_ontop(p_section, page_id); |
| 957 |
} |
} |
| 958 |
} |
} |
| 959 |
|
|