summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libvxi11client/libvxi11client.c9
-rw-r--r--libvxi11client/perlbits/perlglue.c3
-rwxr-xr-xlibvxi11client/perlbits/testscript.pl5
-rw-r--r--vxi11_server.c19
4 files changed, 26 insertions, 10 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c
index 0e01809..219a17f 100644
--- a/libvxi11client/libvxi11client.c
+++ b/libvxi11client/libvxi11client.c
@@ -384,8 +384,10 @@ static gpointer interruptthreadfunc(gpointer data) {
return 0;
}
+ interruptserverport = transp->xp_port;
+
#ifdef DEBUG
- printf("Interrupt channel on port %d tcp\n", transp->xp_port);
+ printf("Interrupt channel on port %d tcp\n", interruptserverport);
#endif
if (!svc_register(transp, DEVICE_INTR, DEVICE_INTR_VERSION, device_intr_1, 0)) {
@@ -393,7 +395,6 @@ static gpointer interruptthreadfunc(gpointer data) {
return 0;
}
- interruptserverport = transp->xp_port;
g_mutex_lock(mutex);
g_cond_signal(cond);
g_mutex_unlock(mutex);
@@ -501,8 +502,8 @@ int vxi11_create_intr_chan(VXI11Context* context) {
struct sockaddr_in myaddress;
get_myaddress(&myaddress);
- Device_RemoteFunc remotefunc = { .hostAddr = myaddress.sin_addr.s_addr, .hostPort = interruptserverport, .progNum =
- DEVICE_INTR, .progVers = DEVICE_INTR_VERSION, .progFamily = DEVICE_TCP };
+ Device_RemoteFunc remotefunc = { .hostAddr = ntohl(myaddress.sin_addr.s_addr), .hostPort = interruptserverport,
+ .progNum = DEVICE_INTR, .progVers = DEVICE_INTR_VERSION, .progFamily = DEVICE_TCP };
Device_Error* error = create_intr_chan_1(&remotefunc, context->clnt);
if (error != NULL && error->error == 0) {
context->interruptchannelopen = true;
diff --git a/libvxi11client/perlbits/perlglue.c b/libvxi11client/perlbits/perlglue.c
index dec97c2..7807895 100644
--- a/libvxi11client/perlbits/perlglue.c
+++ b/libvxi11client/perlbits/perlglue.c
@@ -56,10 +56,13 @@ int glue_stop_interrupt_server() {
}
freelast();
g_async_queue_unref(interruptqueue);
+ interruptqueue = NULL;
return ret;
}
char* glue_wait_for_interrupt() {
+ if (interruptqueue)
+ return NULL;
GTimeVal timeout;
g_get_current_time(&timeout);
g_time_val_add(&timeout, 2500);
diff --git a/libvxi11client/perlbits/testscript.pl b/libvxi11client/perlbits/testscript.pl
index ae23e79..ac7dd3f 100755
--- a/libvxi11client/perlbits/testscript.pl
+++ b/libvxi11client/perlbits/testscript.pl
@@ -19,7 +19,10 @@ printf "status byte is " . $statusbyte . "\n";
$instr->vxi_create_intr_chan();
$instr->vxi_enable_srq("myhandle");
-vxi_wait_for_interrupt();
+
+for (my $i = 0; $i < 10000; $i++) {
+ vxi_wait_for_interrupt();
+}
$instr->vxi_disable_srq();
$instr->vxi_destroy_intr_chan();
$instr->vxi_abort();
diff --git a/vxi11_server.c b/vxi11_server.c
index 11fdf87..3f47c07 100644
--- a/vxi11_server.c
+++ b/vxi11_server.c
@@ -516,12 +516,15 @@ destroy_link_1_svc(Device_Link *argp, struct svc_req *rqstp) {
Device_Error *
create_intr_chan_1_svc(Device_RemoteFunc *argp, struct svc_req *rqstp) {
static Device_Error result;
+
+ in_port_t port = htons(argp->hostPort);
+ uint32_t addr = htonl(argp->hostAddr);
+
#ifdef DEBUG
printf("create_intr_chan_1_svc()\n");
char clientaddressstring[INET_ADDRSTRLEN];
- inet_ntop(AF_INET, &argp->hostAddr, clientaddressstring, sizeof(clientaddressstring));
- printf("Client %s is asking for an interrupt connection on port %u\n", clientaddressstring,
- (unsigned int) argp->hostPort);
+ inet_ntop(AF_INET, &addr, clientaddressstring, sizeof(clientaddressstring));
+ printf("Client %s is asking for an interrupt connection on port %u\n", clientaddressstring, (unsigned int) port);
#endif
// if a client had an interrupt channel and died without closing it
@@ -530,6 +533,9 @@ create_intr_chan_1_svc(Device_RemoteFunc *argp, struct svc_req *rqstp) {
if (intclient != NULL) {
clnt_geterr(intclient, &err);
if (err.re_errno != 0) {
+#ifdef DEBUG
+ printf("killing stale client\n");
+#endif
clnt_destroy(intclient);
intclient = NULL;
}
@@ -543,8 +549,8 @@ create_intr_chan_1_svc(Device_RemoteFunc *argp, struct svc_req *rqstp) {
else {
struct sockaddr_in clientaddr;
clientaddr.sin_family = AF_INET;
- clientaddr.sin_port = htons(argp->hostPort);
- clientaddr.sin_addr.s_addr = argp->hostAddr;
+ clientaddr.sin_port = port;
+ clientaddr.sin_addr.s_addr = addr;
int sock = RPC_ANYSOCK;
CLIENT* clnt = clnttcp_create(&clientaddr, DEVICE_INTR, DEVICE_INTR_VERSION, &sock, 0, 0);
if (clnt == NULL) {
@@ -556,6 +562,9 @@ create_intr_chan_1_svc(Device_RemoteFunc *argp, struct svc_req *rqstp) {
else {
intclient = clnt;
result.error = 0;
+#ifdef DEBUG
+ printf("Client created\n");
+#endif
}
}
return &result;