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

Diff of /lbbs/src/user_list.c

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

Revision 1.37 by sysadm, Tue Nov 18 14:43:35 2025 UTC Revision 1.38 by sysadm, Tue Nov 18 15:15:18 2025 UTC
# Line 519  void user_list_pool_cleanup(void) Line 519  void user_list_pool_cleanup(void)
519    
520  int set_user_list_pool_shm_readonly(void)  int set_user_list_pool_shm_readonly(void)
521  {  {
522    #ifndef __CYGWIN__
523          int shmid;          int shmid;
524          void *p_shm;          void *p_shm;
525    
# Line 531  int set_user_list_pool_shm_readonly(void Line 532  int set_user_list_pool_shm_readonly(void
532          shmid = p_user_list_pool->shmid;          shmid = p_user_list_pool->shmid;
533    
534          // Remap shared memory in read-only mode          // Remap shared memory in read-only mode
 #if defined(__CYGWIN__)  
         if (shmdt(p_user_list_pool) == -1)  
         {  
                 log_error("shmdt(user_list_pool) error (%d)\n", errno);  
                 return -1;  
         }  
         p_shm = shmat(shmid, p_user_list_pool, SHM_RDONLY);  
 #else  
535          p_shm = shmat(shmid, p_user_list_pool, SHM_RDONLY | SHM_REMAP);          p_shm = shmat(shmid, p_user_list_pool, SHM_RDONLY | SHM_REMAP);
 #endif  
536          if (p_shm == (void *)-1)          if (p_shm == (void *)-1)
537          {          {
538                  log_error("shmat(user_list_pool shmid = %d) error (%d)\n", shmid, errno);                  log_error("shmat(user_list_pool shmid = %d) error (%d)\n", shmid, errno);
# Line 548  int set_user_list_pool_shm_readonly(void Line 540  int set_user_list_pool_shm_readonly(void
540          }          }
541    
542          p_user_list_pool = p_shm;          p_user_list_pool = p_shm;
543    #endif
544    
545          return 0;          return 0;
546  }  }
# Line 651  cleanup: Line 644  cleanup:
644  int user_list_try_rd_lock(int semid, int wait_sec)  int user_list_try_rd_lock(int semid, int wait_sec)
645  {  {
646          struct sembuf sops[2];          struct sembuf sops[2];
647  #if !defined(__CYGWIN__)  #ifndef __CYGWIN__
648          struct timespec timeout;          struct timespec timeout;
649  #endif  #endif
650          int ret;          int ret;
# Line 664  int user_list_try_rd_lock(int semid, int Line 657  int user_list_try_rd_lock(int semid, int
657          sops[1].sem_op = 1;                     // lock          sops[1].sem_op = 1;                     // lock
658          sops[1].sem_flg = SEM_UNDO; // undo on terminate          sops[1].sem_flg = SEM_UNDO; // undo on terminate
659    
660  #if defined(__CYGWIN__)  #ifdef __CYGWIN__
661          ret = semop(semid, sops, 2);          ret = semop(semid, sops, 2);
662  #else  #else
663          timeout.tv_sec = wait_sec;          timeout.tv_sec = wait_sec;
# Line 683  int user_list_try_rd_lock(int semid, int Line 676  int user_list_try_rd_lock(int semid, int
676  int user_list_try_rw_lock(int semid, int wait_sec)  int user_list_try_rw_lock(int semid, int wait_sec)
677  {  {
678          struct sembuf sops[3];          struct sembuf sops[3];
679  #if !defined(__CYGWIN__)  #ifndef __CYGWIN__
680          struct timespec timeout;          struct timespec timeout;
681  #endif  #endif
682          int ret;          int ret;
# Line 700  int user_list_try_rw_lock(int semid, int Line 693  int user_list_try_rw_lock(int semid, int
693          sops[2].sem_op = 0;      // wait until unlocked          sops[2].sem_op = 0;      // wait until unlocked
694          sops[2].sem_flg = 0;          sops[2].sem_flg = 0;
695    
696  #if defined(__CYGWIN__)  #ifdef __CYGWIN__
697          ret = semop(semid, sops, 3);          ret = semop(semid, sops, 3);
698  #else  #else
699          timeout.tv_sec = wait_sec;          timeout.tv_sec = wait_sec;


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

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