summaryrefslogtreecommitdiff
path: root/libvxi11client/libvxi11client.c
diff options
context:
space:
mode:
Diffstat (limited to 'libvxi11client/libvxi11client.c')
-rw-r--r--libvxi11client/libvxi11client.c69
1 files changed, 59 insertions, 10 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c
index 2f36147..b212487 100644
--- a/libvxi11client/libvxi11client.c
+++ b/libvxi11client/libvxi11client.c
@@ -30,6 +30,9 @@ static GThread* interruptthread;
static bool interruptchannelopen = false;
static void killinterruptthreadandwait() {
+#ifdef DEBUG
+ printf("Waiting for interrupt thread to die\n");
+#endif
interruptchannelopen = false;
g_thread_join(interruptthread);
interruptthread = NULL;
@@ -361,27 +364,46 @@ static gpointer interruptthreadfunc(gpointer data) {
}
*((unsigned int*) data) = transp->xp_port;
- int no_of_fds;
int i;
- struct pollfd pollfd_set[1024];
+ struct pollfd *my_pollfd = NULL;
+ int last_max_pollfd = 0;
- //svc_run();
- // stolen from: http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.commtechref%2Fdoc%2Fcommtrf1%2Fsvc_getreq_poll.htm
while (interruptchannelopen) {
- /* initialize the pollfd_set array and
- get no of file descriptors in "no_of_fds"*/
+ int max_pollfd = svc_max_pollfd;
+ 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) {
+ break;
+ }
+
+ my_pollfd = new_pollfd;
+ last_max_pollfd = max_pollfd;
+ }
- /* Keep polling on file descriptors */
- switch (i = poll(pollfd_set, no_of_fds, -1)) {
+ for (i = 0; i < max_pollfd; ++i) {
+ my_pollfd[i].fd = svc_pollfd[i].fd;
+ my_pollfd[i].events = svc_pollfd[i].events;
+ my_pollfd[i].revents = 0;
+ }
+
+ switch (i = poll(my_pollfd, max_pollfd, VXI11_DEFAULT_TIMEOUT)) {
case -1:
+ break;
case 0:
continue;
default:
- /* Handle RPC request on each file descriptor */
- svc_getreq_poll(pollfd_set, i);
+ svc_getreq_poll(my_pollfd, i);
+ continue;
}
+ break;
}
+ free(my_pollfd);
+
#ifdef DEBUG
printf("Interrupt channel thread ended\n");
#endif
@@ -449,6 +471,33 @@ int vxi11_destroy_intr_chan() {
}
/**
+ * enable interrupts
+ */
+
+int vxi11_enable_srq(bool enable, char* handle) {
+ if (!interruptchannelopen)
+ return 0;
+ else if (clnt == NULL)
+ return 0;
+ else if (interruptthread == NULL)
+ return 0;
+
+ Device_EnableSrqParms params = { .lid = link, .enable = enable };
+ if (handle != NULL) {
+ params.handle.handle_val = handle;
+ params.handle.handle_len = strlen(handle);
+ }
+ Device_Error* error = device_enable_srq_1(&params, clnt);
+ if (error != NULL && error->error == 0) {
+ return 1;
+ }
+ else if (error == NULL)
+ return 0;
+ else
+ return -(error->error);
+}
+
+/**
* send an abort to the connected device
*/