Back to home page

Enduro/X

 
 

    


0001 /**
0002  *
0003  * @file atmisv18.c
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 #include <unistd.h>     /* Symbolic Constants */
0035 #include <sys/types.h>  /* Primitive System Data Types */ 
0036 #include <errno.h>      /* Errors */
0037 #include <stdio.h>      /* Input/Output */
0038 #include <stdlib.h>     /* General Utilities */
0039 #include <pthread.h>    /* POSIX Threads */
0040 
0041 
0042 #include <ndebug.h>
0043 #include <atmi.h>
0044 #include <ndrstandard.h>
0045 #include <ubf.h>
0046 #include <test.fd.h>
0047 #include <string.h>
0048 
0049 
0050 
0051 
0052 /* main server thread... 
0053  * NOTE: p_svc - this is local variable of enduro's main thread (on stack).
0054  * but p_svc->data - is auto buffer, will be freed when main thread returns.
0055  *                      Thus we need a copy of buffer for thread.
0056  */
0057 void TESTSVFN (TPSVCINFO *p_svc)
0058 {
0059     int ret=EXSUCCEED;
0060     UBFH *p_ub = (UBFH *)p_svc->data; /* this is auto-buffer */
0061    
0062     /* serve next.. */
0063     tpfree((char *)p_ub);
0064     
0065     NDRX_LOG(log_debug, "Got call + dumping it by continue()");
0066     
0067     tpcontinue();
0068 }
0069 
0070 /**
0071  * Just reply OK.
0072  * @param p_svc
0073  */
0074 void ECHO(TPSVCINFO *p_svc)
0075 {
0076     UBFH *p_ub = (UBFH *)p_svc->data;
0077     
0078     sleep(5);
0079     
0080     /* Return OK */
0081     tpreturn (TPSUCCESS, 0L, (char *)p_ub, 0L, 0L);
0082 }
0083 
0084 /**
0085  * Blocky service will do long processings...
0086  * @param p_svc
0087  */
0088 void BLOCKY(TPSVCINFO *p_svc)
0089 {
0090     UBFH *p_ub = (UBFH *)p_svc->data;
0091     
0092     sleep(9999);
0093     
0094     /* Return OK */
0095     tpreturn (TPSUCCESS, 0L, (char *)p_ub, 0L, 0L);
0096 }
0097 
0098 /*
0099  * Do initialization
0100  */
0101 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
0102 {
0103     int ret = EXSUCCEED;
0104     NDRX_LOG(log_debug, "tpsvrinit called");
0105 
0106     if (EXSUCCEED!=tpadvertise("TESTSV", TESTSVFN))
0107     {
0108         NDRX_LOG(log_error, "Failed to initialize TESTSV (first)!");
0109         ret=EXFAIL;
0110     }
0111     else if (EXSUCCEED!=tpadvertise("ECHO", ECHO))
0112     {
0113         NDRX_LOG(log_error, "Failed to initialize ECHO!");
0114         ret=EXFAIL;
0115     }
0116     else if (EXSUCCEED!=tpadvertise("BLOCKY", BLOCKY))
0117     {
0118         NDRX_LOG(log_error, "Failed to initialize BLOCKY!");
0119         ret=EXFAIL;
0120     }
0121     
0122     return ret;
0123 }
0124 
0125 /**
0126  * Do de-initialization
0127  */
0128 void NDRX_INTEGRA(tpsvrdone)(void)
0129 {
0130     NDRX_LOG(log_debug, "tpsvrdone called");
0131 }
0132 /* vim: set ts=4 sw=4 et smartindent: */