diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-06 15:27:25 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-06 15:27:25 +0000 |
commit | 5bed80ee36f92c42b39278d4f1f19fff3c554b34 (patch) | |
tree | 5030cb219b23206405ce11b45dddc8fda26b8b3f | |
parent | 642e7c516d06f3c6e5d923bed3e733dc03aa0d0b (diff) |
thread_pthread.c: async_bug_fd
* thread_pthread.c (async_bug_fd): show failed file descriptor too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | thread_pthread.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index fb76020cc9..9c571c913d 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1285,6 +1285,18 @@ static struct { {-1, -1}, /* low priority */ }; +NORETURN(static void async_bug_fd(const char *mesg, int errno_arg, int fd)); +static void +async_bug_fd(const char *mesg, int errno_arg, int fd) +{ + char buff[64]; + size_t n = strlcpy(buff, mesg, sizeof(buff)); + if (n < sizeof(buff)-3) { + ruby_snprintf(buff, sizeof(buff)-n, "(%d)", fd); + } + rb_async_bug_errno(buff, errno_arg); +} + /* only use signal-safe system calls here */ static void rb_thread_wakeup_timer_thread_fd(volatile int *fdp) @@ -1306,7 +1318,7 @@ rb_thread_wakeup_timer_thread_fd(volatile int *fdp) #endif break; default: - rb_async_bug_errno("rb_thread_wakeup_timer_thread - write", e); + async_bug_fd("rb_thread_wakeup_timer_thread: write", e, fd); } } if (TT_DEBUG) WRITE_CONST(2, "rb_thread_wakeup_timer_thread: write\n"); @@ -1358,7 +1370,7 @@ consume_communication_pipe(int fd) #endif return; default: - rb_async_bug_errno("consume_communication_pipe: read", e); + async_bug_fd("consume_communication_pipe: read", e, fd); } } } @@ -1373,7 +1385,7 @@ close_invalidate(volatile int *fdp, const char *msg) *fdp = -1; if (close(fd) < 0) { - rb_async_bug_errno(msg, errno); + async_bug_fd(msg, errno, fd); } } |