![]() |
|
|||
0001 /** 0002 * @brief Testing Bug #475 boot time advertise limits 0003 * 0004 * @file atmisv34_2.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 <string.h> 0035 #include <stdio.h> 0036 #include <stdlib.h> 0037 #include <memory.h> 0038 #include <math.h> 0039 0040 #include <ndebug.h> 0041 #include <atmi.h> 0042 0043 0044 #include <ubf.h> 0045 #include <Exfields.h> 0046 #include <test.fd.h> 0047 #include <ndrstandard.h> 0048 #include <ndrxdcmn.h> 0049 /*---------------------------Externs------------------------------------*/ 0050 /*---------------------------Macros-------------------------------------*/ 0051 0052 #ifndef EXSUCCEED 0053 #define EXSUCCEED 0 0054 #endif 0055 0056 #ifndef EXFAIL 0057 #define EXFAIL -1 0058 #endif 0059 0060 #define USED_SERVICES 2 /**< used by bootet server */ 0061 /*---------------------------Enums--------------------------------------*/ 0062 /*---------------------------Typedefs-----------------------------------*/ 0063 /*---------------------------Globals------------------------------------*/ 0064 /*---------------------------Statics------------------------------------*/ 0065 /*---------------------------Prototypes---------------------------------*/ 0066 0067 /** 0068 * Dynamic function 0069 */ 0070 void DYNFUNC(TPSVCINFO *p_svc) 0071 { 0072 int ret = EXSUCCEED; 0073 UBFH *p_ub = (UBFH *)p_svc->data; 0074 0075 if (NULL==(p_ub = (UBFH *)tprealloc((char *)p_ub, 4096))) 0076 { 0077 EXFAIL_OUT(ret); 0078 } 0079 0080 if (EXFAIL==Badd(p_ub, T_STRING_2_FLD, p_svc->name, 0L)) 0081 { 0082 EXFAIL_OUT(ret); 0083 } 0084 0085 out: 0086 0087 tpreturn( ret==EXSUCCEED?TPSUCCESS:TPFAIL, 0088 0L, 0089 (char *)p_ub, 0090 0L, 0091 0L); 0092 } 0093 0094 /** 0095 * Initialize the application 0096 * Check static limits. 0097 * Shell test the environment when we have less SHM. 0098 * Currently it wont stop from booting as SHM limits are found only after 0099 * the init phase. 0100 * Currently it will silently ignore the system SHM limits and let binary to boot. 0101 * ndrxd and psc will see the queues. But thy will not be visible to shared 0102 * memory. Thus ndrxd psvc will not show them. 0103 * @param argc argument count 0104 * @param argv argument values 0105 * @return SUCCEED/FAIL 0106 */ 0107 int init(int argc, char** argv) 0108 { 0109 int ret = EXSUCCEED; 0110 int i; 0111 char svcnm[MAXTIDENT+1]; 0112 0113 TP_LOG(log_info, "Initialising..."); 0114 0115 /* try to hit the limit? On 50 we shall get the system error 0116 * Once we try to boot with more than have in shm 0117 * we shall get some failure too.. 0118 */ 0119 0120 /* check the test case... now... */ 0121 NDRX_LOG(log_error, "Advertise max per service"); 0122 for (i=0; i<MAX_SVC_PER_SVR-2 /* for adjust for admin/reply */ ; i++) 0123 { 0124 snprintf(svcnm, sizeof(svcnm), "ZZZ%06d", i); 0125 if (EXSUCCEED!=tpadvertise(svcnm, DYNFUNC)) 0126 { 0127 NDRX_LOG(log_error, "TESTERROR! Failed to advertise [%s]: %s", 0128 svcnm, tpstrerror(tperrno)); 0129 EXFAIL_OUT(ret); 0130 } 0131 } 0132 0133 NDRX_LOG(log_error, "Check limit, shall fail:"); 0134 /* Check for next failure.. */ 0135 snprintf(svcnm, sizeof(svcnm), "ZZZ%06d", i+1); 0136 if (EXSUCCEED==tpadvertise(svcnm, DYNFUNC)) 0137 { 0138 NDRX_LOG(log_error, "TESTERROR! Must fail to advertise but got OK!!! [%s]: %s", 0139 svcnm, tpstrerror(tperrno)); 0140 EXFAIL_OUT(ret); 0141 } 0142 0143 /* check error */ 0144 if (TPELIMIT!=tperrno) 0145 { 0146 NDRX_LOG(log_error, "TESTERROR! must be TPELIMIT, but got %d: %s", 0147 tperrno, tpstrerror(tperrno)); 0148 EXFAIL_OUT(ret); 0149 } 0150 0151 NDRX_LOG(log_error, "Static unadvertise: "); 0152 /* remove all, check for leaks... */ 0153 for (i=0; i<MAX_SVC_PER_SVR-2 /* for adjust for admin/reply */ ; i++) 0154 { 0155 snprintf(svcnm, sizeof(svcnm), "ZZZ%06d", i); 0156 if (EXSUCCEED!=tpunadvertise(svcnm)) 0157 { 0158 NDRX_LOG(log_error, "TESTERROR! Failed to unadvertise [%s]: %s", 0159 svcnm, tpstrerror(tperrno)); 0160 EXFAIL_OUT(ret); 0161 } 0162 } 0163 0164 /* ok do it again... */ 0165 for (i=0; i<MAX_SVC_PER_SVR-2 /* for adjust for admin/reply */ ; i++) 0166 { 0167 snprintf(svcnm, sizeof(svcnm), "ZZZ%06d", i); 0168 if (EXSUCCEED!=tpadvertise(svcnm, DYNFUNC)) 0169 { 0170 NDRX_LOG(log_error, "TESTERROR! Failed to advertise [%s]: %s", 0171 svcnm, tpstrerror(tperrno)); 0172 EXFAIL_OUT(ret); 0173 } 0174 } 0175 0176 0177 out: 0178 return ret; 0179 } 0180 0181 /** 0182 * Terminate the application 0183 */ 0184 void uninit(void) 0185 { 0186 TP_LOG(log_info, "Uninitialising..."); 0187 } 0188 0189 /** 0190 * Server program main entry 0191 * @param argc argument count 0192 * @param argv argument values 0193 * @return SUCCEED/FAIL 0194 */ 0195 int main(int argc, char** argv) 0196 { 0197 /* Launch the Enduro/x thread */ 0198 return ndrx_main_integra(argc, argv, init, uninit, 0); 0199 } 0200 0201 /* 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 |
![]() ![]() |