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

Diff of /lbbs/src/section_list_loader.c

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

Revision 1.5 by sysadm, Tue May 27 07:21:43 2025 UTC Revision 1.7 by sysadm, Tue May 27 12:24:43 2025 UTC
# Line 488  int apply_article_op_log_from_db(void) Line 488  int apply_article_op_log_from_db(void)
488                                          ret = ERR_UNKNOWN_SECTION;                                          ret = ERR_UNKNOWN_SECTION;
489                                          break;                                          break;
490                                  }                                  }
491                                    // acquire lock of dest section
492                                    if ((ret = section_list_rw_lock(p_section_dest)) < 0)
493                                    {
494                                            log_error("section_list_rw_lock(sid = %d) error\n", p_section_dest);
495                                            break;
496                                    }
497                                  // Move topic                                  // Move topic
498                                  if ((ret = section_list_move_topic(p_section, p_section_dest, p_article->aid)) < 0)                                  if ((ret = section_list_move_topic(p_section, p_section_dest, p_article->aid)) < 0)
499                                  {                                  {
500                                          break;                                          log_error("section_list_move_topic(src_sid=%d, dest_sid=%d, aid=%d) error (%d), retry in the next loop\n",
501                                                              p_section->sid, p_section_dest->sid, p_article->aid, ret);
502                                    }
503                                    // release lock of dest section
504                                    if (section_list_rw_unlock(p_section_dest) < 0)
505                                    {
506                                            log_error("section_list_rw_unlock(sid = %d) error\n", p_section_dest);
507                                            ret = -1;
508                                  }                                  }
509                          }                          }
510                          break;                          break;
# Line 685  int section_list_loader_reload(void) Line 698  int section_list_loader_reload(void)
698    
699          return 0;          return 0;
700  }  }
701    
702    int query_section_articles(SECTION_LIST *p_section, int32_t page_id, ARTICLE *p_articles[], int32_t *p_article_count)
703    {
704            ARTICLE *p_article;
705            ARTICLE *p_next_page_first_article;
706            int ret = 0;
707    
708            if (p_section == NULL || p_articles == NULL || p_article_count == NULL)
709            {
710                    log_error("query_section_articles() NULL pointer error\n");
711                    return -1;
712            }
713    
714            // acquire lock of section
715            if ((ret = section_list_rd_lock(p_section)) < 0)
716            {
717                    log_error("section_list_rd_lock(sid = %d) error\n", p_section->sid);
718                    return -2;
719            }
720    
721            if (page_id >= p_section->page_count)
722            {
723                    page_id = p_section->page_count - 1;
724            }
725    
726            if (page_id < 0)
727            {
728                    ret = -3;
729            }
730            else
731            {
732                    ret = page_id;
733                    p_article = p_section->p_page_first_article[page_id];
734                    p_next_page_first_article =
735                            (page_id == p_section->page_count - 1 ? p_section->p_article_head : p_section->p_page_first_article[page_id + 1]);
736                    *p_article_count = 0;
737    
738                    do
739                    {
740                            if (p_article->visible)
741                            {
742                                    p_articles[*p_article_count] = p_article;
743                                    (*p_article_count)++;
744                            }
745                            p_article = p_article->p_next;
746                    } while (p_article != p_next_page_first_article && (*p_article_count) <= BBS_article_limit_per_page);
747            }
748    
749            // release lock of section
750            if ((ret = section_list_rd_unlock(p_section)) < 0)
751            {
752                    log_error("section_list_rd_unlock(sid = %d) error\n", p_section->sid);
753                    ret = -2;
754            }
755    
756            return ret;
757    }


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

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