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

Diff of /lbbs/src/bbs_main.c

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

Revision 1.54 by sysadm, Mon May 26 02:56:59 2025 UTC Revision 1.55 by sysadm, Tue May 27 00:54:01 2025 UTC
# Line 25  Line 25 
25  #include "screen.h"  #include "screen.h"
26  #include "menu.h"  #include "menu.h"
27  #include "bbs_cmd.h"  #include "bbs_cmd.h"
28    #include "section_list.h"
29    #include "trie_dict.h"
30  #include <unistd.h>  #include <unistd.h>
31  #include <time.h>  #include <time.h>
32  #include <string.h>  #include <string.h>
# Line 249  int bbs_center() Line 251  int bbs_center()
251    
252  int bbs_main()  int bbs_main()
253  {  {
254          MYSQL *db;          MYSQL *db = NULL;
255    
256            // Set data pools in shared memory readonly
257            if (set_trie_dict_shm_readonly() < 0)
258            {
259                    goto cleanup;
260            }
261            if (set_article_block_shm_readonly() < 0)
262            {
263                    goto cleanup;
264            }
265            if (set_section_list_shm_readonly() < 0)
266            {
267                    goto cleanup;
268            }
269    
270            // Load menu in shared memory
271            if (set_menu_shm_readonly(p_bbs_menu) < 0)
272            {
273                    goto cleanup;
274            }
275    
276          set_input_echo(0);          set_input_echo(0);
277    
278          // System info          // System info
279          if (bbs_info() < 0)          if (bbs_info() < 0)
280          {          {
281                  return -1;                  goto cleanup;
282          }          }
283    
284          db = db_open();          db = db_open();
285          if (db == NULL)          if (db == NULL)
286          {          {
287                  prints("无法连接数据库\n");                  prints("无法连接数据库\n");
288                  return -2;                  goto cleanup;
289          }          }
290    
291          // Welcome          // Welcome
292          if (bbs_welcome(db) < 0)          if (bbs_welcome(db) < 0)
293          {          {
294                  mysql_close(db);                  mysql_close(db);
295                  return -3;                  goto cleanup;
296          }          }
297    
298          // User login          // User login
299          if (bbs_login(db) < 0)          if (bbs_login(db) < 0)
300          {          {
301                  mysql_close(db);                  mysql_close(db);
302                  return -4;                  goto cleanup;
303          }          }
304          clearscr();          clearscr();
305    
306          // BBS Top 10          // BBS Top 10
307          display_file_ex(VAR_BBS_TOP, 1, 1);          display_file_ex(VAR_BBS_TOP, 1, 1);
308    
         // Load menu in shared memory  
         if (set_menu_shm_readonly(p_bbs_menu) < 0)  
         {  
                 return -5;  
         }  
   
309          // Main          // Main
310          bbs_center();          bbs_center();
311    
         // Unload menu in shared memory  
         detach_menu_shm(p_bbs_menu);  
         free(p_bbs_menu);  
         p_bbs_menu = NULL;  
   
312          // Logout          // Logout
313          bbs_logout(db);          bbs_logout(db);
314    
315          // Unload file_loader and trie_dict  cleanup:
316          // Do nothing explictly - SHM detached automatically on process exit          if (db != NULL)
317            {
318                    mysql_close(db);
319            }
320    
321            // Detach menu in shared memory
322            detach_menu_shm(p_bbs_menu);
323            free(p_bbs_menu);
324            p_bbs_menu = NULL;
325    
326          mysql_close(db);          // Detach data pools shm
327            detach_section_list_shm();
328            detach_article_block_shm();
329            detach_trie_dict_shm();
330    
331          return 0;          return 0;
332  }  }


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

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