ruby-changes:39698
From: nobu <ko1@a...>
Date: Mon, 7 Sep 2015 00:27:38 +0900 (JST)
Subject: [ruby-changes:39698] nobu:r51779 (trunk): thread_pthread.c: async_bug_fd
nobu 2015-09-07 00:27:25 +0900 (Mon, 07 Sep 2015) New Revision: 51779 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51779 Log: thread_pthread.c: async_bug_fd * thread_pthread.c (async_bug_fd): show failed file descriptor too. Modified files: trunk/thread_pthread.c Index: thread_pthread.c =================================================================== --- thread_pthread.c (revision 51778) +++ thread_pthread.c (revision 51779) @@ -1285,6 +1285,18 @@ static struct { https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1285 {-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(volatil https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1318 #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) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1370 #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, cons https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1385 *fdp = -1; if (close(fd) < 0) { - rb_async_bug_errno(msg, errno); + async_bug_fd(msg, errno, fd); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/