From: Eric Wong <e@80x24.org>
To: raindrops-public@bogomips.org
Cc: Eric Wong <e@80x24.org>
Subject: [PATCH] linux_inet_diag: clarify *fprintf usage without GVL
Date: Wed, 14 Jan 2015 00:25:12 +0000 [thread overview]
Message-ID: <1421195112-22633-1-git-send-email-e@80x24.org> (raw)
A reviewer may wonder why fprintf is chosen instead of rb_warn,
so make it clear we're outside of the GVL when spewing the
warning message and cannot use most rb_* functions.
---
ext/raindrops/linux_inet_diag.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/ext/raindrops/linux_inet_diag.c b/ext/raindrops/linux_inet_diag.c
index fa8de03..5f21295 100644
--- a/ext/raindrops/linux_inet_diag.c
+++ b/ext/raindrops/linux_inet_diag.c
@@ -1,4 +1,5 @@
#include <ruby.h>
+#include <stdarg.h>
#ifdef HAVE_RUBY_ST_H
# include <ruby/st.h>
#else
@@ -213,8 +214,14 @@ static const char *addr_any(sa_family_t family)
return ipv6;
}
-static void bug_warn(void)
+static void bug_warn_nogvl(const char *fmt, ...)
{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+
fprintf(stderr, "Please report how you produced this at "\
"raindrops-public@bogomips.org\n");
fflush(stderr);
@@ -263,8 +270,7 @@ static struct listen_stats *stats_for(st_table *table, struct inet_diag_msg *r)
assert(0 && "unsupported address family, could that be IPv7?!");
}
if (rc != 0) {
- fprintf(stderr, "BUG: getnameinfo: %s\n", gai_strerror(rc));
- bug_warn();
+ bug_warn_nogvl("BUG: getnameinfo: %s\n", gai_strerror(rc));
*key = 0;
}
@@ -296,8 +302,7 @@ static struct listen_stats *stats_for(st_table *table, struct inet_diag_msg *r)
addr_any(sa.ss.ss_family),
ntohs(r->id.idiag_sport));
if (n <= 0) {
- fprintf(stderr, "BUG: snprintf: %d\n", n);
- bug_warn();
+ bug_warn_nogvl("BUG: snprintf: %d\n", n);
}
if (st_lookup(table, (st_data_t)key, (st_data_t *)&stats))
return stats;
--
EW
reply other threads:[~2015-01-14 0:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/raindrops/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1421195112-22633-1-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=raindrops-public@bogomips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/raindrops.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).