![]() |
|
|||
0001 /** 0002 * @brief Test kill signal sequences - server 0003 * 0004 * @file atmisv93.c 0005 */ 0006 /* ----------------------------------------------------------------------------- 0007 * Enduro/X Middleware Platform for Distributed Transaction Processing 0008 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0009 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0010 * This software is released under one of the following licenses: 0011 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0012 * See LICENSE file for full text. 0013 * ----------------------------------------------------------------------------- 0014 * AGPL license: 0015 * 0016 * This program is free software; you can redistribute it and/or modify it under 0017 * the terms of the GNU Affero General Public License, version 3 as published 0018 * by the Free Software Foundation; 0019 * 0020 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0022 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0023 * for more details. 0024 * 0025 * You should have received a copy of the GNU Affero General Public License along 0026 * with this program; if not, write to the Free Software Foundation, Inc., 0027 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0028 * 0029 * ----------------------------------------------------------------------------- 0030 * A commercial use license is available from Mavimax, Ltd 0031 * contact@mavimax.com 0032 * ----------------------------------------------------------------------------- 0033 */ 0034 #include <stdio.h> 0035 #include <stdlib.h> 0036 #include <ndebug.h> 0037 #include <ndrstandard.h> 0038 #include <atmi.h> 0039 #include <signal.h> 0040 #include <ubf.h> 0041 #include <test.fd.h> 0042 #include <string.h> 0043 #include <unistd.h> 0044 #include "test93.h" 0045 0046 /*---------------------------Externs------------------------------------*/ 0047 /*---------------------------Macros-------------------------------------*/ 0048 /*---------------------------Enums--------------------------------------*/ 0049 /*---------------------------Typedefs-----------------------------------*/ 0050 /*---------------------------Globals------------------------------------*/ 0051 /*---------------------------Statics------------------------------------*/ 0052 0053 /* number of signal readings: */ 0054 int M_signal_2=0; 0055 int M_signal_14=0; 0056 int M_signal_15=0; 0057 int M_is_stock = EXFALSE; 0058 /*---------------------------Prototypes---------------------------------*/ 0059 0060 /** 0061 * register the signal sequences... 0062 */ 0063 exprivate void sighandler(int signo) 0064 { 0065 switch (signo) 0066 { 0067 case 2: 0068 M_signal_2++; 0069 break; 0070 case 14: 0071 M_signal_14++; 0072 break; 0073 case 15: 0074 M_signal_15++; 0075 break; 0076 } 0077 } 0078 0079 /** 0080 * Do initialisation 0081 */ 0082 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv) 0083 { 0084 int ret = EXSUCCEED; 0085 struct sigaction sigact; 0086 0087 NDRX_LOG(log_debug, "tpsvrinit called [%s]", argv[argc-2]); 0088 0089 sigact.sa_handler = sighandler; 0090 sigemptyset(&sigact.sa_mask); 0091 sigact.sa_flags = 0; 0092 sigaction(2, &sigact, NULL); 0093 sigaction(14, &sigact, NULL); 0094 sigaction(15, &sigact, NULL); 0095 0096 if (0==strcmp(argv[argc-2], "stock")) 0097 { 0098 NDRX_LOG(log_debug, "Stock mode"); 0099 M_is_stock=EXTRUE; 0100 } 0101 0102 out: 0103 return ret; 0104 } 0105 0106 /** 0107 * Do de-initialisation 0108 */ 0109 void NDRX_INTEGRA(tpsvrdone)(void) 0110 { 0111 NDRX_LOG(log_debug, "tpsvrdone called"); 0112 0113 if (M_is_stock) 0114 { 0115 while (0==M_signal_2 || 0==M_signal_15) 0116 { 0117 NDRX_LOG(log_debug, "Waiting for signals M_signal_2=%d M_signal_14=%d M_signal_15=%d", 0118 M_signal_2, M_signal_14, M_signal_15); 0119 sleep(1); 0120 } 0121 0122 if (1==M_signal_2 && 0==M_signal_14 && 1==M_signal_15) 0123 { 0124 NDRX_LOG(log_debug, "STOCK SIGNALS OK"); 0125 } 0126 } 0127 else 0128 { 0129 while (0==M_signal_2 || 0==M_signal_14 || 0==M_signal_15) 0130 { 0131 NDRX_LOG(log_debug, "Waiting for signals M_signal_2=%d M_signal_14=%d M_signal_15=%d", 0132 M_signal_2, M_signal_14, M_signal_15); 0133 sleep(1); 0134 } 0135 0136 NDRX_LOG(log_debug, "ALL SIGNALS OK"); 0137 } 0138 } 0139 0140 /* 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 |
![]() ![]() |