diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2018-09-26 21:52:17 +0200 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2018-09-26 21:52:17 +0200 |
commit | 8ee5d4b415403d57a0669be5fa7605491b988c74 (patch) | |
tree | 348e2ce9cf4a3cbc03bb900c7331a3dd09c52991 | |
parent | ca925e8b5231d96f93b1b8513b9348fdec8c1071 (diff) | |
download | librb-8ee5d4b415403d57a0669be5fa7605491b988c74.tar.gz librb-8ee5d4b415403d57a0669be5fa7605491b988c74.tar.bz2 librb-8ee5d4b415403d57a0669be5fa7605491b988c74.zip |
fix: posix function may return EINTR instead of ECANCELED after rb_stop()
-rw-r--r-- | rb.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -939,6 +939,12 @@ static long rb_recvt if (sact == -1) { trace(("e/select() %s", strerror(errno))); + + if (rb->force_exit == 1) + { + errno = ECANCELED; + } + pthread_mutex_unlock(&rb->lock); trace(("i/rb unlock")); return -1; @@ -1441,10 +1447,23 @@ long rb_sendt if (sact == -1) { trace(("e/select() %s", strerror(errno))); + + if (rb->force_exit == 1) + { + /* + * if select was interrupted by us, overwrite errno to + * ECANCELED, or else it might be EINTR, which may be + * missleading for user. + */ + + errno = ECANCELED; + } + pthread_mutex_unlock(&rb->lock); trace(("i/rb unlock")); pthread_mutex_unlock(&rb->wlock); trace(("i/write unlock")); + return -1; } |