diff --git a/lib/connection.c b/lib/connection.c index 21708e4..5491073 100644 --- a/lib/connection.c +++ b/lib/connection.c @@ -90,7 +90,7 @@ static int __conn_read(conn_t *co, void *buf, size_t buf_len) int rfd = SSL_get_fd(co->ssl), r; fd_set readset; - fprintf(stderr, "\tListening ... on %s\n", co->uuid); + //fprintf(stderr, "\tListening ... on %s\n", co->uuid); /* get prepare to select */ FD_ZERO(&readset); FD_SET(rfd, &readset); @@ -1265,7 +1265,12 @@ static int __default_msg_return(void *cctx, sexp_t *sx) usrtc_delete(chan->msgs_tree, &(smsg->pendingq_node)); pthread_rwlock_unlock(&(chan->msglock)); } - pthread_mutex_unlock(&(smsg->wait)); + if(smsg->flags & ESXMSG_PENDING) pthread_mutex_unlock(&(smsg->wait)); + else { + /* nobody want it */ + destroy_sexp(smsg->initial_sx); + __destroy_msg(smsg); + } } __finish: diff --git a/lib/message.c b/lib/message.c index 0c2bd0c..8f41c3c 100644 --- a/lib/message.c +++ b/lib/message.c @@ -231,8 +231,10 @@ static int __msg_reply(sxmsg_t *msg, sexp_t *sx, struct timespec *tio, int opcod else pthread_mutex_timedlock(&(msg->wait), tio); } - if(tio && (msg->flags & ESXMSG_PENDING)) + if(tio && (msg->flags & ESXMSG_PENDING)) { + msg->flags &= ~ESXMSG_PENDING; /* we will not wait for it */ return SXOTIMEDOUT; + } r = msg->opcode;