/[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.20 by sysadm, Sun May 25 08:15:03 2025 UTC Revision 1.21 by sysadm, Sun May 25 10:43:27 2025 UTC
# Line 1275  int section_list_try_rd_lock(SECTION_LIS Line 1275  int section_list_try_rd_lock(SECTION_LIS
1275          // Read lock on any specific section will also acquire single read lock on "all section"          // Read lock on any specific section will also acquire single read lock on "all section"
1276          // so that write lock on all section only need to acquire single write on on "all section"          // so that write lock on all section only need to acquire single write on on "all section"
1277          // rather than to acquire multiple write locks on all the available sections.          // rather than to acquire multiple write locks on all the available sections.
1278          if (index == BBS_max_section)          if (index != BBS_max_section)
1279          {          {
1280                  sops[2].sem_num = BBS_max_section * 2 + 1; // w_sem of all section                  sops[2].sem_num = BBS_max_section * 2 + 1; // w_sem of all section
1281                  sops[2].sem_op = 0;                                                // wait until unlocked                  sops[2].sem_op = 0;                                                // wait until unlocked
# Line 1289  int section_list_try_rd_lock(SECTION_LIS Line 1289  int section_list_try_rd_lock(SECTION_LIS
1289          timeout.tv_sec = wait_sec;          timeout.tv_sec = wait_sec;
1290          timeout.tv_nsec = 0;          timeout.tv_nsec = 0;
1291    
1292          ret = semtimedop(section_list_pool_semid, sops, (index == BBS_max_section ? 4 : 2), &timeout);          ret = semtimedop(section_list_pool_semid, sops, (index == BBS_max_section ? 2 : 4), &timeout);
1293          if (ret == -1 && errno != EAGAIN && errno != EINTR)          if (ret == -1 && errno != EAGAIN && errno != EINTR)
1294          {          {
1295                  log_error("semtimedop(index = %d, lock read) error %d\n", index, errno);                  log_error("semtimedop(index = %d, lock read) error %d\n", index, errno);
# Line 1351  int section_list_rd_unlock(SECTION_LIST Line 1351  int section_list_rd_unlock(SECTION_LIST
1351          sops[0].sem_op = -1;                                               // unlock          sops[0].sem_op = -1;                                               // unlock
1352          sops[0].sem_flg = IPC_NOWAIT | SEM_UNDO;           // no wait          sops[0].sem_flg = IPC_NOWAIT | SEM_UNDO;           // no wait
1353    
1354          // The same reason as section_list_try_rd_lock()          if (index != BBS_max_section)
         if (index == BBS_max_section)  
1355          {          {
1356                  sops[1].sem_num = BBS_max_section * 2;   // r_sem of all section                  sops[1].sem_num = BBS_max_section * 2;   // r_sem of all section
1357                  sops[1].sem_op = -1;                                     // unlock                  sops[1].sem_op = -1;                                     // unlock
1358                  sops[1].sem_flg = IPC_NOWAIT | SEM_UNDO; // no wait                  sops[1].sem_flg = IPC_NOWAIT | SEM_UNDO; // no wait
1359          }          }
1360    
1361          ret = semop(section_list_pool_semid, sops, (index == BBS_max_section ? 2 : 1));          ret = semop(section_list_pool_semid, sops, (index == BBS_max_section ? 1 : 2));
1362          if (ret == -1 && errno != EAGAIN && errno != EINTR)          if (ret == -1 && errno != EAGAIN && errno != EINTR)
1363          {          {
1364                  log_error("semop(index = %d, unlock read) error %d\n", index, errno);                  log_error("semop(index = %d, unlock read) error %d\n", index, errno);


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

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