summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libvxi11client/libvxi11client.c8
-rw-r--r--libvxi11client/perlbits/perlglue.c13
-rw-r--r--vxi11_server.c2
3 files changed, 11 insertions, 12 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c
index 601e490..c44f086 100644
--- a/libvxi11client/libvxi11client.c
+++ b/libvxi11client/libvxi11client.c
@@ -39,7 +39,7 @@ device_intr_srq_1_svc(Device_SrqParms *argp, struct svc_req *rqstp) {
#endif
if (interruptcallback != NULL ) {
- interruptcallback(argp->handle.handle_val);
+ interruptcallback(g_strndup(argp->handle.handle_val, argp->handle.handle_len));
}
static char * result;
@@ -196,7 +196,7 @@ int vxi11_write(VXI11Context* context, char* data, int len, bool waitlock, bool
Device_WriteParms params = { .lid = context->devicelink, .io_timeout = VXI11_DEFAULT_TIMEOUT, .lock_timeout =
VXI11_DEFAULT_TIMEOUT, .flags = vxi11_generateflags(waitlock, end, false) };
- params.data.data_len = len < 0 ? (strlen(data) + 1) : len;
+ params.data.data_len = len < 0 ? strlen(data) : len;
params.data.data_val = data;
Device_WriteResp* resp = device_write_1(&params, context->clnt);
@@ -497,7 +497,7 @@ static gpointer interruptthreadfunc(gpointer data) {
return NULL ;
}
-int vxi11_start_interrupt_server(void (*callback)(char* handle)) {
+int vxi11_start_interrupt_server(void (*callback)(gchar* handle)) {
interruptcallback = callback;
interruptserverstarted = true;
g_thread_init(NULL );
@@ -617,7 +617,7 @@ int vxi11_enable_srq(VXI11Context* context, bool enable, char* handle) {
if (enable) {
if (handle != NULL ) {
params.handle.handle_val = handle;
- params.handle.handle_len = strlen(handle) + 1;
+ params.handle.handle_len = strlen(handle);
}
}
else {
diff --git a/libvxi11client/perlbits/perlglue.c b/libvxi11client/perlbits/perlglue.c
index 259a652..5c6448b 100644
--- a/libvxi11client/perlbits/perlglue.c
+++ b/libvxi11client/perlbits/perlglue.c
@@ -12,13 +12,13 @@
static GAsyncQueue* interruptqueue;
typedef struct {
- char* handle;
+ gchar* handle;
} Event;
static Event* lastevent = NULL;
+// perl is responsible for freeing the handle
static void freeevent(Event* event) {
- g_free(event->handle);
g_free(event);
}
@@ -29,11 +29,9 @@ static void freelast() {
}
}
-static void interruptcallback(char* handle) {
+static void interruptcallback(gchar* handle) {
Event* event = g_malloc(sizeof(Event));
- int handlelen = strlen(handle);
- event->handle = g_malloc(handlelen + 1);
- strcpy(event->handle, handle);
+ event->handle = handle;
g_async_queue_push(interruptqueue, event);
}
@@ -76,11 +74,12 @@ char* glue_wait_for_interrupt(unsigned int timeout) {
// if we have a timeout pop with a time out
// otherwise block until an interrupt happens
+ freelast();
+
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 {
diff --git a/vxi11_server.c b/vxi11_server.c
index 144141e..398de47 100644
--- a/vxi11_server.c
+++ b/vxi11_server.c
@@ -482,7 +482,7 @@ device_enable_srq_1_svc(Device_EnableSrqParms *argp, struct svc_req *rqstp) {
}
if (argp->enable) {
if (argp->handle.handle_val != NULL ) {
- inthandler = g_strdup(argp->handle.handle_val);
+ inthandler = g_strndup(argp->handle.handle_val, argp->handle.handle_len);
#ifdef DEBUG
printf("Interrupt handle set to %s\n", inthandler);
#endif