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

Diff of /lbbs/src/menu.c

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

Revision 1.78 by sysadm, Wed Oct 29 07:36:38 2025 UTC Revision 1.82 by sysadm, Tue Nov 4 14:30:44 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                    menu.c  -  description  /*
3                                                           -------------------   * menu
4          Copyright            : (C) 2004-2025 by Leaflet   *   - configurable user interactive menu feature
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2025 by Leaflet <leaflet@leafok.com>
7     */
 /***************************************************************************  
  *                                                                         *  
  *   This program is free software; you can redistribute it and/or modify  *  
  *   it under the terms of the GNU General Public License as published by  *  
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
8    
9  #include "bbs.h"  #include "bbs.h"
10  #include "bbs_cmd.h"  #include "bbs_cmd.h"
# Line 38  Line 30 
30    
31  #define MENU_SET_RESERVED_LENGTH (sizeof(int16_t) * 4)  #define MENU_SET_RESERVED_LENGTH (sizeof(int16_t) * 4)
32    
33  #define MENU_SHMGET_RETRY_LIMIT 3  #define MENU_SHMGET_RETRY_LIMIT 10
34    
35  MENU_SET bbs_menu;  MENU_SET bbs_menu;
36  MENU_SET top10_menu;  MENU_SET top10_menu;
# Line 104  int load_menu(MENU_SET *p_menu_set, cons Line 96  int load_menu(MENU_SET *p_menu_set, cons
96                  key = ftok(conf_file, proj_id + retry_cnt);                  key = ftok(conf_file, proj_id + retry_cnt);
97                  if (key == -1)                  if (key == -1)
98                  {                  {
99                          log_error("ftok(%s %d) error (%d)\n", conf_file, proj_id, errno);                          log_error("ftok(%s %d) error (%d)\n", conf_file, proj_id + retry_cnt, errno);
100                          return -2;                          return -3;
101                  }                  }
102    
103                  p_menu_set->shmid = shmget(key, size, IPC_CREAT | IPC_EXCL | 0600);                  p_menu_set->shmid = shmget(key, size, IPC_CREAT | IPC_EXCL | 0600);
   
104                  if (p_menu_set->shmid == -1)                  if (p_menu_set->shmid == -1)
105                  {                  {
106                          if (errno != EEXIST || retry_cnt + 1 >= MENU_SHMGET_RETRY_LIMIT)                          if (errno != EEXIST || retry_cnt + 1 >= MENU_SHMGET_RETRY_LIMIT)
107                          {                          {
108                                  log_error("shmget(conf_file=%s, size=%d) error (%d) %d times\n",                                  log_error("shmget(conf_file=%s, size=%d) error (%d) %d times\n",
109                                                    conf_file, size, errno, retry_cnt + 1);                                                    conf_file, size, errno, retry_cnt + 1);
110                                  break;                                  return -3;
111                          }                          }
112                          log_error("shmget(conf_file=%s, proj_id=%d, key=0x%x, size=%d) error (%d), retry ...\n",                          log_error("shmget(conf_file=%s, proj_id=%d, key=0x%x, size=%d) error (%d), retry ...\n",
113                                            conf_file, proj_id + retry_cnt, key, size, errno);                                            conf_file, proj_id + retry_cnt, key, size, errno);
# Line 1393  int unload_menu(MENU_SET *p_menu_set) Line 1384  int unload_menu(MENU_SET *p_menu_set)
1384    
1385          detach_menu_shm(p_menu_set);          detach_menu_shm(p_menu_set);
1386    
1387          if (shmctl(shmid, IPC_RMID, NULL) == -1)          if (shmid != 0 && shmctl(shmid, IPC_RMID, NULL) == -1)
1388          {          {
1389                  log_error("shmctl(shmid=%d, IPC_RMID) error (%d)\n", shmid, errno);                  log_error("shmctl(shmid=%d, IPC_RMID) error (%d)\n", shmid, errno);
1390                  return -1;                  return -1;


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

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