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 "test82.h"
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 void TESTSV2 (TPSVCINFO *p_svc)
0057 {
0058 int ret=EXSUCCEED;
0059 UBFH *p_ub = (UBFH *)p_svc->data;
0060 char testbuf[1024];
0061 TPQCTL qc;
0062
0063 NDRX_LOG(log_debug, "%s got call", __func__);
0064
0065 if (EXFAIL==Bget(p_ub, T_STRING_FLD, 0, testbuf, 0))
0066 {
0067 NDRX_LOG(log_error, "TESTERROR: Failed to get T_STRING_FLD: %s",
0068 Bstrerror(Berror));
0069 ret=EXFAIL;
0070 goto out;
0071 }
0072
0073
0074 memset(&qc, 0, sizeof(qc));
0075
0076
0077 if (EXSUCCEED!=tpenqueue("MYSPACE", "MSGQ", &qc, (char *)p_ub, 0, 0))
0078 {
0079 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
0080 tpstrerror(tperrno), qc.diagnostic, qc.diagmsg);
0081 EXFAIL_OUT(ret);
0082 }
0083
0084 if (0==strcmp(testbuf, "FAIL"))
0085 {
0086 ret=EXFAIL;
0087 }
0088 else if (0==strcmp(testbuf, "SLEEP"))
0089 {
0090
0091 sleep(15);
0092 }
0093 else if (0==strcmp(testbuf, "COMMIT"))
0094 {
0095 if (EXSUCCEED!=tpcommit(0))
0096 {
0097 NDRX_LOG(log_error, "TESTERROR: tpcommit() failed: %s",
0098 tpstrerror(tperrno));
0099 EXFAIL_OUT(ret);
0100 }
0101 }
0102 else if (0==strcmp(testbuf, "ABORT") || 0==strcmp(testbuf, "ABORT2") ||
0103 0==strcmp(testbuf, "ABORT3"))
0104 {
0105 if (EXSUCCEED!=tpabort(0))
0106 {
0107 NDRX_LOG(log_error, "TESTERROR: tpabort() failed: %s",
0108 tpstrerror(tperrno));
0109 EXFAIL_OUT(ret);
0110 }
0111 }
0112 else if (0==strcmp(testbuf, "RETURN"))
0113 {
0114 return;
0115 }
0116 #if 0
0117 due to Support #658 bug, cannot perform dynamic unadvertise/advertise to reach the stable works mode
0118 if (0==strcmp(testbuf, "OK"))
0119 {
0120
0121 if (EXSUCCEED!=tpunadvertise("TESTSV2"))
0122 {
0123 NDRX_LOG(log_error, "TESTERROR: Failed to unadvertise: %s", tpstrerror(tperrno));
0124 EXFAIL_OUT(ret);
0125 }
0126
0127
0128
0129
0130 sleep(3);
0131
0132 if (EXSUCCEED!=tpadvertise("TESTSV2", TESTSV2))
0133 {
0134 NDRX_LOG(log_error, "TESTERROR: Failed to advertise: %s", tpstrerror(tperrno));
0135 EXFAIL_OUT(ret);
0136 }
0137 }
0138 #endif
0139
0140 out:
0141
0142 tpreturn( EXSUCCEED==ret?TPSUCCESS:TPFAIL,
0143 0L,
0144 (char *)p_ub,
0145 0L,
0146 0L);
0147
0148 }
0149
0150
0151
0152
0153 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
0154 {
0155 int ret = EXSUCCEED;
0156 NDRX_LOG(log_debug, "tpsvrinit called");
0157
0158 if (EXSUCCEED!=tpopen())
0159 {
0160 NDRX_LOG(log_error, "Failed to tpopen: %s", tpstrerror(tperrno));
0161 EXFAIL_OUT(ret);
0162 }
0163
0164 if (EXSUCCEED!=tpadvertise("TESTSV2", TESTSV2))
0165 {
0166 NDRX_LOG(log_error, "Failed to initialise TESTSV2!");
0167 EXFAIL_OUT(ret);
0168 }
0169 out:
0170 return ret;
0171 }
0172
0173
0174
0175
0176 void NDRX_INTEGRA(tpsvrdone)(void)
0177 {
0178 tpclose();
0179
0180 NDRX_LOG(log_debug, "tpsvrdone called");
0181 }
0182
0183