diff --git a/test/threadqueue.c b/test/threadqueue.c index a336cc8..9359b36 100644 --- a/test/threadqueue.c +++ b/test/threadqueue.c @@ -18,7 +18,7 @@ void *reader(void *arg) for (i = 0; i < CNT/2; i++) { struct uc_threadmsg *msg; struct my_msg *my; - if (uc_thread_queue_get(&queue, NULL, &msg) != 0) { + if (uc_thread_queue_get(&queue, &msg) != 0) { printf("uc_threadqueue_get failed\n"); return NULL; } diff --git a/test/threadqueue_signal.c b/test/threadqueue_signal.c index 7a95528..0f0b07f 100644 --- a/test/threadqueue_signal.c +++ b/test/threadqueue_signal.c @@ -2,6 +2,7 @@ #include #include #include +#include #include struct uc_threadqueue queue; @@ -17,7 +18,13 @@ void *handler(void *arg) for (;;) { struct uc_threadmsg *msg; struct my_msg *my; - if (uc_thread_queue_get(&queue, NULL, &msg) != 0) { + struct timespec timeout = {5, 0}; + int rc; + rc = uc_thread_queue_tryget(&queue, &timeout, &msg); + if(rc == ETIMEDOUT) { + printf("handler timed out\n"); + continue; + } else if (rc != 0) { printf("uc_threadqueue_get failed\n"); return NULL; } @@ -61,6 +68,7 @@ int main(int argc, char *argv[]) } struct my_msg *msg = malloc(sizeof *msg); msg->sig = sig; + msg->uc_msg.msgtype = 0; uc_thread_queue_add(&queue, msg);