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
0035 #include <stdio.h>
0036 #include <stdlib.h>
0037 #include <ndebug.h>
0038 #include <atmi.h>
0039 #include <ndrstandard.h>
0040 #include <ubf.h>
0041 #include <test.fd.h>
0042
0043
0044
0045
0046 void TOUTSV (TPSVCINFO *p_svc)
0047 {
0048 sleep(30);
0049 tpreturn( TPFAIL,
0050 0L,
0051 NULL,
0052 0L,
0053 0L);
0054 }
0055
0056
0057
0058
0059
0060 void ECHO (TPSVCINFO *p_svc)
0061 {
0062 tpreturn( TPSUCCESS,
0063 0L,
0064 p_svc->data,
0065 0L,
0066 0L);
0067 }
0068
0069 void CONVSV (TPSVCINFO *p_svc)
0070 {
0071 int ret=EXSUCCEED;
0072 long revent;
0073 static double d = 55.66;
0074 int i;
0075 UBFH *p_ub = (UBFH *)p_svc->data;
0076 char tmp[128];
0077 long len;
0078 NDRX_LOG(log_debug, "CONVSV got call");
0079
0080
0081 Bprint(p_ub);
0082
0083 if (NULL==(p_ub = (UBFH *)tprealloc((char *)p_ub, 6000)))
0084 {
0085 ret=EXFAIL;
0086 goto out;
0087 }
0088
0089 d+=1;
0090
0091 for (i=0; i<100; i++)
0092 {
0093 sprintf(tmp, "SRV SND: %d", i);
0094 if (EXFAIL==Badd(p_ub, T_STRING_FLD, (char *)tmp, 0))
0095 {
0096 ret=EXFAIL;
0097 goto out;
0098 }
0099
0100 if (p_svc->flags & TPSENDONLY)
0101 {
0102 NDRX_LOG(log_debug, "Doing some send!");
0103
0104 if (EXFAIL==tpsend(p_svc->cd, (char *)p_ub, 0L, 0L, &revent))
0105 {
0106 NDRX_LOG(log_error, "Failed to send to client!");
0107 }
0108 }
0109 }
0110
0111
0112 if (EXFAIL==tpsend(p_svc->cd, (char *)p_ub, 0L, TPRECVONLY, &revent))
0113 {
0114 NDRX_LOG(log_error, "Failed to send to client!");
0115 goto out;
0116 }
0117
0118
0119 while (EXSUCCEED==tprecv(p_svc->cd, (char **)&p_ub, &len, 0L, &revent))
0120 {
0121 NDRX_LOG(log_debug, "Sent MSG OK!");
0122 }
0123
0124
0125 Bfprint(p_ub, stderr);
0126
0127 if (TPEEVENT==tperrno)
0128 {
0129 if (TPEV_SENDONLY==revent)
0130 {
0131 NDRX_LOG(log_debug, "We are senders - FINISH UP!");
0132 }
0133 else
0134 {
0135 NDRX_LOG(log_debug, "Did not get TPEV_SENDONLY!!!");
0136 ret=EXFAIL;
0137 }
0138 }
0139
0140 out:
0141 tpreturn( ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0142 0L,
0143 (char *)p_ub,
0144 0L,
0145 0L);
0146 }
0147
0148
0149
0150
0151
0152 void NOBLK (TPSVCINFO *p_svc)
0153 {
0154 int ret=EXSUCCEED;
0155 long revent;
0156 UBFH *p_ub = (UBFH *)p_svc->data;
0157
0158 sleep(5);
0159
0160 #ifdef EX_USE_EPOLL
0161
0162 while (EXSUCCEED==tpsend(p_svc->cd, (char *)p_ub, 0L, TPNOBLOCK, &revent));
0163
0164 if (TPEBLOCK!=tperrno)
0165 {
0166 NDRX_LOG(log_error, "TESTERROR: Expected TPEBLOCK got %s %ld", tpstrerror(tperrno),
0167 revent);
0168 EXFAIL_OUT(ret);
0169 }
0170 #endif
0171
0172
0173 out:
0174 tpreturn( ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0175 0L,
0176 (char *)p_ub,
0177 0L,
0178 0L);
0179 }
0180
0181
0182
0183
0184 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
0185 {
0186 int ret = EXSUCCEED;
0187 NDRX_LOG(log_debug, "tpsvrinit called");
0188
0189 if (EXSUCCEED!=tpadvertise("CONVSV", CONVSV))
0190 {
0191 NDRX_LOG(log_error, "Failed to initialize CONVSV!");
0192 ret=EXFAIL;
0193 }
0194
0195 if (EXSUCCEED!=tpadvertise("TOUTSV", TOUTSV))
0196 {
0197 NDRX_LOG(log_error, "Failed to initialize TOUTSV!");
0198 ret=EXFAIL;
0199 }
0200
0201
0202 if (EXSUCCEED!=tpadvertise("NOBLK", NOBLK))
0203 {
0204 NDRX_LOG(log_error, "Failed to initialize NOBLK!");
0205 ret=EXFAIL;
0206 }
0207
0208 if (EXSUCCEED!=tpadvertise("ECHO", ECHO))
0209 {
0210 NDRX_LOG(log_error, "Failed to initialize ECHO!");
0211 ret=EXFAIL;
0212 }
0213
0214 return ret;
0215 }
0216
0217
0218
0219
0220 void NDRX_INTEGRA(tpsvrdone)(void)
0221 {
0222 NDRX_LOG(log_debug, "tpsvrdone called");
0223 }
0224