/[LeafOK_CVS]/lbbs/src/test_section_list.c
ViewVC logotype

Diff of /lbbs/src/test_section_list.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.14 by sysadm, Fri May 23 07:06:57 2025 UTC Revision 1.23 by sysadm, Mon May 26 03:20:39 2025 UTC
# Line 15  Line 15 
15   ***************************************************************************/   ***************************************************************************/
16    
17  #include "section_list.h"  #include "section_list.h"
18    #include "trie_dict.h"
19  #include "bbs.h"  #include "bbs.h"
20  #include "log.h"  #include "log.h"
21  #include <stdio.h>  #include <stdio.h>
22  #include <unistd.h>  #include <unistd.h>
23  #include <errno.h>  #include <errno.h>
24    
25    #define ARTICLE_BLOCK_SHM_FILE "~article_block_shm.dat"
26    #define SECTION_LIST_SHM_FILE "~section_list_shm.dat"
27    #define TRIE_DICT_SHM_FILE "~trie_dict_shm.dat"
28    
29  const char *sname[] = {  const char *sname[] = {
30          "Test",          "Test",
31          "ABCDEFG",          "ABCDEFG",
# Line 47  int main(int argc, char *argv[]) Line 52  int main(int argc, char *argv[])
52          ARTICLE article;          ARTICLE article;
53          int block_count;          int block_count;
54          int i, j;          int i, j;
55            int sid;
56          int last_aid;          int last_aid;
57          int current_tid;          int current_tid;
58          int section_first_aid;          int section_first_aid;
# Line 56  int main(int argc, char *argv[]) Line 62  int main(int argc, char *argv[])
62          int32_t page;          int32_t page;
63          int32_t offset;          int32_t offset;
64          int affected_count;          int affected_count;
65            FILE *fp;
66    
67          if (log_begin("../log/bbsd.log", "../log/error.log") < 0)          if (log_begin("../log/bbsd.log", "../log/error.log") < 0)
68          {          {
# Line 69  int main(int argc, char *argv[]) Line 76  int main(int argc, char *argv[])
76          // - 1 to make blocks allocated is less than required, to trigger error handling          // - 1 to make blocks allocated is less than required, to trigger error handling
77          block_count = BBS_article_limit_per_section * BBS_max_section / ARTICLE_PER_BLOCK;          block_count = BBS_article_limit_per_section * BBS_max_section / ARTICLE_PER_BLOCK;
78    
79          if (article_block_init("../conf/menu.conf", block_count) < 0)          if ((fp = fopen(ARTICLE_BLOCK_SHM_FILE, "w")) == NULL)
80            {
81                    log_error("fopen(%s) error\n", ARTICLE_BLOCK_SHM_FILE);
82                    return -1;
83            }
84            fclose(fp);
85    
86            if ((fp = fopen(SECTION_LIST_SHM_FILE, "w")) == NULL)
87            {
88                    log_error("fopen(%s) error\n", SECTION_LIST_SHM_FILE);
89                    return -1;
90            }
91            fclose(fp);
92    
93            if ((fp = fopen(TRIE_DICT_SHM_FILE, "w")) == NULL)
94            {
95                    log_error("fopen(%s) error\n", TRIE_DICT_SHM_FILE);
96                    return -1;
97            }
98            fclose(fp);
99    
100            if (trie_dict_init(TRIE_DICT_SHM_FILE, TRIE_NODE_PER_POOL) < 0)
101          {          {
102                  log_error("section_data_pool_init() error\n");                  printf("trie_dict_init failed\n");
103                    return -1;
104            }
105    
106            if (article_block_init(ARTICLE_BLOCK_SHM_FILE, block_count) < 0)
107            {
108                    log_error("article_block_init(%s, %d) error\n", ARTICLE_BLOCK_SHM_FILE, block_count);
109                    return -2;
110            }
111    
112            if (section_list_init(SECTION_LIST_SHM_FILE) < 0)
113            {
114                    log_error("section_list_pool_init(%s) error\n", SECTION_LIST_SHM_FILE);
115                  return -2;                  return -2;
116          }          }
117    
# Line 79  int main(int argc, char *argv[]) Line 119  int main(int argc, char *argv[])
119    
120          last_aid = 0;          last_aid = 0;
121    
122            if (section_list_rw_lock(NULL) < 0)
123            {
124                    printf("section_list_rw_lock(sid = %d) error\n", 0);
125            }
126    
127          for (i = 0; i < section_count; i++)          for (i = 0; i < section_count; i++)
128          {          {
129                  p_section[i] = section_list_create(i + 1,                  sid = i * 3 + 1;
130                    p_section[i] = section_list_create(sid,
131                                                                                     sname[i % section_conf_count],                                                                                     sname[i % section_conf_count],
132                                                                                     stitle[i % section_conf_count],                                                                                     stitle[i % section_conf_count],
133                                                                                     master_name[i % section_conf_count]);                                                                                     master_name[i % section_conf_count]);
134                  if (p_section[i] == NULL)                  if (p_section[i] == NULL)
135                  {                  {
136                          log_error("section_data_create(i=%d) error\n", i);                          printf("section_list_create(i = %d) error\n", i);
137                            return -3;
138                    }
139    
140                    if (get_section_index(p_section[i]) != i)
141                    {
142                            printf("get_section_index(i = %d) error\n", i);
143                          return -3;                          return -3;
144                  }                  }
145          }          }
# Line 96  int main(int argc, char *argv[]) Line 148  int main(int argc, char *argv[])
148          {          {
149                  if (section_list_find_by_name(sname[i]) == NULL)                  if (section_list_find_by_name(sname[i]) == NULL)
150                  {                  {
151                          printf("section_data_find_section_by_name(%s) error\n", sname[i]);                          printf("section_list_find_by_name(%s) error\n", sname[i]);
152                          return -3;                          return -3;
153                  }                  }
154          }          }
155    
156            for (i = 0; i < section_count; i++)
157            {
158                    sid = i * 3 + 1;
159                    if (section_list_find_by_sid(sid) == NULL || section_list_find_by_sid(sid)->sid != sid)
160                    {
161                            printf("section_list_find_by_sid(%d) error\n", sid);
162                            return -3;
163                    }
164            }
165    
166            if (section_list_rw_unlock(NULL) < 0)
167            {
168                    printf("section_list_rw_unlock(sid = %d) error\n", 0);
169            }
170    
171          for (j = 0; j < BBS_article_limit_per_section; j++)          for (j = 0; j < BBS_article_limit_per_section; j++)
172          {          {
173                  for (i = 0; i < section_count; i++)                  for (i = 0; i < section_count; i++)
# Line 109  int main(int argc, char *argv[]) Line 176  int main(int argc, char *argv[])
176    
177                          // Set article data                          // Set article data
178                          article.aid = last_aid;                          article.aid = last_aid;
                         article.cid = article.aid;  
179                          article.tid = 0;                          article.tid = 0;
180                            article.sid = i * 3 + 1;
181                            article.cid = article.aid;
182                          article.uid = 1; // TODO: randomize                          article.uid = 1; // TODO: randomize
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    
188                            if (section_list_rw_lock(p_section[i]) < 0)
189                            {
190                                    printf("section_list_rw_lock(sid = %d) error\n", p_section[i]->sid);
191                                    break;
192                            }
193    
194                          if (section_list_append_article(p_section[i], &article) < 0)                          if (section_list_append_article(p_section[i], &article) < 0)
195                          {                          {
196                                  printf("append article (aid = %d) error at section %d index %d\n", article.aid, i, j);                                  printf("append article (aid = %d) error at section %d index %d\n", article.aid, i, j);
197                                  break;                                  break;
198                          }                          }
199    
200                            if (section_list_rw_unlock(p_section[i]) < 0)
201                            {
202                                    printf("section_list_rw_unlock(sid = %d) error %d\n", p_section[i]->sid, errno);
203                                    break;
204                            }
205                  }                  }
206          }          }
207    
# Line 132  int main(int argc, char *argv[]) Line 212  int main(int argc, char *argv[])
212    
213          last_aid = 0;          last_aid = 0;
214    
215          for (i = 0; i < section_count; i++)          for (j = 0; j < BBS_article_limit_per_section; j++)
216          {          {
217                  if (p_section[i]->article_count == 0)                  for (i = 0; i < section_count; i++)
                 {  
                         continue;  
                 }  
   
                 for (j = 0; j < p_section[i]->article_count; j++)  
218                  {                  {
219                          last_aid++;                          last_aid++;
220    
# Line 149  int main(int argc, char *argv[]) Line 224  int main(int argc, char *argv[])
224                                  printf("article_block_find_by_aid() at section %d index %d, %d != %d\n", i, j, p_article->aid, last_aid);                                  printf("article_block_find_by_aid() at section %d index %d, %d != %d\n", i, j, p_article->aid, last_aid);
225                          }                          }
226    
227                          p_article = article_block_find_by_index(last_aid - 1);                          if (section_list_rw_lock(p_section[i]) < 0)
                         if (p_article == NULL || p_article->aid != last_aid)  
228                          {                          {
229                                  printf("article_block_find_by_index() at section %d index %d, %d != %d\n", i, j, p_article->aid, last_aid);                                  printf("section_list_rw_lock(sid = %d) error\n", p_section[i]->sid);
230                                    break;
231                          }                          }
232    
233                          if (section_list_set_article_visible(p_section[i], p_article->aid, 0) != 1)                          if (section_list_set_article_visible(p_section[i], p_article->aid, 0) != 1)
234                          {                          {
235                                  printf("section_list_set_article_visible(aid = %d) error\n", p_article->aid);                                  printf("section_list_set_article_visible(aid = %d) error\n", p_article->aid);
236                          }                          }
237    
238                            if (section_list_rw_unlock(p_section[i]) < 0)
239                            {
240                                    printf("section_list_rw_unlock(sid = %d) error\n", p_section[i]->sid);
241                                    break;
242                            }
243                  }                  }
244    
245                  // printf("Verified %d articles in section %d\n", p_section[i]->article_count, i);                  // printf("Verified %d articles in section %d\n", p_section[i]->article_count, i);
# Line 166  int main(int argc, char *argv[]) Line 247  int main(int argc, char *argv[])
247    
248          printf("Testing #2 ...\n");          printf("Testing #2 ...\n");
249    
250            if (section_list_rw_lock(NULL) < 0)
251            {
252                    printf("section_list_rw_lock(sid = %d) error\n", 0);
253            }
254    
255          if (article_block_reset() != 0)          if (article_block_reset() != 0)
256          {          {
257                  log_error("section_data_free_block(i=%d) error\n", i);                  log_error("article_block_reset() error\n");
258                  return -4;                  return -4;
259          }          }
260    
# Line 177  int main(int argc, char *argv[]) Line 263  int main(int argc, char *argv[])
263                  section_list_reset_articles(p_section[i]);                  section_list_reset_articles(p_section[i]);
264          }          }
265    
266            if (section_list_rw_unlock(NULL) < 0)
267            {
268                    printf("section_list_rw_unlock(sid = %d) error\n", 0);
269            }
270    
271          last_aid = 0;          last_aid = 0;
272    
273          for (i = 0; i < section_count; i++)          for (i = 0; i < section_count; i++)
274          {          {
275                  section_first_aid = last_aid + 1;                  section_first_aid = last_aid + 1;
276    
277                    if (section_list_rw_lock(p_section[i]) < 0)
278                    {
279                            printf("section_list_rw_lock(sid = %d) error\n", p_section[i]->sid);
280                            break;
281                    }
282    
283                  for (j = 0; j < BBS_article_limit_per_section; j++)                  for (j = 0; j < BBS_article_limit_per_section; j++)
284                  {                  {
285                          last_aid++;                          last_aid++;
286    
287                          // Set article data                          // Set article data
288                          article.aid = last_aid;                          article.aid = last_aid;
                         article.cid = article.aid;  
289                          // Group articles into group_count topics                          // Group articles into group_count topics
290                          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));
291                            article.sid = i * 3 + 1;
292                            article.cid = article.aid;
293                          article.uid = 1; // TODO: randomize                          article.uid = 1; // TODO: randomize
294                          article.visible = 1;                          article.visible = 1;
295                          article.excerption = 0;                          article.excerption = 0;
# Line 205  int main(int argc, char *argv[]) Line 303  int main(int argc, char *argv[])
303                          }                          }
304                  }                  }
305    
306                    if (section_list_rw_unlock(p_section[i]) < 0)
307                    {
308                            printf("section_list_rw_unlock(sid = %d) error\n", p_section[i]->sid);
309                            break;
310                    }
311    
312                  // 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);
313          }          }
314    
# Line 218  int main(int argc, char *argv[]) Line 322  int main(int argc, char *argv[])
322                  article_count = 0;                  article_count = 0;
323                  last_aid = 0;                  last_aid = 0;
324    
325                    if (section_list_rd_lock(p_section[i]) < 0)
326                    {
327                            printf("section_list_rd_lock(sid = %d) error\n", p_section[i]->sid);
328                            break;
329                    }
330    
331                  p_article = p_section[i]->p_article_head;                  p_article = p_section[i]->p_article_head;
332    
333                  do                  do
# Line 240  int main(int argc, char *argv[]) Line 350  int main(int argc, char *argv[])
350                          break;                          break;
351                  }                  }
352    
353                    if (section_list_rd_unlock(p_section[i]) < 0)
354                    {
355                            printf("section_list_rd_unlock(sid = %d) error\n", p_section[i]->sid);
356                            break;
357                    }
358    
359                  // printf("Verified %d articles in section %d\n", group_count, i);                  // printf("Verified %d articles in section %d\n", group_count, i);
360          }          }
361    
# Line 250  int main(int argc, char *argv[]) Line 366  int main(int argc, char *argv[])
366                          continue;                          continue;
367                  }                  }
368    
369                    if (section_list_rd_lock(p_section[i]) < 0)
370                    {
371                            printf("section_list_rd_lock(sid = %d) error\n", p_section[i]->sid);
372                            break;
373                    }
374    
375                  if (p_section[i]->topic_count != group_count)                  if (p_section[i]->topic_count != group_count)
376                  {                  {
377                          printf("Inconsistent topic count in section %d, %d != %d\n", i, p_section[i]->topic_count, group_count);                          printf("Inconsistent topic count in section %d, %d != %d\n", i, p_section[i]->topic_count, group_count);
# Line 307  int main(int argc, char *argv[]) Line 429  int main(int argc, char *argv[])
429                          {                          {
430                                  printf("Count of articles in topic %d is different from expected %d != %d\n",                                  printf("Count of articles in topic %d is different from expected %d != %d\n",
431                                             j + 1, article_count, p_section[i]->article_count / group_count);                                             j + 1, article_count, p_section[i]->article_count / group_count);
432                                  break;                                  // break;
433                          }                          }
434                  }                  }
435    
436                    if (section_list_rd_unlock(p_section[i]) < 0)
437                    {
438                            printf("section_list_rd_unlock(sid = %d) error\n", p_section[i]->sid);
439                            break;
440                    }
441    
442                  // printf("Verified %d topics in section %d\n", group_count, i);                  // printf("Verified %d topics in section %d\n", group_count, i);
443          }          }
444    
# Line 320  int main(int argc, char *argv[]) Line 448  int main(int argc, char *argv[])
448          {          {
449                  last_aid = 0;                  last_aid = 0;
450    
451                    if (section_list_rd_lock(p_section[i]) < 0)
452                    {
453                            printf("section_list_rd_lock(sid = %d) error\n", p_section[i]->sid);
454                            break;
455                    }
456    
457                  for (j = 0; j < p_section[i]->page_count; j++)                  for (j = 0; j < p_section[i]->page_count; j++)
458                  {                  {
459                          if (p_section[i]->p_page_first_article[j]->aid <= last_aid)                          if (p_section[i]->p_page_first_article[j]->aid <= last_aid)
# Line 344  int main(int argc, char *argv[]) Line 478  int main(int argc, char *argv[])
478                                  }                                  }
479                          }                          }
480                  }                  }
481    
482                    if (section_list_rd_unlock(p_section[i]) < 0)
483                    {
484                            printf("section_list_rd_unlock(sid = %d) error\n", p_section[i]->sid);
485                            break;
486                    }
487          }          }
488    
489          printf("Testing #4 ...\n");          printf("Testing #4 ...\n");
490    
491          for (i = 0; i < section_count; i++)          for (i = 0; i < section_count; i++)
492          {          {
493                    if (section_list_rw_lock(p_section[i]) < 0)
494                    {
495                            printf("section_list_rw_lock(sid = %d) error\n", p_section[i]->sid);
496                            break;
497                    }
498    
499                  step = i % 10 + 1;                  step = i % 10 + 1;
500                  for (j = group_count; j < BBS_article_limit_per_section; j += step)                  for (j = group_count; j < BBS_article_limit_per_section; j += step)
501                  {                  {
# Line 479  int main(int argc, char *argv[]) Line 625  int main(int argc, char *argv[])
625                                     p_section[i]->last_page_visible_article_count);                                     p_section[i]->last_page_visible_article_count);
626                          break;                          break;
627                  }                  }
628    
629                    if (section_list_rw_unlock(p_section[i]) < 0)
630                    {
631                            printf("section_list_rw_unlock(sid = %d) error\n", p_section[i]->sid);
632                            break;
633                    }
634          }          }
635    
636          for (i = 0; i < BBS_max_section; i++)          for (i = 0; i < BBS_max_section; i++)
637          {          {
638                    if (section_list_rw_lock(p_section[i]) < 0)
639                    {
640                            printf("section_list_rw_lock(sid = %d) error\n", p_section[i]->sid);
641                            break;
642                    }
643    
644                  affected_count = 0;                  affected_count = 0;
645    
646                  for (j = 0; j < BBS_article_limit_per_section; j += 1)                  for (j = 0; j < BBS_article_limit_per_section; j += 1)
# Line 536  int main(int argc, char *argv[]) Line 694  int main(int argc, char *argv[])
694                                     p_section[i]->last_page_visible_article_count);                                     p_section[i]->last_page_visible_article_count);
695                          break;                          break;
696                  }                  }
697    
698                    if (section_list_rw_unlock(p_section[i]) < 0)
699                    {
700                            printf("section_list_rw_unlock(sid = %d) error\n", p_section[i]->sid);
701                            break;
702                    }
703          }          }
704    
705          printf("Testing #5 ...\n");          printf("Testing #5 ...\n");
706    
707            if (section_list_rw_lock(NULL) < 0)
708            {
709                    printf("section_list_rw_lock(sid = %d) error\n", 0);
710            }
711    
712          if (article_block_reset() != 0)          if (article_block_reset() != 0)
713          {          {
714                  log_error("section_data_free_block(i=%d) error\n", i);                  log_error("article_block_reset() error\n");
715                  return -4;                  return -4;
716          }          }
717    
# Line 551  int main(int argc, char *argv[]) Line 720  int main(int argc, char *argv[])
720                  section_list_reset_articles(p_section[i]);                  section_list_reset_articles(p_section[i]);
721          }          }
722    
723            if (section_list_rw_unlock(NULL) < 0)
724            {
725                    printf("section_list_rw_unlock(sid = %d) error\n", 0);
726            }
727    
728          last_aid = 0;          last_aid = 0;
729    
730          for (i = 0; i < section_count / 2; i++)          for (i = 0; i < section_count / 2; i++)
731          {          {
732                    if (section_list_rw_lock(p_section[i]) < 0)
733                    {
734                            printf("section_list_rw_lock(sid = %d) error\n", p_section[i]->sid);
735                            break;
736                    }
737    
738                  section_first_aid = last_aid + 1;                  section_first_aid = last_aid + 1;
739    
740                  for (j = 0; j < BBS_article_limit_per_section; j++)                  for (j = 0; j < BBS_article_limit_per_section; j++)
# Line 563  int main(int argc, char *argv[]) Line 743  int main(int argc, char *argv[])
743    
744                          // Set article data                          // Set article data
745                          article.aid = last_aid;                          article.aid = last_aid;
                         article.cid = article.aid;  
746                          // Group articles into group_count topics                          // Group articles into group_count topics
747                          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));
748                            article.sid = i * 3 + 1;
749                            article.cid = article.aid;
750                          article.uid = 1; // TODO: randomize                          article.uid = 1; // TODO: randomize
751                          article.visible = 1;                          article.visible = 1;
752                          article.excerption = 0;                          article.excerption = 0;
# Line 579  int main(int argc, char *argv[]) Line 760  int main(int argc, char *argv[])
760                          }                          }
761                  }                  }
762    
763                    if (section_list_rw_unlock(p_section[i]) < 0)
764                    {
765                            printf("section_list_rw_unlock(sid = %d) error\n", p_section[i]->sid);
766                            break;
767                    }
768    
769                  // 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);
770          }          }
771    
772          for (i = 0; i < section_count / 2; i++)          for (i = 0; i < section_count / 2; i++)
773          {          {
774                    if (section_list_rw_lock(p_section[i]) < 0)
775                    {
776                            printf("section_list_rw_lock(sid = %d) error\n", p_section[i]->sid);
777                            break;
778                    }
779    
780                  section_first_aid = p_section[i]->p_article_head->aid;                  section_first_aid = p_section[i]->p_article_head->aid;
781    
782                  for (j = 0; j < group_count; j++)                  for (j = 0; j < group_count; j += 2)
783                  {                  {
784                          p_article = section_list_find_article_with_offset(p_section[i], section_first_aid + j, &page, &offset, &p_next);                          p_article = section_list_find_article_with_offset(p_section[i], section_first_aid + j, &page, &offset, &p_next);
785                          if (p_article == NULL)                          if (p_article == NULL)
# Line 595  int main(int argc, char *argv[]) Line 788  int main(int argc, char *argv[])
788                                             section_first_aid + j, i);                                             section_first_aid + j, i);
789                                  break;                                  break;
790                          }                          }
791    
792                            if (section_list_set_article_visible(p_section[i], p_article->aid, 0) != BBS_article_limit_per_section / group_count)
793                            {
794                                    printf("section_list_set_article_visible(aid = %d) error\n", p_article->aid);
795                            }
796                    }
797    
798                    if (section_list_rw_unlock(p_section[i]) < 0)
799                    {
800                            printf("section_list_rw_unlock(sid = %d) error\n", p_section[i]->sid);
801                            break;
802                  }                  }
803          }          }
804    
805          for (i = 0; i < section_count / 2; i++)          for (i = 0; i < section_count / 2; i++)
806          {          {
807                    if (section_list_rw_lock(p_section[i]) < 0)
808                    {
809                            printf("section_list_rw_lock(sid = %d) error\n", p_section[i]->sid);
810                            break;
811                    }
812    
813                    if (section_list_rw_lock(p_section[section_count / 2 + i]) < 0)
814                    {
815                            printf("section_list_rw_lock(sid = %d) error\n", p_section[section_count / 2 + i]->sid);
816    
817                            if (section_list_rw_unlock(p_section[i]) < 0)
818                            {
819                                    printf("section_list_rw_unlock(sid = %d) error\n", p_section[i]->sid);
820                            }
821                            break;
822                    }
823    
824                  section_first_aid = p_section[i]->p_article_head->aid;                  section_first_aid = p_section[i]->p_article_head->aid;
825    
826                  for (j = 0; j < group_count; j++)                  for (j = 0; j < group_count; j++)
# Line 617  int main(int argc, char *argv[]) Line 838  int main(int argc, char *argv[])
838                                  printf("move topic (aid = %d) affected article count %d != %d\n",                                  printf("move topic (aid = %d) affected article count %d != %d\n",
839                                             section_first_aid + j, affected_count,                                             section_first_aid + j, affected_count,
840                                             BBS_article_limit_per_section / group_count);                                             BBS_article_limit_per_section / group_count);
841                                  break;                                  // break;
842                          }                          }
843                  }                  }
844    
845                    if (section_list_rw_unlock(p_section[i]) < 0)
846                    {
847                            printf("section_list_rw_unlock(sid = %d) error\n", p_section[i]->sid);
848                            break;
849                    }
850    
851                    if (section_list_rw_unlock(p_section[section_count / 2 + i]) < 0)
852                    {
853                            printf("section_list_rw_unlock(sid = %d) error\n", p_section[section_count / 2 + i]->sid);
854    
855                            if (section_list_rw_unlock(p_section[i]) < 0)
856                            {
857                                    printf("section_list_rw_unlock(sid = %d) error\n", p_section[i]->sid);
858                            }
859                            break;
860                    }
861          }          }
862    
863          for (i = 0; i < section_count; i++)          for (i = 0; i < section_count; i++)
864          {          {
865                    if (section_list_rd_lock(p_section[i]) < 0)
866                    {
867                            printf("section_list_rd_lock(sid = %d) error\n", p_section[i]->sid);
868                            break;
869                    }
870    
871                  if (p_section[i]->topic_count != (i < section_count / 2 ? 0 : group_count))                  if (p_section[i]->topic_count != (i < section_count / 2 ? 0 : group_count))
872                  {                  {
873                          printf("Topic count error in section %d, %d != %d\n", i,                          printf("Topic count error in section %d, %d != %d\n", i,
# Line 631  int main(int argc, char *argv[]) Line 875  int main(int argc, char *argv[])
875                          break;                          break;
876                  }                  }
877    
878                    if (p_section[i]->visible_topic_count != (i < section_count / 2 ? 0 : group_count / 2))
879                    {
880                            printf("Visible topic count error in section %d, %d != %d\n", i,
881                                       p_section[i]->visible_topic_count, (i < section_count / 2 ? 0 : group_count / 2));
882                            break;
883                    }
884    
885                  if (p_section[i]->article_count != (i < section_count / 2 ? 0 : BBS_article_limit_per_section))                  if (p_section[i]->article_count != (i < section_count / 2 ? 0 : BBS_article_limit_per_section))
886                  {                  {
887                          printf("Article count error in section %d, %d != %d\n", i,                          printf("Article count error in section %d, %d != %d\n", i,
# Line 638  int main(int argc, char *argv[]) Line 889  int main(int argc, char *argv[])
889                          break;                          break;
890                  }                  }
891    
892                  if (p_section[i]->page_count != (i < section_count / 2 ? 0 : BBS_article_limit_per_section / BBS_article_limit_per_page))                  if (p_section[i]->visible_article_count != (i < section_count / 2 ? 0 : BBS_article_limit_per_section / 2))
893                    {
894                            printf("Visible article count error in section %d, %d != %d\n", i,
895                                       p_section[i]->visible_article_count, (i < section_count / 2 ? 0 : BBS_article_limit_per_section / 2));
896                            break;
897                    }
898    
899                    if (p_section[i]->page_count != (i < section_count / 2 ? 0 : BBS_article_limit_per_section / 2 / BBS_article_limit_per_page))
900                  {                  {
901                          printf("Page count error in section %d, %d != %d\n", i,                          printf("Page count error in section %d, %d != %d\n", i,
902                                     p_section[i]->page_count, (i < section_count / 2 ? 0 : BBS_article_limit_per_section / BBS_article_limit_per_page));                                     p_section[i]->page_count, (i < section_count / 2 ? 0 : BBS_article_limit_per_section / 2 / BBS_article_limit_per_page));
903                            break;
904                    }
905    
906                    if (section_list_rd_unlock(p_section[i]) < 0)
907                    {
908                            printf("section_list_rd_unlock(sid = %d) error\n", p_section[i]->sid);
909                          break;                          break;
910                  }                  }
911          }          }
# Line 649  int main(int argc, char *argv[]) Line 913  int main(int argc, char *argv[])
913          printf("Press ENTER to exit...");          printf("Press ENTER to exit...");
914          getchar();          getchar();
915    
916            section_list_cleanup();
917          article_block_cleanup();          article_block_cleanup();
918            trie_dict_cleanup();
919    
920            if (unlink(TRIE_DICT_SHM_FILE) < 0)
921            {
922                    log_error("unlink(%s) error\n", TRIE_DICT_SHM_FILE);
923                    return -1;
924            }
925    
926            if (unlink(ARTICLE_BLOCK_SHM_FILE) < 0)
927            {
928                    log_error("unlink(%s) error\n", ARTICLE_BLOCK_SHM_FILE);
929                    return -1;
930            }
931    
932            if (unlink(SECTION_LIST_SHM_FILE) < 0)
933            {
934                    log_error("unlink(%s) error\n", SECTION_LIST_SHM_FILE);
935                    return -1;
936            }
937    
938          log_end();          log_end();
939    


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1