* [PATCH] linux_inet_diag: avoid errors for users compiling w/o assertions
@ 2023-09-30 23:26 Eric Wong
2024-03-24 0:26 ` [PATCH v2] " Eric Wong
0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread
* [PATCH v2] linux_inet_diag: avoid errors for users compiling w/o assertions
2023-09-30 23:26 [PATCH] linux_inet_diag: avoid errors for users compiling w/o assertions Eric Wong
@ 2024-03-24 0:26 ` Eric Wong
0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2024-03-24 0:26 UTC (permalink / raw)
To: raindrops-public
We should warn gracefully when we hit IPv7+ or whatever...
---
Rebased against khashl changes
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 d0638d7..058936b 100644
--- a/ext/raindrops/linux_inet_diag.c
+++ b/ext/raindrops/linux_inet_diag.c
@@ -208,7 +208,9 @@ static struct listen_stats *stats_for(addr2stats *a2s, 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));
@@ -228,7 +230,8 @@ static struct listen_stats *stats_for(addr2stats *a2s, 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));
@@ -278,12 +281,14 @@ static struct listen_stats *stats_for(addr2stats *a2s, struct inet_diag_msg *r)
static void table_incr_active(addr2stats *a2s, struct inet_diag_msg *r)
{
struct listen_stats *stats = stats_for(a2s, r);
+ if (!stats) return;
++stats->active;
}
static void table_set_queued(addr2stats *a2s, struct inet_diag_msg *r)
{
struct listen_stats *stats = stats_for(a2s, r);
+ if (!stats) return;
stats->listener_p = 1;
stats->queued += r->idiag_rqueue;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-24 0:26 UTC | newest]
Thread overview: 2+ messages (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
2024-03-24 0:26 ` [PATCH v2] " 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).