![]() |
|
|||
0001 /** 0002 * Singleton group lock provider 0003 * @file exsinglesv.h 0004 */ 0005 /* ----------------------------------------------------------------------------- 0006 * Enduro/X Middleware Platform for Distributed Transaction Processing 0007 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0008 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0009 * This software is released under one of the following licenses: 0010 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0011 * See LICENSE file for full text. 0012 * ----------------------------------------------------------------------------- 0013 * AGPL license: 0014 * 0015 * This program is free software; you can redistribute it and/or modify it under 0016 * the terms of the GNU Affero General Public License, version 3 as published 0017 * by the Free Software Foundation; 0018 * 0019 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0020 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0021 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0022 * for more details. 0023 * 0024 * You should have received a copy of the GNU Affero General Public License along 0025 * with this program; if not, write to the Free Software Foundation, Inc., 0026 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0027 * 0028 * ----------------------------------------------------------------------------- 0029 * A commercial use license is available from Mavimax, Ltd 0030 * contact@mavimax.com 0031 * ----------------------------------------------------------------------------- 0032 */ 0033 0034 #ifndef EXSINGLESV_H 0035 #define EXSINGLESV_H 0036 0037 #ifdef __cplusplus 0038 extern "C" { 0039 #endif 0040 0041 /*---------------------------Includes-----------------------------------*/ 0042 #include <limits.h> 0043 #include <exthpool.h> 0044 #include <singlegrp.h> 0045 /*---------------------------Externs------------------------------------*/ 0046 /*---------------------------Macros-------------------------------------*/ 0047 #define NDRX_LOCK_FILE_1 0 /**< first lock file name, permanent */ 0048 #define NDRX_LOCK_FILE_2 1/**< Ping lock */ 0049 0050 #define NDRX_LOCKE_FILE -1 /**< failed to create file */ 0051 #define NDRX_LOCKE_LOCK -2 /**< failed to lock file */ 0052 #define NDRX_LOCKE_BUSY -3 /**< file is locked */ 0053 #define NDRX_LOCKE_NOLOCK -4 /**< File is not locked */ 0054 /*---------------------------Enums--------------------------------------*/ 0055 /*---------------------------Typedefs-----------------------------------*/ 0056 0057 /** 0058 * Admin server configuration 0059 */ 0060 typedef struct 0061 { 0062 int procgrp_lp_no; /**< Providing lock for this group */ 0063 char lockfile_1[PATH_MAX+1]; /**< Lock file 1 */ 0064 char lockfile_2[PATH_MAX+1]; /**< Lock file 2 */ 0065 char exec_on_bootlocked[PATH_MAX+1]; /**< Exec on boot locked */ 0066 char exec_on_locked[PATH_MAX+1]; /**< Exec on locked */ 0067 int chkinterval; /**< Check interval */ 0068 int locked_wait; /**< Number of check cycles for lock takeover*/ 0069 int locked1; /**< Locked */ 0070 int first_boot; /**< Is booting up */ 0071 0072 int wait_counter; /**< if this is not first boot, then wait */ 0073 int is_locked; /**< Is process fully locked */ 0074 int svc_timeout; /**< Service timeout (for remote calls) */ 0075 int noremote; /**< Do not check remote servers, just HB file */ 0076 } ndrx_exsinglesv_conf_t; 0077 0078 /** 0079 * Locking state machine context 0080 */ 0081 typedef struct 0082 { 0083 ndrx_sg_shm_t *pshm; /**< Shared memory ptr of current group */ 0084 ndrx_sg_shm_t local; /**< Atomically copied shard memory entry */ 0085 /** 0086 * New precalcualted refresh time, so that at of the system 0087 * freeze this would already be old 0088 */ 0089 time_t new_refresh; 0090 long new_sequence; /**< New sequence number */ 0091 } ndrx_locksm_ctx_t; 0092 0093 /** 0094 * Disk based lock entry... 0095 */ 0096 typedef struct 0097 { 0098 uint64_t lock_time; /**< lock time in UTC epoch */ 0099 uint64_t sequence; /**< sequence counted on */ 0100 uint64_t crc32; /**< crc32 of the lock time */ 0101 } ndrx_exsinglesv_lockent_t; 0102 0103 /*---------------------------Globals------------------------------------*/ 0104 extern ndrx_exsinglesv_conf_t ndrx_G_exsinglesv_conf; /**< Configuration */ 0105 /*---------------------------Statics------------------------------------*/ 0106 /*---------------------------Prototypes---------------------------------*/ 0107 extern int ndrx_exsinglesv_file_lock(int lock_no, char *lockfile); 0108 extern int ndrx_exsinglesv_file_unlock(int lock_no); 0109 extern int ndrx_exsinglesv_file_chkpid(int lock_no, char *lockfile); 0110 extern void ndrx_exsinglesv_uninit(int normal_unlock, int force_unlock); 0111 extern int ndrx_exsinglesv_sm_run(void); 0112 extern int ndrx_exsinglesv_sm_comp(void); 0113 extern int ndrx_exsinglesv_sg_is_locked(ndrx_locksm_ctx_t *lock_ctx, int force_chk); 0114 extern void ndrx_exsinglesv_set_error_fmt(UBFH *p_ub, long error_code, const char *fmt, ...); 0115 0116 extern int ndrx_exsinglesv_ping_do(ndrx_locksm_ctx_t *lock_ctx); 0117 extern int ndrx_exsinglesv_ping_read(int nodeid, ndrx_exsinglesv_lockent_t *p_ent); 0118 extern long ndrx_exsinglesv_sg_max_seq(ndrx_locksm_ctx_t *lock_ctx); 0119 0120 /* Local service: */ 0121 extern void SGLOC (TPSVCINFO *p_svc); 0122 0123 /* Remote service: */ 0124 extern void SGREM (TPSVCINFO *p_svc); 0125 0126 /* LP specifics: */ 0127 extern void ndrx_exsinglesv_uninit(int normal_unlock, int force_unlock); 0128 0129 #ifdef __cplusplus 0130 } 0131 #endif 0132 0133 #endif /* EXSINGLESV_H */ 0134 0135 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |