summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaniel <daniel@roi>2013-01-30 12:15:53 +0900
committerdaniel <daniel@roi>2013-01-30 12:15:53 +0900
commitc4957e4c650008698226c9b4b236222280f16396 (patch)
tree4e3f7498554f0e3d0ef916d684072a808ef02092
parent0cda537acf1ac6652ca8d2f3d0bfa1bd2725b2bd (diff)
Make interrupt timeout configurable
-rw-r--r--libvxi11client/libvxi11client.c172
-rw-r--r--libvxi11client/libvxi11client.h4
-rw-r--r--libvxi11client/perlbits/Client.xs7
-rw-r--r--libvxi11client/perlbits/perlglue.c47
-rw-r--r--vxi11_server.c39
5 files changed, 185 insertions, 84 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c
index 7b23c43..586e84f 100644
--- a/libvxi11client/libvxi11client.c
+++ b/libvxi11client/libvxi11client.c
@@ -4,6 +4,7 @@
#include <unistd.h>
#include <glib.h>
#include <poll.h>
+#include <errno.h>
#include "libvxi11client.h"
#include "vxi11.h"
@@ -37,7 +38,7 @@ device_intr_srq_1_svc(Device_SrqParms *argp, struct svc_req *rqstp) {
printf("device_intr_srq_1_svc()\n");
#endif
- if (interruptcallback != NULL) {
+ if (interruptcallback != NULL ) {
interruptcallback(argp->handle.handle_val);
}
@@ -54,8 +55,8 @@ static void device_intr_1(struct svc_req *rqstp, register SVCXPRT *transp) {
char *(*local)(char *, struct svc_req *);
switch (rqstp->rq_proc) {
- case NULLPROC:
- (void) svc_sendreply(transp, (xdrproc_t) xdr_void, (char *) NULL);
+ case NULLPROC :
+ (void) svc_sendreply(transp, (xdrproc_t) xdr_void, (char *) NULL );
return;
case device_intr_srq:
@@ -103,8 +104,10 @@ static Device_Flags vxi11_generateflags(bool waitlock, bool end, bool termchrset
int vxi11_open(VXI11Context* context, char* address, char* device) {
context->clnt = clnt_create(address, DEVICE_CORE, DEVICE_CORE_VERSION, "tcp");
- if (context->clnt == NULL)
+ if (context->clnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
else {
Create_LinkParms link_parms;
@@ -131,7 +134,7 @@ int vxi11_open(VXI11Context* context, char* address, char* device) {
serveraddr.sin_port = htons(linkresp->abortPort);
int sock = RPC_ANYSOCK;
context->abortclnt = clnttcp_create(&serveraddr, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, &sock, 0, 0);
- if (context->abortclnt == NULL)
+ if (context->abortclnt == NULL )
return 0;
}
@@ -144,8 +147,10 @@ int vxi11_open(VXI11Context* context, char* address, char* device) {
return 1;
}
- else if (linkresp == NULL)
+ else if (linkresp == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(linkresp->error);
}
@@ -158,8 +163,10 @@ int vxi11_open(VXI11Context* context, char* address, char* device) {
*/
int vxi11_readstatusbyte(VXI11Context* context, bool waitforlock) {
- if (context->clnt == NULL)
+ if (context->clnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
Device_GenericParms params = { .lid = context->devicelink, .flags = vxi11_generateflags(waitforlock, false, false),
.lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
@@ -168,8 +175,10 @@ int vxi11_readstatusbyte(VXI11Context* context, bool waitforlock) {
if (resp != NULL && resp->error == 0)
return resp->stb | (1 << 8); // this sets a bit above the byte so that we can tell whether there was a state issue
// or if the instrument returned 0
- else if (resp == NULL)
+ else if (resp == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(resp->error);
}
@@ -180,8 +189,10 @@ int vxi11_readstatusbyte(VXI11Context* context, bool waitforlock) {
*/
int vxi11_write(VXI11Context* context, char* data, int len, bool waitlock, bool end) {
- if (context->clnt == NULL)
+ if (context->clnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
Device_WriteParms params = { .lid = context->devicelink, .io_timeout = VXI11_DEFAULT_TIMEOUT, .lock_timeout =
VXI11_DEFAULT_TIMEOUT, .flags = vxi11_generateflags(waitlock, end, false) };
@@ -191,8 +202,10 @@ int vxi11_write(VXI11Context* context, char* data, int len, bool waitlock, bool
Device_WriteResp* resp = device_write_1(&params, context->clnt);
if (resp != NULL && resp->error == 0)
return resp->size;
- else if (resp == NULL)
+ else if (resp == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(resp->error);
}
@@ -203,8 +216,10 @@ int vxi11_write(VXI11Context* context, char* data, int len, bool waitlock, bool
int vxi11_read(VXI11Context* context, char* buffer, unsigned int bufferlen, bool waitlock, bool termchrset,
char termchr, unsigned int* reason) {
- if (context->clnt == NULL)
+ if (context->clnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
Device_ReadParms params = { .lid = context->devicelink, .requestSize = 256, .io_timeout = VXI11_DEFAULT_TIMEOUT,
.lock_timeout = VXI11_DEFAULT_TIMEOUT, .flags = vxi11_generateflags(waitlock, false, termchrset),
@@ -215,7 +230,7 @@ int vxi11_read(VXI11Context* context, char* buffer, unsigned int bufferlen, bool
#ifdef DEBUG
printf("Got \"%s\" from server\n", resp->data.data_val);
#endif
- if (buffer != NULL && resp->data.data_val != NULL) {
+ if (buffer != NULL && resp->data.data_val != NULL ) {
int lengthtocopy = ((bufferlen - 1) < resp->data.data_len ? (bufferlen - 1) : resp->data.data_len);
strncpy(buffer, resp->data.data_val, lengthtocopy);
}
@@ -223,12 +238,14 @@ int vxi11_read(VXI11Context* context, char* buffer, unsigned int bufferlen, bool
else
printf("Supplied buffer is null!\n");
#endif
- if (reason != NULL)
+ if (reason != NULL )
*reason = resp->reason;
return resp->data.data_len;
}
- else if (resp == NULL)
+ else if (resp == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(resp->error);
}
@@ -240,14 +257,16 @@ int vxi11_read(VXI11Context* context, char* buffer, unsigned int bufferlen, bool
int vxi11_docmd(VXI11Context* context, char* datain, int datainlen, char* dataout, int outbufferlen, int* dataoutlen,
unsigned long cmd, bool waitforlock) {
- if (context->clnt == NULL)
+ if (context->clnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
Device_DocmdParms params = { .lid = context->devicelink, .flags = vxi11_generateflags(waitforlock, false, false),
.io_timeout = VXI11_DEFAULT_TIMEOUT, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .cmd = cmd, .network_order = 0,
.datasize = 0 };
- if (datain == NULL)
+ if (datain == NULL )
datainlen = 0;
else if (datainlen < 0)
datainlen = strlen(datain) + 1;
@@ -257,14 +276,16 @@ int vxi11_docmd(VXI11Context* context, char* datain, int datainlen, char* dataou
Device_DocmdResp* resp = device_docmd_1(&params, context->clnt);
if (resp != NULL && resp->error == 0) {
- if (dataout != NULL)
+ if (dataout != NULL )
strncpy(dataout, resp->data_out.data_out_val,
(resp->data_out.data_out_len > outbufferlen ? outbufferlen : resp->data_out.data_out_len));
*dataoutlen = resp->data_out.data_out_len;
return 1;
}
- else if (resp == NULL)
+ else if (resp == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(resp->error);
}
@@ -274,8 +295,10 @@ int vxi11_docmd(VXI11Context* context, char* datain, int datainlen, char* dataou
*/
int vxi11_trigger(VXI11Context* context, bool waitforlock) {
- if (context->clnt == NULL)
+ if (context->clnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
Device_GenericParms params = { .lid = context->devicelink, .flags = vxi11_generateflags(waitforlock, false, false),
.lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
@@ -283,6 +306,10 @@ int vxi11_trigger(VXI11Context* context, bool waitforlock) {
if (error->error == 0)
return 1;
+ else if (error == NULL ) {
+ errno = ERRNO_NULLRESULT;
+ return 0;
+ }
else
return -(error->error);
}
@@ -292,15 +319,19 @@ int vxi11_trigger(VXI11Context* context, bool waitforlock) {
*/
int vxi11_clear(VXI11Context* context, bool waitforlock) {
- if (context->clnt == NULL)
+ if (context->clnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
Device_GenericParms params = { .lid = context->devicelink, .flags = vxi11_generateflags(waitforlock, false, false),
.lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
Device_Error* error = device_clear_1(&params, context->clnt);
if (error != NULL && error->error == 0)
return 1;
- else if (error == NULL)
+ else if (error == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(error->error);
}
@@ -310,15 +341,19 @@ int vxi11_clear(VXI11Context* context, bool waitforlock) {
*/
int vxi11_remote(VXI11Context* context, bool waitforlock) {
- if (context->clnt == NULL)
+ if (context->clnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
Device_GenericParms params = { .lid = context->devicelink, .flags = vxi11_generateflags(waitforlock, false, false),
.lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
Device_Error* error = device_remote_1(&params, context->clnt);
if (error != NULL && error->error == 0)
return 1;
- else if (error == NULL)
+ else if (error == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(error->error);
}
@@ -328,15 +363,19 @@ int vxi11_remote(VXI11Context* context, bool waitforlock) {
*/
int vxi11_local(VXI11Context* context, bool waitforlock) {
- if (context->clnt == NULL)
+ if (context->clnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
Device_GenericParms params = { .lid = context->devicelink, .flags = vxi11_generateflags(waitforlock, false, false),
.lock_timeout = VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
Device_Error* error = device_local_1(&params, context->clnt);
if (error != NULL && error->error == 0)
return 1;
- else if (error == NULL)
+ else if (error == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(error->error);
}
@@ -346,15 +385,19 @@ int vxi11_local(VXI11Context* context, bool waitforlock) {
*/
int vxi11_lock(VXI11Context* context, bool waitforlock) {
- if (context->clnt == NULL)
+ if (context->clnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
Device_LockParms params = { .lid = context->devicelink, .flags = vxi11_generateflags(waitforlock, false, false),
.lock_timeout = VXI11_DEFAULT_TIMEOUT };
Device_Error* error = device_lock_1(&params, context->clnt);
if (error != NULL && error->error == 0)
return 1;
- else if (error == NULL)
+ else if (error == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(error->error);
}
@@ -364,13 +407,17 @@ int vxi11_lock(VXI11Context* context, bool waitforlock) {
*/
int vxi11_unlock(VXI11Context* context) {
- if (context->clnt == NULL)
+ if (context->clnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
Device_Error* error = device_unlock_1(&(context->devicelink), context->clnt);
if (error != NULL && error->error == 0)
return 1;
- else if (error == NULL)
+ else if (error == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(error->error);
}
@@ -381,7 +428,7 @@ static gpointer interruptthreadfunc(gpointer data) {
#endif
SVCXPRT *transp;
transp = svctcp_create(RPC_ANYSOCK, 0, 0);
- if (transp == NULL) {
+ if (transp == NULL ) {
fprintf(stderr, "%s", "cannot create tcp service.");
return 0;
}
@@ -407,13 +454,13 @@ static gpointer interruptthreadfunc(gpointer data) {
while (interruptserverstarted) {
int max_pollfd = svc_max_pollfd;
- if (max_pollfd == 0 && svc_pollfd == NULL)
+ if (max_pollfd == 0 && svc_pollfd == NULL )
break;
if (last_max_pollfd != max_pollfd) {
struct pollfd *new_pollfd = realloc(my_pollfd, sizeof(struct pollfd) * max_pollfd);
- if (new_pollfd == NULL) {
+ if (new_pollfd == NULL ) {
break;
}
@@ -444,18 +491,18 @@ static gpointer interruptthreadfunc(gpointer data) {
#ifdef DEBUG
printf("Interrupt channel thread ended\n");
#endif
- return NULL;
+ return NULL ;
}
int vxi11_start_interrupt_server(void (*callback)(char* handle)) {
interruptcallback = callback;
interruptserverstarted = true;
- g_thread_init(NULL);
+ g_thread_init(NULL );
mutex = g_mutex_new();
cond = g_cond_new();
g_mutex_lock(mutex);
- interruptthread = g_thread_create(interruptthreadfunc, NULL, true, NULL);
- if (interruptthread == NULL)
+ interruptthread = g_thread_create(interruptthreadfunc, NULL, true, NULL );
+ if (interruptthread == NULL )
return 0;
#ifdef DEBUG
@@ -492,12 +539,15 @@ int vxi11_stop_interrupt_server() {
* create an interrupt channel from the connected device
*/
int vxi11_create_intr_chan(VXI11Context* context) {
- if (context->clnt == NULL || context->interruptchannelopen)
+ if (context->clnt == NULL || context->interruptchannelopen) {
+ errno = ERRNO_BADSTATE;
return 0;
- else if (interruptthread == NULL) {
+ }
+ else if (interruptthread == NULL ) {
#ifdef DEBUG
printf("interrupt thread isn't running\n");
#endif
+ errno = ERRNO_INTERRUPTHANDLERTHREADISDEAD;
return 0;
}
@@ -511,8 +561,10 @@ int vxi11_create_intr_chan(VXI11Context* context) {
context->interruptchannelopen = true;
return 1;
}
- else if (error == NULL)
+ else if (error == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(error->error);
}
@@ -522,18 +574,24 @@ int vxi11_create_intr_chan(VXI11Context* context) {
*/
int vxi11_destroy_intr_chan(VXI11Context* context) {
- if (context->clnt == NULL || !(context->interruptchannelopen))
+ if (context->clnt == NULL || !(context->interruptchannelopen)) {
+ errno = ERRNO_BADSTATE;
return 0;
- else if (interruptthread == NULL)
+ }
+ else if (interruptthread == NULL ) {
+ errno = ERRNO_INTERRUPTHANDLERTHREADISDEAD;
return 0;
+ }
Device_Error* error = destroy_intr_chan_1(NULL, context->clnt);
if (error != NULL && error->error == 0) {
context->interruptchannelopen = false;
return 1;
}
- else if (error == NULL)
+ else if (error == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(error->error);
}
@@ -543,14 +601,18 @@ int vxi11_destroy_intr_chan(VXI11Context* context) {
*/
int vxi11_enable_srq(VXI11Context* context, bool enable, char* handle) {
- if (context->clnt == NULL || !(context->interruptchannelopen))
+ if (context->clnt == NULL || !(context->interruptchannelopen)) {
+ errno = ERRNO_BADSTATE;
return 0;
- else if (interruptthread == NULL)
+ }
+ else if (interruptthread == NULL ) {
+ errno = ERRNO_INTERRUPTHANDLERTHREADISDEAD;
return 0;
+ }
Device_EnableSrqParms params = { .lid = context->devicelink, .enable = enable };
if (enable) {
- if (handle != NULL) {
+ if (handle != NULL ) {
params.handle.handle_val = handle;
params.handle.handle_len = strlen(handle) + 1;
}
@@ -563,8 +625,10 @@ int vxi11_enable_srq(VXI11Context* context, bool enable, char* handle) {
if (error != NULL && error->error == 0) {
return 1;
}
- else if (error == NULL)
+ else if (error == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(error->error);
}
@@ -574,13 +638,17 @@ int vxi11_enable_srq(VXI11Context* context, bool enable, char* handle) {
*/
int vxi11_abort(VXI11Context* context) {
- if (context->abortclnt == NULL)
+ if (context->abortclnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
Device_Error* error = device_abort_1(&(context->devicelink), context->abortclnt);
if (error != NULL && error->error == 0)
return 1;
- else if (error == NULL)
+ else if (error == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(error->error);
}
@@ -590,8 +658,10 @@ int vxi11_abort(VXI11Context* context) {
*/
int vxi11_close(VXI11Context* context) {
- if (context->clnt == NULL)
+ if (context->clnt == NULL ) {
+ errno = ERRNO_BADSTATE;
return 0;
+ }
Device_Error* error = destroy_link_1(&(context->devicelink), context->clnt);
clnt_destroy(context->clnt);
@@ -601,8 +671,10 @@ int vxi11_close(VXI11Context* context) {
if (error != NULL && error->error == 0)
return 1;
- else if (error == NULL)
+ else if (error == NULL ) {
+ errno = ERRNO_NULLRESULT;
return 0;
+ }
else
return -(error->error);
}
diff --git a/libvxi11client/libvxi11client.h b/libvxi11client/libvxi11client.h
index ff301d3..407fc83 100644
--- a/libvxi11client/libvxi11client.h
+++ b/libvxi11client/libvxi11client.h
@@ -1,6 +1,10 @@
#include <stdbool.h>
#include "vxi11.h"
+#define ERRNO_BADSTATE 1
+#define ERRNO_INTERRUPTHANDLERTHREADISDEAD 2
+#define ERRNO_NULLRESULT 3
+
#define ERR_SYNTAXERROR -1
#define ERR_DEVICENOTACCESSIBLE -3
#define ERR_INVALIDLINKINDENTIFIER -4
diff --git a/libvxi11client/perlbits/Client.xs b/libvxi11client/perlbits/Client.xs
index d84482e..1ad34e9 100644
--- a/libvxi11client/perlbits/Client.xs
+++ b/libvxi11client/perlbits/Client.xs
@@ -93,9 +93,10 @@ vxi_enable_srq_long(context, enable, handle)
RETVAL
char*
-vxi_wait_for_interrupt()
- CODE:
- RETVAL = glue_wait_for_interrupt();
+vxi_wait_for_interrupt(timeout = 0)
+ unsigned int timeout
+ CODE:
+ RETVAL = glue_wait_for_interrupt(timeout);
OUTPUT:
RETVAL
diff --git a/libvxi11client/perlbits/perlglue.c b/libvxi11client/perlbits/perlglue.c
index 7807895..259a652 100644
--- a/libvxi11client/perlbits/perlglue.c
+++ b/libvxi11client/perlbits/perlglue.c
@@ -3,6 +3,12 @@
#include <glib.h>
#include "libvxi11client.h"
+#define DEBUG
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
static GAsyncQueue* interruptqueue;
typedef struct {
@@ -17,7 +23,7 @@ static void freeevent(Event* event) {
}
static void freelast() {
- if (lastevent != NULL) {
+ if (lastevent != NULL ) {
freeevent(lastevent);
lastevent = NULL;
}
@@ -33,8 +39,8 @@ static void interruptcallback(char* handle) {
VXI11Context* glue_open(char* address, char* device) {
VXI11Context* context = malloc(sizeof(VXI11Context));
- if (context == NULL)
- return NULL;
+ if (context == NULL )
+ return NULL ;
int err = vxi11_open(context, address, device);
@@ -51,7 +57,7 @@ int glue_stop_interrupt_server() {
int ret = vxi11_stop_interrupt_server();
Event* event = NULL;
// clear everything that is left over
- while ((event = (Event*) g_async_queue_try_pop(interruptqueue)) != NULL) {
+ while ((event = (Event*) g_async_queue_try_pop(interruptqueue)) != NULL ) {
freeevent(event);
}
freelast();
@@ -60,17 +66,30 @@ int glue_stop_interrupt_server() {
return ret;
}
-char* glue_wait_for_interrupt() {
- if (interruptqueue)
- return NULL;
- GTimeVal timeout;
- g_get_current_time(&timeout);
- g_time_val_add(&timeout, 2500);
- freelast();
- lastevent = (Event*) g_async_queue_timed_pop(interruptqueue, &timeout);
- if (lastevent != NULL) {
+char* glue_wait_for_interrupt(unsigned int timeout) {
+ if (interruptqueue == NULL ) {
+#ifdef DEBUG
+ printf("interrupt queue is null!\n");
+#endif
+ return NULL ;
+ }
+
+ // if we have a timeout pop with a time out
+ // otherwise block until an interrupt happens
+ if (timeout > 0) {
+ GTimeVal whentotimeout;
+ g_get_current_time(&whentotimeout);
+ g_time_val_add(&whentotimeout, timeout * 1000);
+ freelast();
+ lastevent = (Event*) g_async_queue_timed_pop(interruptqueue, &whentotimeout);
+ }
+ else {
+ lastevent = (Event*) g_async_queue_pop(interruptqueue);
+ }
+
+ if (lastevent != NULL ) {
return lastevent->handle;
}
else
- return NULL;
+ return NULL ;
}
diff --git a/vxi11_server.c b/vxi11_server.c
index d374f3a..34e2919 100644
--- a/vxi11_server.c
+++ b/vxi11_server.c
@@ -67,7 +67,7 @@ static bool isValidLink(int linkid) {
#endif
return false;
}
- return links[linkid] != NULL;
+ return links[linkid] != NULL ;
}
// test if a link has expired, this is to avoid dead locks
@@ -126,7 +126,7 @@ static void freelink(ActiveLink* link) {
if (globals.Remote.vxi_connections == 0) {
// cancel any remaining panel locks
- globals.Remote.vxi_panel_lock = 0;
+ globals.Remote.vxi_panel_lock = 0;
}
#ifdef DEBUG
@@ -145,7 +145,7 @@ static void freelink(ActiveLink* link) {
void vxi11_deadsocketcallback(int socket) {
int linkid;
for (linkid = 0; linkid < SIZEOFARRAY(links); linkid++) {
- if (links[linkid] != NULL) {
+ if (links[linkid] != NULL ) {
if (links[linkid]->sock == socket) {
#ifdef DEBUG
printf("Freeing link %d, socket died\n", linkid);
@@ -199,15 +199,15 @@ create_link_1_svc(Create_LinkParms *argp, struct svc_req *rqstp) {
}
else {
ActiveLink* link = g_malloc(sizeof(ActiveLink));
- if (link == NULL) {
+ if (link == NULL ) {
result.error = ERR_OUTOFRESOURCES;
}
else {
int linkid;
for (linkid = 0; linkid < SIZEOFARRAY(links); linkid++) {
- if (links[linkid] != NULL) // clean up any dead links
+ if (links[linkid] != NULL ) // clean up any dead links
linkexpired(links[linkid]);
- if (links[linkid] == NULL) {
+ if (links[linkid] == NULL ) {
links[linkid] = link;
break;
}
@@ -262,7 +262,7 @@ device_write_1_svc(Device_WriteParms *argp, struct svc_req *rqstp) {
printf("\n");
printf("got <<%s>> (reported length %d)on link %d.\n", str, (int) argp->data.data_len, (int) argp->lid);
#endif
- Parser_main(str, 0, GPIB_and_VXI_start_query_response, NULL);
+ Parser_main(str, 0, GPIB_and_VXI_start_query_response, NULL );
g_free(str);
result.size = argp->data.data_len;
}
@@ -278,7 +278,7 @@ device_read_1_svc(Device_ReadParms *argp, struct svc_req *rqstp) {
#endif
// this free's the data from the last call
- if (result.data.data_val != NULL)
+ if (result.data.data_val != NULL )
g_free(result.data.data_val);
memset(&result, 0, sizeof(result));
@@ -292,7 +292,7 @@ device_read_1_svc(Device_ReadParms *argp, struct svc_req *rqstp) {
}
else {
touchlink(argp->lid);
- if (globals.Registers.pending_output_message != NULL) {
+ if (globals.Registers.pending_output_message != NULL ) {
result.data.data_len = strlen(globals.Registers.pending_output_message);
result.data.data_val = globals.Registers.pending_output_message;
globals.Registers.pending_output_message = NULL;
@@ -456,9 +456,9 @@ device_unlock_1_svc(Device_Link *argp, struct svc_req *rqstp) {
void vxi11_fireinterrupt() {
#ifdef DEBUG
- printf("vxi11_fireinterrupt()\n");
+ printf("vxi11_fireinterrupt()\n");
#endif
- if (intclient != NULL) {
+ if (intclient != NULL ) {
Device_SrqParms params;
params.handle.handle_val = inthandler;
params.handle.handle_len = strlen(inthandler);
@@ -476,18 +476,23 @@ device_enable_srq_1_svc(Device_EnableSrqParms *argp, struct svc_req *rqstp) {
result.error = ERR_INVALIDLINKINDENTIFIER;
else {
touchlink(argp->lid);
- if (inthandler != NULL) {
+ if (inthandler != NULL ) {
g_free(inthandler);
inthandler = NULL;
}
if (argp->enable) {
- if (argp->handle.handle_val != NULL) {
+ if (argp->handle.handle_val != NULL ) {
inthandler = g_strdup(argp->handle.handle_val);
#ifdef DEBUG
printf("Interrupt handle set to %s\n", inthandler);
#endif
}
}
+#ifdef DEBUG
+ else {
+ printf("Interrupts disabled\n");
+ }
+#endif
result.error = 0;
intenabled = argp->enable;
}
@@ -546,7 +551,7 @@ create_intr_chan_1_svc(Device_RemoteFunc *argp, struct svc_req *rqstp) {
// if a client had an interrupt channel and died without closing it
// we need to clean it up to avoid a deadlock
static struct rpc_err err;
- if (intclient != NULL) {
+ if (intclient != NULL ) {
clnt_geterr(intclient, &err);
if (err.re_errno != 0) {
#ifdef DEBUG
@@ -559,7 +564,7 @@ create_intr_chan_1_svc(Device_RemoteFunc *argp, struct svc_req *rqstp) {
if (argp->progFamily != DEVICE_TCP || argp->progNum != DEVICE_INTR || argp->progVers != DEVICE_INTR_VERSION)
result.error = ERR_OPERATIONNOTSUPPORTED;
- else if (intclient != NULL) {
+ else if (intclient != NULL ) {
result.error = ERR_CHANNELALREADYESTABLISHED;
}
else {
@@ -569,7 +574,7 @@ create_intr_chan_1_svc(Device_RemoteFunc *argp, struct svc_req *rqstp) {
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) {
+ if (clnt == NULL ) {
#ifdef DEBUG
printf("Couldn't create interrupt channel client\n");
#endif
@@ -592,7 +597,7 @@ destroy_intr_chan_1_svc(void *argp, struct svc_req *rqstp) {
#ifdef DEBUG
printf("destroy_intr_chan_1_svc()\n");
#endif
- if (intclient == NULL) {
+ if (intclient == NULL ) {
result.error = ERR_CHANNELNOTESTABLISHED;
}
else {