| 179 |
article.tid = 0; |
article.tid = 0; |
| 180 |
article.sid = i * 3 + 1; |
article.sid = i * 3 + 1; |
| 181 |
article.cid = article.aid; |
article.cid = article.aid; |
| 182 |
article.uid = 1; // TODO: randomize |
article.uid = 1; |
| 183 |
article.visible = 1; |
article.visible = 1; |
| 184 |
article.excerption = 0; |
article.excerption = 0; |
| 185 |
article.ontop = 0; |
article.ontop = 0; |
| 186 |
article.lock = 0; |
article.lock = 0; |
| 187 |
|
article.transship = 0; |
| 188 |
|
|
| 189 |
if (section_list_rw_lock(p_section[i]) < 0) |
if (section_list_rw_lock(p_section[i]) < 0) |
| 190 |
{ |
{ |
| 211 |
// printf("Loaded %d articles into section %d\n", p_section[i]->article_count, i); |
// printf("Loaded %d articles into section %d\n", p_section[i]->article_count, i); |
| 212 |
} |
} |
| 213 |
|
|
| 214 |
|
if (last_aid != article_block_last_aid()) |
| 215 |
|
{ |
| 216 |
|
printf("last_aid != %d\n", article_block_last_aid()); |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
if (article_block_article_count() != section_count * BBS_article_limit_per_section) |
| 220 |
|
{ |
| 221 |
|
printf("article_block_article_count() error %d != %d * %d\n", |
| 222 |
|
article_block_article_count(), section_count, BBS_article_limit_per_section); |
| 223 |
|
} |
| 224 |
|
|
| 225 |
last_aid = 0; |
last_aid = 0; |
| 226 |
|
|
| 227 |
for (j = 0; j < BBS_article_limit_per_section; j++) |
for (j = 0; j < BBS_article_limit_per_section; j++) |
| 302 |
article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count)); |
article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count)); |
| 303 |
article.sid = i * 3 + 1; |
article.sid = i * 3 + 1; |
| 304 |
article.cid = article.aid; |
article.cid = article.aid; |
| 305 |
article.uid = 1; // TODO: randomize |
article.uid = 1; |
| 306 |
article.visible = 1; |
article.visible = 1; |
| 307 |
article.excerption = 0; |
article.excerption = 0; |
| 308 |
article.ontop = 0; |
article.ontop = 0; |
| 309 |
article.lock = 0; |
article.lock = 0; |
| 310 |
|
article.transship = 0; |
| 311 |
|
|
| 312 |
if (section_list_append_article(p_section[i], &article) < 0) |
if (section_list_append_article(p_section[i], &article) < 0) |
| 313 |
{ |
{ |
| 760 |
article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count)); |
article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count)); |
| 761 |
article.sid = i * 3 + 1; |
article.sid = i * 3 + 1; |
| 762 |
article.cid = article.aid; |
article.cid = article.aid; |
| 763 |
article.uid = 1; // TODO: randomize |
article.uid = 1; |
| 764 |
article.visible = 1; |
article.visible = 1; |
| 765 |
article.excerption = 0; |
article.excerption = 0; |
| 766 |
article.ontop = 0; |
article.ontop = 0; |
| 767 |
article.lock = 0; |
article.lock = 0; |
| 768 |
|
article.transship = 0; |
| 769 |
|
|
| 770 |
if (section_list_append_article(p_section[i], &article) < 0) |
if (section_list_append_article(p_section[i], &article) < 0) |
| 771 |
{ |
{ |
| 924 |
} |
} |
| 925 |
} |
} |
| 926 |
|
|
| 927 |
|
printf("Testing #6 ...\n"); |
| 928 |
|
|
| 929 |
|
for (i = 0; i < section_count; i++) |
| 930 |
|
{ |
| 931 |
|
if (section_list_rd_lock(p_section[i]) < 0) |
| 932 |
|
{ |
| 933 |
|
printf("section_list_rd_lock(sid = %d) error\n", p_section[i]->sid); |
| 934 |
|
break; |
| 935 |
|
} |
| 936 |
|
} |
| 937 |
|
|
| 938 |
|
printf("Try rw_lock for 5 sec...\n"); |
| 939 |
|
if (section_list_try_rw_lock(NULL, 5) == 0) |
| 940 |
|
{ |
| 941 |
|
printf("section_list_try_rw_lock(sid = %d) error, expectation is timeout\n", p_section[i]->sid); |
| 942 |
|
} |
| 943 |
|
|
| 944 |
|
for (i = 0; i < section_count; i++) |
| 945 |
|
{ |
| 946 |
|
if (section_list_rd_unlock(p_section[i]) < 0) |
| 947 |
|
{ |
| 948 |
|
printf("section_list_rd_unlock(sid = %d) error\n", p_section[i]->sid); |
| 949 |
|
break; |
| 950 |
|
} |
| 951 |
|
} |
| 952 |
|
|
| 953 |
|
if (section_list_try_rw_lock(NULL, 5) < 0) |
| 954 |
|
{ |
| 955 |
|
printf("section_list_rd_lock(sid = %d) error\n", p_section[i]->sid); |
| 956 |
|
} |
| 957 |
|
|
| 958 |
|
for (i = 0; i < section_count; i++) |
| 959 |
|
{ |
| 960 |
|
if (section_list_try_rd_lock(p_section[i], 0) == 0) |
| 961 |
|
{ |
| 962 |
|
printf("section_list_try_rd_lock(sid = %d) error, expectation is timeout\n", p_section[i]->sid); |
| 963 |
|
break; |
| 964 |
|
} |
| 965 |
|
} |
| 966 |
|
|
| 967 |
|
if (section_list_rw_unlock(NULL) < 0) |
| 968 |
|
{ |
| 969 |
|
printf("section_list_rw_unlock(sid = %d) error\n", p_section[i]->sid); |
| 970 |
|
} |
| 971 |
|
|
| 972 |
printf("Press ENTER to exit..."); |
printf("Press ENTER to exit..."); |
| 973 |
getchar(); |
getchar(); |
| 974 |
|
|