Back to home page

Enduro/X

 
 

    


0001 /**
0002  * @brief Cache boot server, for full startup will reset databases which are marked
0003  *   for startup clean up (bootreset flag)
0004  *
0005  * @file tpcachebtsv.c
0006  */
0007 /* -----------------------------------------------------------------------------
0008  * Enduro/X Middleware Platform for Distributed Transaction Processing
0009  * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0010  * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0011  * This software is released under one of the following licenses:
0012  * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0013  * See LICENSE file for full text.
0014  * -----------------------------------------------------------------------------
0015  * AGPL license:
0016  *
0017  * This program is free software; you can redistribute it and/or modify it under
0018  * the terms of the GNU Affero General Public License, version 3 as published
0019  * by the Free Software Foundation;
0020  *
0021  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0022  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0023  * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0024  * for more details.
0025  *
0026  * You should have received a copy of the GNU Affero General Public License along 
0027  * with this program; if not, write to the Free Software Foundation, Inc.,
0028  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0029  *
0030  * -----------------------------------------------------------------------------
0031  * A commercial use license is available from Mavimax, Ltd
0032  * contact@mavimax.com
0033  * -----------------------------------------------------------------------------
0034  */
0035 #include <stdio.h>
0036 #include <stdlib.h>
0037 #include <string.h>
0038 #include <errno.h>
0039 #include <regex.h>
0040 #include <utlist.h>
0041 
0042 #include <ndebug.h>
0043 #include <atmi.h>
0044 #include <sys_unix.h>
0045 #include <atmi_int.h>
0046 #include <typed_buf.h>
0047 #include <ndrstandard.h>
0048 #include <ubf.h>
0049 #include <Exfields.h>
0050 #include <atmi_shm.h>
0051 #include <exregex.h>
0052 #include "tpcachesv.h"
0053 #include <atmi_cache.h>
0054 /*---------------------------Externs------------------------------------*/
0055 /*---------------------------Macros-------------------------------------*/
0056 /*---------------------------Enums--------------------------------------*/
0057 /*---------------------------Typedefs-----------------------------------*/
0058 /*---------------------------Globals------------------------------------*/
0059 /*---------------------------Statics------------------------------------*/
0060 /*---------------------------Prototypes---------------------------------*/
0061 
0062 /**
0063  * Standard server init
0064  */
0065 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
0066 {
0067     int ret=EXSUCCEED;
0068     char *env;
0069     long l;
0070     
0071     
0072     /* pull in init.. */
0073     if (EXSUCCEED!=tpinit(NULL))
0074     {
0075         NDRX_LOG(log_error, "Failed to pre-init server");
0076         EXFAIL_OUT(ret);
0077     }
0078     
0079     NDRX_LOG(log_info, "Closing caches (1)...");
0080     ndrx_cache_uninit();
0081            
0082     /* get the env */
0083     
0084     env = getenv(CONF_NDRX_SYSFLAGS);
0085     
0086     if (NULL!=env)
0087     {
0088         l = atol(env);
0089         
0090         NDRX_LOG(log_debug, "sysflags=%ld", l);
0091         
0092         if (l & NDRX_PRC_SYSFLAGS_FULLSTART)
0093         {
0094             NDRX_LOG(log_info, "Fullstart - About to reset caches (if bootreset set)");
0095             
0096             
0097             NDRX_LOG(log_info, "Closing caches open (standard)");
0098             ndrx_cache_uninit();
0099             
0100             NDRX_LOG(log_debug, "init boot mode...");
0101             /* otherwise on restart we do not need cache handle... */
0102             if (EXSUCCEED!=ndrx_cache_init(NDRX_TPCACH_INIT_BOOT))
0103             {
0104                 NDRX_LOG(log_error, "Cache init failed");
0105                 EXFAIL_OUT(ret);
0106             }
0107         }
0108         else
0109         {
0110             NDRX_LOG(log_info, "not full startup, no cache reset");
0111         }
0112     }
0113 
0114     NDRX_LOG(log_info, "Closing caches (2)...");
0115     ndrx_cache_uninit();
0116 out:
0117 
0118     return ret;
0119 }
0120 
0121 void NDRX_INTEGRA(tpsvrdone) (void)
0122 {
0123     NDRX_LOG(log_debug, "%s called", __func__);
0124 }
0125 /* vim: set ts=4 sw=4 et smartindent: */