/[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.57 by sysadm, Sun Nov 16 00:10:48 2025 UTC Revision 1.58 by sysadm, Mon Nov 17 11:56:11 2025 UTC
# Line 25  Line 25 
25  #include <sys/sem.h>  #include <sys/sem.h>
26  #include <sys/shm.h>  #include <sys/shm.h>
27    
28  #ifdef _SEM_SEMUN_UNDEFINED  #if defined(_SEM_SEMUN_UNDEFINED) || defined(__MSYS__) || defined(__MINGW32__)
29  union semun  union semun
30  {  {
31          int val;                           /* Value for SETVAL */          int val;                           /* Value for SETVAL */
# Line 34  union semun Line 34  union semun
34          struct seminfo *__buf; /* Buffer for IPC_INFO          struct seminfo *__buf; /* Buffer for IPC_INFO
35                                                            (Linux-specific) */                                                            (Linux-specific) */
36  };  };
37  #endif // #ifdef _SEM_SEMUN_UNDEFINED  #endif // #if defined(_SEM_SEMUN_UNDEFINED)
38    
39  enum _section_list_constant_t  enum _section_list_constant_t
40  {  {
# Line 1609  int section_list_try_rd_lock(SECTION_LIS Line 1609  int section_list_try_rd_lock(SECTION_LIS
1609  {  {
1610          int index;          int index;
1611          struct sembuf sops[4];          struct sembuf sops[4];
1612    #if !defined(__MSYS__) && !defined(__MINGW32__)
1613          struct timespec timeout;          struct timespec timeout;
1614    #endif
1615          int ret;          int ret;
1616    
1617          index = get_section_index(p_section);          index = get_section_index(p_section);
# Line 1640  int section_list_try_rd_lock(SECTION_LIS Line 1642  int section_list_try_rd_lock(SECTION_LIS
1642                  sops[3].sem_flg = SEM_UNDO;                        // undo on terminate                  sops[3].sem_flg = SEM_UNDO;                        // undo on terminate
1643          }          }
1644    
1645    #if defined(__MSYS__) || defined(__MINGW32__)
1646            ret = semop(p_section_list_pool->semid, sops, (index == BBS_max_section ? 2 : 4));
1647    #else
1648          timeout.tv_sec = wait_sec;          timeout.tv_sec = wait_sec;
1649          timeout.tv_nsec = 0;          timeout.tv_nsec = 0;
1650    
1651          ret = semtimedop(p_section_list_pool->semid, sops, (index == BBS_max_section ? 2 : 4), &timeout);          ret = semtimedop(p_section_list_pool->semid, sops, (index == BBS_max_section ? 2 : 4), &timeout);
1652    #endif
1653          if (ret == -1 && errno != EAGAIN && errno != EINTR)          if (ret == -1 && errno != EAGAIN && errno != EINTR)
1654          {          {
1655                  log_error("semtimedop(index = %d, lock read) error %d\n", index, errno);                  log_error("semop(index = %d, lock read) error %d\n", index, errno);
1656          }          }
1657    
1658          return ret;          return ret;
# Line 1656  int section_list_try_rw_lock(SECTION_LIS Line 1662  int section_list_try_rw_lock(SECTION_LIS
1662  {  {
1663          int index;          int index;
1664          struct sembuf sops[3];          struct sembuf sops[3];
1665    #if !defined(__MSYS__) && !defined(__MINGW32__)
1666          struct timespec timeout;          struct timespec timeout;
1667    #endif
1668          int ret;          int ret;
1669    
1670          index = get_section_index(p_section);          index = get_section_index(p_section);
# Line 1677  int section_list_try_rw_lock(SECTION_LIS Line 1685  int section_list_try_rw_lock(SECTION_LIS
1685          sops[2].sem_op = 0;                                                        // wait until unlocked          sops[2].sem_op = 0;                                                        // wait until unlocked
1686          sops[2].sem_flg = 0;          sops[2].sem_flg = 0;
1687    
1688    #if defined(__MSYS__) || defined(__MINGW32__)
1689            ret = semop(p_section_list_pool->semid, sops, 3);
1690    #else
1691          timeout.tv_sec = wait_sec;          timeout.tv_sec = wait_sec;
1692          timeout.tv_nsec = 0;          timeout.tv_nsec = 0;
1693    
1694          ret = semtimedop(p_section_list_pool->semid, sops, 3, &timeout);          ret = semtimedop(p_section_list_pool->semid, sops, 3, &timeout);
1695    #endif
1696          if (ret == -1 && errno != EAGAIN && errno != EINTR)          if (ret == -1 && errno != EAGAIN && errno != EINTR)
1697          {          {
1698                  log_error("semtimedop(index = %d, lock write) error %d\n", index, errno);                  log_error("semop(index = %d, lock write) error %d\n", index, errno);
1699          }          }
1700    
1701          return ret;          return ret;


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

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