| 44 |
SECTION_DATA *p_section[BBS_max_section]; |
SECTION_DATA *p_section[BBS_max_section]; |
| 45 |
ARTICLE *p_article; |
ARTICLE *p_article; |
| 46 |
ARTICLE article; |
ARTICLE article; |
| 47 |
|
int block_count; |
| 48 |
int i, j; |
int i, j; |
| 49 |
int last_aid; |
int last_aid; |
| 50 |
int group_count; |
int group_count; |
| 51 |
|
int article_count; |
| 52 |
|
|
| 53 |
if (log_begin("../log/bbsd.log", "../log/error.log") < 0) |
if (log_begin("../log/bbsd.log", "../log/error.log") < 0) |
| 54 |
{ |
{ |
| 59 |
log_std_redirect(STDOUT_FILENO); |
log_std_redirect(STDOUT_FILENO); |
| 60 |
log_err_redirect(STDERR_FILENO); |
log_err_redirect(STDERR_FILENO); |
| 61 |
|
|
| 62 |
if (section_data_pool_init("../conf/menu.conf", BBS_article_block_limit_per_section * BBS_max_section) < 0) |
block_count = BBS_article_block_limit_per_section * BBS_max_section - 1; |
| 63 |
|
|
| 64 |
|
if (section_data_pool_init("../conf/menu.conf", block_count) < 0) |
| 65 |
{ |
{ |
| 66 |
log_error("section_data_pool_init() error\n"); |
log_error("section_data_pool_init() error\n"); |
| 67 |
return -2; |
return -2; |
| 96 |
article.ontop = 0; |
article.ontop = 0; |
| 97 |
article.lock = 0; |
article.lock = 0; |
| 98 |
|
|
| 99 |
section_data_append_article(p_section[i], &article); |
if (section_data_append_article(p_section[i], &article) < 0) |
| 100 |
|
{ |
| 101 |
|
printf("append article (aid = %d) error\n", article.aid); |
| 102 |
|
break; |
| 103 |
|
} |
| 104 |
} |
} |
| 105 |
|
|
| 106 |
printf("Load %d articles into section %d\n", p_section[i]->article_count, i); |
printf("Load %d articles into section %d\n", p_section[i]->article_count, i); |
| 110 |
|
|
| 111 |
for (i = 0; i < section_count; i++) |
for (i = 0; i < section_count; i++) |
| 112 |
{ |
{ |
| 113 |
|
if (p_section[i]->article_count == 0) |
| 114 |
|
{ |
| 115 |
|
continue; |
| 116 |
|
} |
| 117 |
|
|
| 118 |
for (j = 0; j < p_section[i]->article_count; j++) |
for (j = 0; j < p_section[i]->article_count; j++) |
| 119 |
{ |
{ |
| 120 |
last_aid++; |
last_aid++; |
| 157 |
article.ontop = 0; |
article.ontop = 0; |
| 158 |
article.lock = 0; |
article.lock = 0; |
| 159 |
|
|
| 160 |
section_data_append_article(p_section[i], &article); |
if (section_data_append_article(p_section[i], &article) < 0) |
| 161 |
|
{ |
| 162 |
|
printf("append article (aid = %d) error\n", article.aid); |
| 163 |
|
break; |
| 164 |
|
} |
| 165 |
} |
} |
| 166 |
|
|
| 167 |
printf("Load %d articles into section %d\n", p_section[i]->article_count, i); |
printf("Load %d articles into section %d\n", p_section[i]->article_count, i); |
| 169 |
|
|
| 170 |
for (i = 0; i < section_count; i++) |
for (i = 0; i < section_count; i++) |
| 171 |
{ |
{ |
| 172 |
|
if (p_section[i]->article_count == 0) |
| 173 |
|
{ |
| 174 |
|
continue; |
| 175 |
|
} |
| 176 |
|
|
| 177 |
for (j = 0; j < group_count; j++) |
for (j = 0; j < group_count; j++) |
| 178 |
{ |
{ |
| 179 |
p_article = section_data_find_article_by_index(p_section[i], j); |
p_article = section_data_find_article_by_index(p_section[i], j); |
| 188 |
break; |
break; |
| 189 |
} |
} |
| 190 |
|
|
| 191 |
|
article_count = 1; |
| 192 |
|
|
| 193 |
do |
do |
| 194 |
{ |
{ |
| 195 |
if (p_article->next_aid <= p_article->aid && p_article->next_aid != p_article->tid) |
if (p_article->next_aid <= p_article->aid && p_article->next_aid != p_article->tid) |
| 214 |
printf("Inconsistent tid at aid %d != %d\n", last_aid, j + 1); |
printf("Inconsistent tid at aid %d != %d\n", last_aid, j + 1); |
| 215 |
break; |
break; |
| 216 |
} |
} |
| 217 |
|
article_count++; |
| 218 |
} while (1); |
} while (1); |
| 219 |
|
|
| 220 |
|
if (article_count != p_section[i]->article_count / group_count) |
| 221 |
|
{ |
| 222 |
|
printf("Count of articles in topic %d is less than expected %d < %d\n", |
| 223 |
|
j + 1, article_count, p_section[i]->article_count / group_count); |
| 224 |
|
} |
| 225 |
} |
} |
| 226 |
|
|
| 227 |
printf("Verify %d topics in section %d\n", group_count, i); |
printf("Verify %d topics in section %d\n", group_count, i); |