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

Diff of /lbbs/src/section_list.c

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

Revision 1.23 by sysadm, Mon May 26 03:20:39 2025 UTC Revision 1.36 by sysadm, Tue Jun 24 10:01:24 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
 #define _GNU_SOURCE  
   
 #include "section_list.h"  
17  #include "log.h"  #include "log.h"
18    #include "section_list.h"
19  #include "trie_dict.h"  #include "trie_dict.h"
20    #include <errno.h>
21    #include <signal.h>
22  #include <stdio.h>  #include <stdio.h>
23    #include <stdlib.h>
24  #include <string.h>  #include <string.h>
 #include <signal.h>  
25  #include <unistd.h>  #include <unistd.h>
26  #include <stdlib.h>  #include <sys/ipc.h>
 #include <errno.h>  
27  #include <sys/param.h>  #include <sys/param.h>
28  #include <sys/sem.h>  #include <sys/sem.h>
29  #include <sys/shm.h>  #include <sys/shm.h>
 #include <sys/ipc.h>  
30    
31  #ifdef _SEM_SEMUN_UNDEFINED  #ifdef _SEM_SEMUN_UNDEFINED
32  union semun  union semun
# Line 44  union semun Line 42  union semun
42  #define SECTION_TRY_LOCK_WAIT_TIME 1 // second  #define SECTION_TRY_LOCK_WAIT_TIME 1 // second
43  #define SECTION_TRY_LOCK_TIMES 10  #define SECTION_TRY_LOCK_TIMES 10
44    
45  #define ARTICLE_BLOCK_PER_SHM 400                 // sizeof(ARTICLE_BLOCK) * ARTICLE_BLOCK_PER_SHM is the size of each shm segment to allocate  #define ARTICLE_BLOCK_PER_SHM 1000               // sizeof(ARTICLE_BLOCK) * ARTICLE_BLOCK_PER_SHM is the size of each shm segment to allocate
46  #define ARTICLE_BLOCK_SHM_COUNT_LIMIT 200 // limited by length (8-bit) of proj_id in ftok(path, proj_id)  #define ARTICLE_BLOCK_SHM_COUNT_LIMIT 80 // limited by length (8-bit) of proj_id in ftok(path, proj_id)
47  #define ARTICLE_BLOCK_PER_POOL (ARTICLE_BLOCK_PER_SHM * ARTICLE_BLOCK_SHM_COUNT_LIMIT)  #define ARTICLE_BLOCK_PER_POOL (ARTICLE_BLOCK_PER_SHM * ARTICLE_BLOCK_SHM_COUNT_LIMIT)
48    
49  #define CALCULATE_PAGE_THRESHOLD 100 // Adjust to tune performance of move topic  #define CALCULATE_PAGE_THRESHOLD 100 // Adjust to tune performance of moving topic between sections
50    
51  #define SID_STR_LEN 5 // 32-bit + NULL  #define SID_STR_LEN 5 // 32-bit + NULL
52    
# Line 108  int article_block_init(const char *filen Line 106  int article_block_init(const char *filen
106                  return -1;                  return -1;
107          }          }
108    
109          if (block_count > ARTICLE_BLOCK_PER_POOL)          if (block_count <= 0 || block_count > ARTICLE_BLOCK_PER_POOL)
110          {          {
111                  log_error("article_block_count exceed limit %d\n", ARTICLE_BLOCK_PER_POOL);                  log_error("article_block_count exceed limit %d\n", ARTICLE_BLOCK_PER_POOL);
112                  return -2;                  return -2;
# Line 236  void article_block_cleanup(void) Line 234  void article_block_cleanup(void)
234          p_article_block_pool = NULL;          p_article_block_pool = NULL;
235  }  }
236    
237    int set_article_block_shm_readonly(void)
238    {
239            int shmid;
240            void *p_shm;
241            int i;
242    
243            if (p_article_block_pool == NULL)
244            {
245                    log_error("article_block_pool not initialized\n");
246                    return -1;
247            }
248    
249            for (i = 0; i < p_article_block_pool->shm_count; i++)
250            {
251                    shmid = (p_article_block_pool->shm_pool + i)->shmid;
252    
253                    // Remap shared memory in read-only mode
254                    p_shm = shmat(shmid, (p_article_block_pool->shm_pool + i)->p_shm, SHM_RDONLY | SHM_REMAP);
255                    if (p_shm == (void *)-1)
256                    {
257                            log_error("shmat(article_block_pool shmid = %d) error (%d)\n", shmid, errno);
258                            return -2;
259                    }
260            }
261    
262            return 0;
263    }
264    
265    int detach_article_block_shm(void)
266    {
267            int shmid;
268    
269            if (p_article_block_pool == NULL)
270            {
271                    return -1;
272            }
273    
274            for (int i = 0; i < p_article_block_pool->shm_count; i++)
275            {
276                    if ((p_article_block_pool->shm_pool + i)->p_shm != NULL && shmdt((p_article_block_pool->shm_pool + i)->p_shm) == -1)
277                    {
278                            log_error("shmdt(shmid = %d) error (%d)\n", (p_article_block_pool->shm_pool + i)->shmid, errno);
279                            return -2;
280                    }
281            }
282    
283            shmid = p_article_block_pool->shmid;
284    
285            if (shmdt(p_article_block_pool) == -1)
286            {
287                    log_error("shmdt(shmid = %d) error (%d)\n", shmid, errno);
288                    return -3;
289            }
290    
291            p_article_block_pool = NULL;
292    
293            return 0;
294    }
295    
296  inline static ARTICLE_BLOCK *pop_free_article_block(void)  inline static ARTICLE_BLOCK *pop_free_article_block(void)
297  {  {
298          ARTICLE_BLOCK *p_block = NULL;          ARTICLE_BLOCK *p_block = NULL;
# Line 340  ARTICLE *article_block_find_by_aid(int32 Line 397  ARTICLE *article_block_find_by_aid(int32
397                  }                  }
398          }          }
399    
400          return (p_block->articles + left);          if (aid != p_block->articles[left].aid) // not found
401            {
402                    return NULL;
403            }
404    
405            return (p_block->articles + left); // found
406  }  }
407    
408  ARTICLE *article_block_find_by_index(int index)  ARTICLE *article_block_find_by_index(int index)
# Line 452  extern int section_list_init(const char Line 514  extern int section_list_init(const char
514          return 0;          return 0;
515  }  }
516    
517    void section_list_cleanup(void)
518    {
519            int shmid;
520    
521            if (p_section_list_pool == NULL)
522            {
523                    return;
524            }
525    
526            if (p_section_list_pool->p_trie_dict_section_by_name != NULL)
527            {
528                    trie_dict_destroy(p_section_list_pool->p_trie_dict_section_by_name);
529                    p_section_list_pool->p_trie_dict_section_by_name = NULL;
530            }
531    
532            if (p_section_list_pool->p_trie_dict_section_by_sid != NULL)
533            {
534                    trie_dict_destroy(p_section_list_pool->p_trie_dict_section_by_sid);
535                    p_section_list_pool->p_trie_dict_section_by_sid = NULL;
536            }
537    
538            shmid = p_section_list_pool->shmid;
539    
540            if (semctl(p_section_list_pool->semid, 0, IPC_RMID) == -1)
541            {
542                    log_error("semctl(semid = %d, IPC_RMID) error (%d)\n", p_section_list_pool->semid, errno);
543            }
544    
545            if (shmdt(p_section_list_pool) == -1)
546            {
547                    log_error("shmdt(shmid = %d) error (%d)\n", shmid, errno);
548            }
549    
550            if (shmctl(shmid, IPC_RMID, NULL) == -1)
551            {
552                    log_error("shmctl(shmid = %d, IPC_RMID) error (%d)\n", shmid, errno);
553            }
554    
555            p_section_list_pool = NULL;
556    }
557    
558    void section_list_ex_menu_set_cleanup(void)
559    {
560            int i;
561    
562            for (i = 0; i < p_section_list_pool->section_count; i++)
563            {
564                    if (p_section_list_pool->sections[i].ex_menu_tm > 0)
565                    {
566                            unload_menu(&(p_section_list_pool->sections[i].ex_menu_set));
567                    }
568            }
569    }
570    
571    int set_section_list_shm_readonly(void)
572    {
573            int shmid;
574            void *p_shm;
575    
576            if (p_section_list_pool == NULL)
577            {
578                    log_error("p_section_list_pool not initialized\n");
579                    return -1;
580            }
581    
582            shmid = p_section_list_pool->shmid;
583    
584            // Remap shared memory in read-only mode
585            p_shm = shmat(shmid, p_section_list_pool, SHM_RDONLY | SHM_REMAP);
586            if (p_shm == (void *)-1)
587            {
588                    log_error("shmat(section_list_pool shmid = %d) error (%d)\n", shmid, errno);
589                    return -3;
590            }
591    
592            p_section_list_pool = p_shm;
593    
594            return 0;
595    }
596    
597    int detach_section_list_shm(void)
598    {
599            if (p_section_list_pool != NULL && shmdt(p_section_list_pool) == -1)
600            {
601                    log_error("shmdt(section_list_pool) error (%d)\n", errno);
602                    return -1;
603            }
604    
605            p_section_list_pool = NULL;
606    
607            return 0;
608    }
609    
610  inline static void sid_to_str(int32_t sid, char *p_sid_str)  inline static void sid_to_str(int32_t sid, char *p_sid_str)
611  {  {
612          uint32_t u_sid;          uint32_t u_sid;
# Line 466  inline static void sid_to_str(int32_t si Line 621  inline static void sid_to_str(int32_t si
621          p_sid_str[i] = '\0';          p_sid_str[i] = '\0';
622  }  }
623    
624  SECTION_LIST *section_list_create(int32_t sid, const char *sname, const char *stitle, const char *master_name)  SECTION_LIST *section_list_create(int32_t sid, const char *sname, const char *stitle, const char *master_list)
625  {  {
626          SECTION_LIST *p_section;          SECTION_LIST *p_section;
627          char sid_str[SID_STR_LEN];          char sid_str[SID_STR_LEN];
# Line 488  SECTION_LIST *section_list_create(int32_ Line 643  SECTION_LIST *section_list_create(int32_
643          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;
644    
645          p_section->sid = sid;          p_section->sid = sid;
646            p_section->ex_menu_tm = 0;
647    
648          strncpy(p_section->sname, sname, sizeof(p_section->sname - 1));          strncpy(p_section->sname, sname, sizeof(p_section->sname) - 1);
649          p_section->sname[sizeof(p_section->sname - 1)] = '\0';          p_section->sname[sizeof(p_section->sname) - 1] = '\0';
650    
651          strncpy(p_section->stitle, stitle, sizeof(p_section->stitle - 1));          strncpy(p_section->stitle, stitle, sizeof(p_section->stitle) - 1);
652          p_section->stitle[sizeof(p_section->stitle - 1)] = '\0';          p_section->stitle[sizeof(p_section->stitle) - 1] = '\0';
653    
654          strncpy(p_section->master_name, master_name, sizeof(p_section->master_name - 1));          strncpy(p_section->master_list, master_list, sizeof(p_section->master_list) - 1);
655          p_section->master_name[sizeof(p_section->master_name - 1)] = '\0';          p_section->master_list[sizeof(p_section->master_list) - 1] = '\0';
656    
657          if (trie_dict_set(p_section_list_pool->p_trie_dict_section_by_name, sname, p_section_list_pool->section_count) != 1)          if (trie_dict_set(p_section_list_pool->p_trie_dict_section_by_name, sname, p_section_list_pool->section_count) != 1)
658          {          {
# Line 528  void section_list_reset_articles(SECTION Line 684  void section_list_reset_articles(SECTION
684    
685          p_section->page_count = 0;          p_section->page_count = 0;
686          p_section->last_page_visible_article_count = 0;          p_section->last_page_visible_article_count = 0;
 }  
   
 void section_list_cleanup(void)  
 {  
         int shmid;  
   
         if (p_section_list_pool == NULL)  
         {  
                 return;  
         }  
   
         if (p_section_list_pool->p_trie_dict_section_by_name != NULL)  
         {  
                 trie_dict_destroy(p_section_list_pool->p_trie_dict_section_by_name);  
                 p_section_list_pool->p_trie_dict_section_by_name = NULL;  
         }  
   
         if (p_section_list_pool->p_trie_dict_section_by_sid != NULL)  
         {  
                 trie_dict_destroy(p_section_list_pool->p_trie_dict_section_by_sid);  
                 p_section_list_pool->p_trie_dict_section_by_sid = NULL;  
         }  
   
         if (p_section_list_pool != NULL)  
         {  
                 if (semctl(p_section_list_pool->semid, 0, IPC_RMID) == -1)  
                 {  
                         log_error("semctl(semid = %d, IPC_RMID) error (%d)\n", p_section_list_pool->semid, errno);  
                 }  
   
                 shmid = p_section_list_pool->shmid;  
   
                 if (shmdt(p_section_list_pool) == -1)  
                 {  
                         log_error("shmdt(shmid = %d) error (%d)\n", shmid, errno);  
                 }  
687    
688                  if (shmctl(shmid, IPC_RMID, NULL) == -1)          p_section->ontop_article_count = 0;
                 {  
                         log_error("shmctl(shmid = %d, IPC_RMID) error (%d)\n", shmid, errno);  
                 }  
   
                 p_section_list_pool = NULL;  
         }  
689  }  }
690    
691  SECTION_LIST *section_list_find_by_name(const char *sname)  SECTION_LIST *section_list_find_by_name(const char *sname)
692  {  {
693          int64_t index;          int64_t index;
694            int ret;
695    
696          if (p_section_list_pool == NULL)          if (p_section_list_pool == NULL)
697          {          {
# Line 584  SECTION_LIST *section_list_find_by_name( Line 699  SECTION_LIST *section_list_find_by_name(
699                  return NULL;                  return NULL;
700          }          }
701    
702          if (trie_dict_get(p_section_list_pool->p_trie_dict_section_by_name, sname, &index) != 1)          ret = trie_dict_get(p_section_list_pool->p_trie_dict_section_by_name, sname, &index);
703            if (ret < 0)
704          {          {
705                  log_error("trie_dict_get(section, %s) error\n", sname);                  log_error("trie_dict_get(section, %s) error\n", sname);
706                  return NULL;                  return NULL;
707          }          }
708            else if (ret == 0)
709            {
710                    return NULL;
711            }
712    
713          return (p_section_list_pool->sections + index);          return (p_section_list_pool->sections + index);
714  }  }
# Line 596  SECTION_LIST *section_list_find_by_name( Line 716  SECTION_LIST *section_list_find_by_name(
716  SECTION_LIST *section_list_find_by_sid(int32_t sid)  SECTION_LIST *section_list_find_by_sid(int32_t sid)
717  {  {
718          int64_t index;          int64_t index;
719            int ret;
720          char sid_str[SID_STR_LEN];          char sid_str[SID_STR_LEN];
721    
722          if (p_section_list_pool == NULL)          if (p_section_list_pool == NULL)
# Line 606  SECTION_LIST *section_list_find_by_sid(i Line 727  SECTION_LIST *section_list_find_by_sid(i
727    
728          sid_to_str(sid, sid_str);          sid_to_str(sid, sid_str);
729    
730          if (trie_dict_get(p_section_list_pool->p_trie_dict_section_by_sid, sid_str, &index) != 1)          ret = trie_dict_get(p_section_list_pool->p_trie_dict_section_by_sid, sid_str, &index);
731            if (ret < 0)
732          {          {
733                  log_error("trie_dict_get(section, %d) error\n", sid);                  log_error("trie_dict_get(section, %d) error\n", sid);
734                  return NULL;                  return NULL;
735          }          }
736            else if (ret == 0)
737            {
738                    return NULL;
739            }
740    
741          return (p_section_list_pool->sections + index);          return (p_section_list_pool->sections + index);
742  }  }
# Line 750  int section_list_append_article(SECTION_ Line 876  int section_list_append_article(SECTION_
876                  p_section->last_page_visible_article_count++;                  p_section->last_page_visible_article_count++;
877          }          }
878    
879            if (p_article->ontop && section_list_update_article_ontop(p_section, p_article) < 0)
880            {
881                    log_error("section_list_update_article_ontop(sid=%d, aid=%d) error\n",
882                                      p_section->sid, p_article->aid);
883                    return -5;
884            }
885    
886          return 0;          return 0;
887  }  }
888    
# Line 761  int section_list_set_article_visible(SEC Line 894  int section_list_set_article_visible(SEC
894    
895          if (p_section == NULL)          if (p_section == NULL)
896          {          {
897                  log_error("section_list_set_article_visible() NULL pointer error\n");                  log_error("NULL pointer error\n");
898                  return -2;                  return -1;
899          }          }
900    
901          p_article = article_block_find_by_aid(aid);          p_article = article_block_find_by_aid(aid);
# Line 773  int section_list_set_article_visible(SEC Line 906  int section_list_set_article_visible(SEC
906    
907          if (p_section->sid != p_article->sid)          if (p_section->sid != p_article->sid)
908          {          {
909                  log_error("section_list_set_article_visible() error: section sid %d != article sid %d\n", p_section->sid, p_article->sid);                  log_error("Inconsistent section sid %d != article sid %d\n", p_section->sid, p_article->sid);
910                  return -2;                  return -2;
911          }          }
912    
# Line 824  int section_list_set_article_visible(SEC Line 957  int section_list_set_article_visible(SEC
957          return affected_count;          return affected_count;
958  }  }
959    
960    int section_list_update_article_ontop(SECTION_LIST *p_section, ARTICLE *p_article)
961    {
962            int i;
963    
964            if (p_section == NULL || p_article == NULL)
965            {
966                    log_error("NULL pointer error\n");
967                    return -1;
968            }
969    
970            if (p_section->sid != p_article->sid)
971            {
972                    log_error("Inconsistent section sid %d != article sid %d\n", p_section->sid, p_article->sid);
973                    return -2;
974            }
975    
976            if (p_article->ontop)
977            {
978                    for (i = 0; i < p_section->ontop_article_count; i++)
979                    {
980                            if (p_section->p_ontop_articles[i]->aid == p_article->aid)
981                            {
982                                    log_error("Inconsistent state found: article %d already ontop in section %d\n", p_article->aid, p_section->sid);
983                                    return 0;
984                            }
985                            else if (p_section->p_ontop_articles[i]->aid > p_article->aid)
986                            {
987                                    break;
988                            }
989                    }
990    
991                    // Remove the oldest one if the array of ontop articles is full
992                    if (p_section->ontop_article_count >= BBS_ontop_article_limit_per_section)
993                    {
994                            if (i == 0) // p_article is the oldest one
995                            {
996                                    return 0;
997                            }
998                            memmove((void *)(p_section->p_ontop_articles),
999                                            (void *)(p_section->p_ontop_articles + 1),
1000                                            sizeof(ARTICLE *) * (size_t)(i - 1));
1001                            p_section->ontop_article_count--;
1002                            i--;
1003                    }
1004                    else
1005                    {
1006                            memmove((void *)(p_section->p_ontop_articles + i + 1),
1007                                            (void *)(p_section->p_ontop_articles + i),
1008                                            sizeof(ARTICLE *) * (size_t)(p_section->ontop_article_count - i));
1009                    }
1010    
1011                    p_section->p_ontop_articles[i] = p_article;
1012                    p_section->ontop_article_count++;
1013    
1014                    // TODO: debug
1015            }
1016            else // ontop == 0
1017            {
1018                    for (i = 0; i < p_section->ontop_article_count; i++)
1019                    {
1020                            if (p_section->p_ontop_articles[i]->aid == p_article->aid)
1021                            {
1022                                    break;
1023                            }
1024                    }
1025                    if (i == p_section->ontop_article_count) // not found
1026                    {
1027                            log_error("Inconsistent state found: article %d not ontop in section %d\n", p_article->aid, p_section->sid);
1028                            return 0;
1029                    }
1030    
1031                    memmove((void *)(p_section->p_ontop_articles + i),
1032                                    (void *)(p_section->p_ontop_articles + i + 1),
1033                                    sizeof(ARTICLE *) * (size_t)(p_section->ontop_article_count - i - 1));
1034                    p_section->ontop_article_count--;
1035            }
1036    
1037            return 0;
1038    }
1039    
1040    int section_list_page_count_with_ontop(SECTION_LIST *p_section)
1041    {
1042            int page_count;
1043    
1044            if (p_section == NULL)
1045            {
1046                    log_error("NULL pointer error\n");
1047                    return -1;
1048            }
1049    
1050            page_count = p_section->page_count - 1 +
1051                                     (p_section->last_page_visible_article_count + p_section->ontop_article_count) / BBS_article_limit_per_page +
1052                                     ((p_section->last_page_visible_article_count + p_section->ontop_article_count) % BBS_article_limit_per_page == 0 ? 0 : 1);
1053    
1054            return page_count;
1055    }
1056    
1057    int section_list_page_article_count_with_ontop(SECTION_LIST *p_section, int32_t page_id)
1058    {
1059            if (p_section == NULL)
1060            {
1061                    log_error("NULL pointer error\n");
1062                    return -1;
1063            }
1064    
1065            if (page_id < p_section->page_count - 1)
1066            {
1067                    return BBS_article_limit_per_page;
1068            }
1069            else // if (page_id >= p_section->page_count - 1)
1070            {
1071                    return MAX(0, (p_section->last_page_visible_article_count + p_section->ontop_article_count -
1072                                               BBS_article_limit_per_page * (page_id - p_section->page_count + 1)));
1073            }
1074    }
1075    
1076  ARTICLE *section_list_find_article_with_offset(SECTION_LIST *p_section, int32_t aid, int32_t *p_page, int32_t *p_offset, ARTICLE **pp_next)  ARTICLE *section_list_find_article_with_offset(SECTION_LIST *p_section, int32_t aid, int32_t *p_page, int32_t *p_offset, ARTICLE **pp_next)
1077  {  {
1078          ARTICLE *p_article;          ARTICLE *p_article;
# Line 1023  int section_list_calculate_page(SECTION_ Line 1272  int section_list_calculate_page(SECTION_
1272          return 0;          return 0;
1273  }  }
1274    
1275    int32_t article_block_last_aid(void)
1276    {
1277            ARTICLE_BLOCK *p_block = p_article_block_pool->p_block[p_article_block_pool->block_count - 1];
1278            int32_t last_aid = p_block->articles[p_block->article_count - 1].aid;
1279    
1280            return last_aid;
1281    }
1282    
1283    int article_block_article_count(void)
1284    {
1285            int ret;
1286    
1287            if (p_article_block_pool == NULL || p_article_block_pool->block_count <= 0)
1288            {
1289                    return -1;
1290            }
1291    
1292            ret = (p_article_block_pool->block_count - 1) * ARTICLE_PER_BLOCK +
1293                      p_article_block_pool->p_block[p_article_block_pool->block_count - 1]->article_count;
1294    
1295            return ret;
1296    }
1297    
1298  int article_count_of_topic(int32_t aid)  int article_count_of_topic(int32_t aid)
1299  {  {
1300          ARTICLE *p_article;          ARTICLE *p_article;
# Line 1063  int section_list_move_topic(SECTION_LIST Line 1335  int section_list_move_topic(SECTION_LIST
1335          int32_t first_inserted_aid_dest;          int32_t first_inserted_aid_dest;
1336          int move_counter;          int move_counter;
1337    
1338          if (p_section_dest == NULL)          if (p_section_src == NULL || p_section_dest == NULL)
1339          {          {
1340                  log_error("section_list_move_topic() NULL pointer error\n");                  log_error("section_list_move_topic() NULL pointer error\n");
1341                  return -1;                  return -1;
1342          }          }
1343    
1344            if (p_section_src->sid == p_section_dest->sid)
1345            {
1346                    log_error("section_list_move_topic() src and dest section are the same\n");
1347                    return -1;
1348            }
1349    
1350          if ((p_article = article_block_find_by_aid(aid)) == NULL)          if ((p_article = article_block_find_by_aid(aid)) == NULL)
1351          {          {
1352                  log_error("section_list_move_topic() error: article %d not found in block\n", aid);                  log_error("article_block_find_by_aid(aid = %d) error: article not found\n", aid);
1353                  return -2;                  return -2;
1354          }          }
1355    
# Line 1112  int section_list_move_topic(SECTION_LIST Line 1390  int section_list_move_topic(SECTION_LIST
1390          {          {
1391                  if (p_section_src->sid != p_article->sid)                  if (p_section_src->sid != p_article->sid)
1392                  {                  {
1393                          log_error("section_list_move_topic() error: src section sid %d != article %d sid %d\n",                          log_error("section_list_move_topic() warning: src section sid %d != article %d sid %d\n",
1394                                            p_section_src->sid, p_article->aid, p_article->sid);                                            p_section_src->sid, p_article->aid, p_article->sid);
1395                          return -2;                          p_article = p_article->p_topic_next;
1396                            continue;
1397                  }                  }
1398    
1399                  // Remove from bi-directional article list of src section                  // Remove from bi-directional article list of src section
# Line 1140  int section_list_move_topic(SECTION_LIST Line 1419  int section_list_move_topic(SECTION_LIST
1419    
1420                  if (section_list_find_article_with_offset(p_section_dest, p_article->aid, &page, &offset, &p_next) != NULL)                  if (section_list_find_article_with_offset(p_section_dest, p_article->aid, &page, &offset, &p_next) != NULL)
1421                  {                  {
1422                          log_error("section_list_move_topic() error: article %d already in section %d\n", p_article->aid, p_section_dest->sid);                          log_error("section_list_move_topic() warning: article %d already in section %d\n", p_article->aid, p_section_dest->sid);
1423                          return -4;                          p_article = p_article->p_topic_next;
1424                            continue;
1425                  }                  }
1426    
1427                  // Insert into bi-directional article list of dest section                  // Insert into bi-directional article list of dest section
# Line 1219  int section_list_move_topic(SECTION_LIST Line 1499  int section_list_move_topic(SECTION_LIST
1499    
1500          if (p_section_dest->article_count - dest_article_count_old != move_article_count)          if (p_section_dest->article_count - dest_article_count_old != move_article_count)
1501          {          {
1502                  log_error("section_list_move_topic() error: count of moved articles %d != %d\n",                  log_error("section_list_move_topic() warning: count of moved articles %d != %d\n",
1503                                    p_section_dest->article_count - dest_article_count_old, move_article_count);                                    p_section_dest->article_count - dest_article_count_old, move_article_count);
1504          }          }
1505    


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

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