raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH] linux_inet_diag: avoid errors for users compiling w/o assertions
@ 2023-09-30 23:26 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2023-09-30 23:26 UTC (permalink / raw)
  To: raindrops-public

We should warn gracefully when we hit IPv7+ or whatever...
---
 ext/raindrops/linux_inet_diag.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/ext/raindrops/linux_inet_diag.c b/ext/raindrops/linux_inet_diag.c
index e4050cb..6d421e7 100644
--- a/ext/raindrops/linux_inet_diag.c
+++ b/ext/raindrops/linux_inet_diag.c
@@ -235,7 +235,9 @@ static struct listen_stats *stats_for(st_table *table, struct inet_diag_msg *r)
 		break;
 		}
 	default:
-		assert(0 && "unsupported address family, could that be IPv7?!");
+		fprintf(stderr, "unsupported .idiag_family: %u\n",
+			(unsigned)r->idiag_family);
+		return NULL; /* can't raise w/o GVL */
 	}
 	if (!inet_ntop(r->idiag_family, src, host, hostlen)) {
 		bug_warn_nogvl("BUG: inet_ntop: %s\n", strerror(errno));
@@ -255,7 +257,8 @@ static struct listen_stats *stats_for(st_table *table, struct inet_diag_msg *r)
 		port = host + hostlen + 2;
 		break;
 	default:
-		assert(0 && "unsupported address family, could that be IPv7?!");
+		assert(0 && "should never get here (returned above)");
+		abort();
 	}
 
 	n = snprintf(port, portlen, "%u", ntohs(r->id.idiag_sport));
@@ -300,12 +303,14 @@ static struct listen_stats *stats_for(st_table *table, struct inet_diag_msg *r)
 static void table_incr_active(st_table *table, struct inet_diag_msg *r)
 {
 	struct listen_stats *stats = stats_for(table, r);
+	if (!stats) return;
 	++stats->active;
 }
 
 static void table_set_queued(st_table *table, struct inet_diag_msg *r)
 {
 	struct listen_stats *stats = stats_for(table, r);
+	if (!stats) return;
 	stats->listener_p = 1;
 	stats->queued += r->idiag_rqueue;
 }

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-30 23:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-30 23:26 [PATCH] linux_inet_diag: avoid errors for users compiling w/o assertions Eric Wong

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).