From 40a0e7752935d02c803f1c2efb97322f59aa0433 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 6 Sep 2015 15:27:25 +0000 Subject: 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 --- thread_pthread.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'thread_pthread.c') 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); } } -- cgit v1.2.3