0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include <stdio.h>
0035 #include <stdlib.h>
0036 #include <ndebug.h>
0037 #include <atmi.h>
0038 #include <ndrstandard.h>
0039 #include <ubf.h>
0040 #include <test.fd.h>
0041 #include <string.h>
0042 #include <unistd.h>
0043 #include "test80.h"
0044 #include <ndrxdiag.h>
0045 #include <pthread.h>
0046
0047
0048
0049
0050
0051
0052
0053
0054 exprivate pthread_t M_shutdown_thread;
0055 exprivate int M_has_shutdown_thread = EXFALSE;
0056
0057
0058
0059
0060 void TESTSV (TPSVCINFO *p_svc)
0061 {
0062 int ret=EXSUCCEED;
0063 char testbuf[1024];
0064 UBFH *p_ub = (UBFH *)p_svc->data;
0065
0066 NDRX_LOG(log_debug, "%s got call", __func__);
0067
0068
0069 Bprint(p_ub);
0070
0071 if (EXFAIL==Bget(p_ub, T_STRING_FLD, 0, testbuf, 0))
0072 {
0073 NDRX_LOG(log_error, "TESTERROR: Failed to get T_STRING_FLD: %s",
0074 Bstrerror(Berror));
0075 ret=EXFAIL;
0076 goto out;
0077 }
0078
0079 if (0!=strcmp(testbuf, VALUE_EXPECTED))
0080 {
0081 NDRX_LOG(log_error, "TESTERROR: Expected: [%s] got [%s]",
0082 VALUE_EXPECTED, testbuf);
0083 ret=EXFAIL;
0084 goto out;
0085 }
0086
0087
0088 out:
0089 tpreturn( TPEXIT,
0090 0L,
0091 (char *)p_ub,
0092 0L,
0093 0L);
0094 }
0095
0096
0097
0098
0099
0100
0101 exprivate void * shutdown_thread_func(void* arg)
0102 {
0103 sleep(1);
0104 tpinit(NULL);
0105 tpexit();
0106 tpterm();
0107 return NULL;
0108 }
0109
0110
0111
0112
0113 void TESTSV2 (TPSVCINFO *p_svc)
0114 {
0115 int ret = EXSUCCEED;
0116
0117 pthread_attr_t pthread_custom_attr;
0118 pthread_attr_init(&pthread_custom_attr);
0119
0120 ndrx_platf_stack_set(&pthread_custom_attr);
0121
0122 if (EXSUCCEED!=(ret=pthread_create(&M_shutdown_thread, &pthread_custom_attr,
0123 &shutdown_thread_func, NULL)))
0124 {
0125 NDRX_PLATF_DIAG(NDRX_DIAG_PTHREAD_CREATE, errno, "shutdown_thread_func thread");
0126 }
0127
0128 tpreturn( TPFAIL,
0129 0L,
0130 NULL,
0131 0L,
0132 0L);
0133 }
0134
0135
0136
0137
0138 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
0139 {
0140 int ret = EXSUCCEED;
0141 NDRX_LOG(log_debug, "tpsvrinit called");
0142
0143 if (EXSUCCEED!=tpadvertise("TESTSV", TESTSV))
0144 {
0145 NDRX_LOG(log_error, "Failed to initialise TESTSV!");
0146 EXFAIL_OUT(ret);
0147 }
0148
0149 if (EXSUCCEED!=tpadvertise("TESTSV2", TESTSV2))
0150 {
0151 NDRX_LOG(log_error, "Failed to initialise TESTSV2!");
0152 EXFAIL_OUT(ret);
0153 }
0154
0155 out:
0156 return ret;
0157 }
0158
0159
0160
0161
0162 void NDRX_INTEGRA(tpsvrdone)(void)
0163 {
0164
0165 if (M_has_shutdown_thread)
0166 {
0167 pthread_join(M_shutdown_thread, NULL);
0168 }
0169
0170 NDRX_LOG(log_debug, "tpsvrdone called");
0171
0172 }
0173
0174