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 #include <string.h>
0043 #include <unistd.h>
0044 #include <thlock.h>
0045 #include "test75.h"
0046 #include "ubf_int.h"
0047 #include <exassert.h>
0048
0049
0050
0051
0052
0053
0054
0055 exprivate __thread volatile int M_notifs = 0;
0056
0057
0058
0059
0060
0061
0062 void notification_callback (char *data, long len, long flags)
0063 {
0064 M_notifs++;
0065 }
0066
0067
0068
0069
0070 void CONVSV1 (TPSVCINFO *p_svc)
0071 {
0072 int ret=EXSUCCEED;
0073 char *buf = p_svc->data;
0074 long revent, len;
0075 NDRX_LOG(log_debug, "%s got call", __func__);
0076 M_notifs = 0;
0077
0078 buf = tprealloc(buf, 1024);
0079 NDRX_ASSERT_TP_OUT((NULL!=buf), "Failed to realloc");
0080
0081
0082 NDRX_ASSERT_VAL_OUT((strcmp(buf, "HELLO")==0), "Expected HELLO at connection point");
0083
0084
0085 NDRX_ASSERT_TP_OUT((EXFAIL==tprecv(p_svc->cd, &buf, &len, 0, &revent)), "Expected failure");
0086 NDRX_ASSERT_TP_OUT( (TPEEVENT==tperrno), "Expected TPEEVENT");
0087 NDRX_ASSERT_TP_OUT( (TPEV_SENDONLY==revent), "Expected TPEV_SENDONLY");
0088 NDRX_ASSERT_VAL_OUT((strcmp(buf, "CLWAIT")==0), "Expected CLWAIT at connection point");
0089
0090
0091 tperrno = 0;
0092 while (EXFAIL!=tpchkunsol() && M_notifs < 9)
0093 {
0094 usleep(1000);
0095 }
0096
0097 NDRX_ASSERT_TP_OUT( (0==tperrno), "Expected no error");
0098
0099
0100
0101 buf = tprealloc(buf, 1024);
0102 NDRX_ASSERT_TP_OUT((NULL!=buf), "Failed to realloc");
0103 snprintf(buf, sizeof(buf), "%d", M_notifs);
0104
0105 NDRX_ASSERT_TP_OUT( (EXSUCCEED==tpsend(p_svc->cd, buf, 0, 0, &revent)),
0106 "Failed send nr of notifs...");
0107
0108 out:
0109 tpreturn( ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0110 0L,
0111 (char *)buf,
0112 0L,
0113 0L);
0114 }
0115
0116
0117
0118
0119 int tpsvrinit(int argc, char **argv)
0120 {
0121 int ret = EXSUCCEED;
0122 NDRX_LOG(log_debug, "tpsvrinit called");
0123
0124 NDRX_ASSERT_TP_OUT((EXSUCCEED==tpadvertise("CONVSV1", CONVSV1)),
0125 "Failed to advertise");
0126
0127 out:
0128
0129 return ret;
0130 }
0131
0132
0133
0134
0135
0136 void tpsvrdone(void)
0137 {
0138 NDRX_LOG(log_debug, "tpsvrdone called");
0139 }
0140
0141
0142
0143
0144 int tpsvrthrinit(int argc, char **argv)
0145 {
0146 int ret = EXSUCCEED;
0147
0148 NDRX_ASSERT_TP_OUT((NULL==tpsetunsol(notification_callback)),
0149 "Invalid previous unsol handler");
0150
0151 out:
0152 return ret;
0153 }
0154
0155
0156
0157
0158 void tpsvrthrdone(void)
0159 {
0160 NDRX_LOG(log_debug, "tpsvrthrdone called");
0161 }
0162
0163
0164 expublic struct tmdsptchtbl_t ndrx_G_tmdsptchtbl[] = {
0165 { NULL, NULL, NULL, 0, 0 }
0166 };
0167
0168
0169
0170
0171
0172 int main( int argc, char** argv )
0173 {
0174 _tmbuilt_with_thread_option=EXTRUE;
0175 struct tmsvrargs_t tmsvrargs =
0176 {
0177 &tmnull_switch,
0178 &ndrx_G_tmdsptchtbl[0],
0179 0,
0180 tpsvrinit,
0181 tpsvrdone,
0182 NULL,
0183 NULL,
0184 NULL,
0185 NULL,
0186 NULL,
0187 tpsvrthrinit,
0188 tpsvrthrdone
0189 };
0190
0191 return( _tmstartserver( argc, argv, &tmsvrargs ));
0192
0193 }
0194
0195
0196