/[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.11 by sysadm, Fri May 23 07:06:57 2025 UTC Revision 1.12 by sysadm, Fri May 23 10:45:54 2025 UTC
# Line 31  Line 31 
31  #define ARTICLE_BLOCK_SHM_COUNT_LIMIT 256 // limited by length (8-bit) of proj_id in ftok(path, proj_id)  #define ARTICLE_BLOCK_SHM_COUNT_LIMIT 256 // limited by length (8-bit) of proj_id in ftok(path, proj_id)
32  #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)
33    
34    #define CALCULATE_PAGE_THRESHOLD 100 // Adjust to tune performance of move topic
35    
36  struct article_block_t  struct article_block_t
37  {  {
38          ARTICLE articles[ARTICLE_PER_BLOCK];          ARTICLE articles[ARTICLE_PER_BLOCK];
# Line 831  int section_list_move_topic(SECTION_LIST Line 833  int section_list_move_topic(SECTION_LIST
833          int32_t move_article_count;          int32_t move_article_count;
834          int32_t dest_article_count_old;          int32_t dest_article_count_old;
835          int32_t last_unaffected_aid_src;          int32_t last_unaffected_aid_src;
836            int32_t first_inserted_aid_dest;
837            int move_counter;
838    
839          if (p_section_dest == NULL)          if (p_section_dest == NULL)
840          {          {
# Line 867  int section_list_move_topic(SECTION_LIST Line 871  int section_list_move_topic(SECTION_LIST
871          }          }
872    
873          dest_article_count_old = p_section_dest->article_count;          dest_article_count_old = p_section_dest->article_count;
874            move_counter = 0;
875            first_inserted_aid_dest = p_article->aid;
876    
877          do          do
878          {          {
# Line 952  int section_list_move_topic(SECTION_LIST Line 958  int section_list_move_topic(SECTION_LIST
958                  }                  }
959    
960                  p_article = p_article->p_topic_next;                  p_article = p_article->p_topic_next;
961    
962                    move_counter++;
963                    if (move_counter % CALCULATE_PAGE_THRESHOLD == 0)
964                    {
965                            // Re-calculate pages of desc section
966                            if (section_list_calculate_page(p_section_dest, first_inserted_aid_dest) < 0)
967                            {
968                                    log_error("section_list_calculate_page(section = %d, aid = %d) error\n",
969                                                      p_section_dest->sid, first_inserted_aid_dest);
970                            }
971    
972                            first_inserted_aid_dest = p_article->aid;
973                    }
974          } while (p_article->aid != aid);          } while (p_article->aid != aid);
975    
976          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)
# Line 960  int section_list_move_topic(SECTION_LIST Line 979  int section_list_move_topic(SECTION_LIST
979                                    p_section_dest->article_count - dest_article_count_old, move_article_count);                                    p_section_dest->article_count - dest_article_count_old, move_article_count);
980          }          }
981    
982          // Re-calculate pages of both src and desc sections          // Re-calculate pages of src section
983          if (section_list_calculate_page(p_section_src, last_unaffected_aid_src) < 0)          if (section_list_calculate_page(p_section_src, last_unaffected_aid_src) < 0)
984          {          {
985                  log_error("section_list_calculate_page(section = %d, aid = %d) error at aid = %d\n", p_section_src->sid, last_unaffected_aid_src, aid);                  log_error("section_list_calculate_page(section = %d, aid = %d) error at aid = %d\n",
986                                      p_section_src->sid, last_unaffected_aid_src, aid);
987          }          }
988          if (section_list_calculate_page(p_section_dest, aid) < 0)  
989            if (move_counter % CALCULATE_PAGE_THRESHOLD != 0)
990          {          {
991                  log_error("section_list_calculate_page(section = %d, aid = %d) error\n", p_section_dest->sid, aid);                  // Re-calculate pages of desc section
992                    if (section_list_calculate_page(p_section_dest, first_inserted_aid_dest) < 0)
993                    {
994                            log_error("section_list_calculate_page(section = %d, aid = %d) error\n",
995                                              p_section_dest->sid, first_inserted_aid_dest);
996                    }
997          }          }
998    
999          return move_article_count;          return move_article_count;


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

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