From: Ahmad Gani <reyuki@gnuweeb.org>
To: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Cc: Ammar Faizi <ammarfaizi2@gnuweeb.org>,
"GNU/Weeb Mailing List" <gwml@vger.gnuweeb.org>
Subject: Re: [PATCH gwproxy v8 2/2] gwproxy: refactor code base to add experimental raw DNS backend
Date: Sat, 6 Sep 2025 18:27:47 +0700 [thread overview]
Message-ID: <CAADvAgpOzC_VFH0O8KD_vWzFv27JFxbW13yOrfWj8zD5bbFNSg@mail.gmail.com> (raw)
In-Reply-To: <CAADvAgrjW-yAOoXU5RJpAsbLiZdHbjJHNJqeEM1gMxF3ZkseRA@mail.gmail.com>
On Sat, Sep 6, 2025 at 11:32 AM Ahmad Gani wrote:
> On Fri, Sep 5, 2025 at 11:26 PM Alviro Iskandar Setiawan wrote:
> >> + txid = (uint16_t)rand();
> >
> > Why do you use a random number for the txid? I don't think rand()
> > guarantees uniqueness. Also, I don't find the srand() call anywhere.
> > That's equivalent to having srand(1).
> >
> > What about using a simple incrementing counter instead (which
> > guarantees the uniqueness)?
> > It will indeed reset after 65535, but that should give enough room to
> > complete prior DNS requests first. With a simple counter, the reuse of
> > an ID will always be 65535 queries away.
>
> Without calling srand, it still generates random numbers, so I thought it
> was fine. But I agree with your suggestion—an incrementing counter is
> better, because randomness doesn’t guarantee uniqueness and is more
> likely to cause collisions than a counter.
(( I'll finish this first before working on the single UDP socket model. ))
If it's incremented until it is recycled by itself, does it still need to
be atomic? I'm considering adding _Atomic because the data probably will
be accessed and incremented at the same time from multiple workers.
--
Ahmad Gani
next prev parent reply other threads:[~2025-09-06 11:28 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 7:55 [PATCH gwproxy v8 0/2] Initial work on integration of DNS parser lib in gwproxy Ahmad Gani
2025-08-29 7:55 ` [PATCH gwproxy v8 1/2] dnsparser: Add dns parser code Ahmad Gani
2025-08-29 7:55 ` [PATCH gwproxy v8 2/2] gwproxy: refactor code base to add experimental raw DNS backend Ahmad Gani
2025-09-05 16:26 ` Alviro Iskandar Setiawan
2025-09-06 4:32 ` Ahmad Gani
2025-09-06 5:16 ` Ahmad Gani
2025-09-06 6:17 ` Ahmad Gani
2025-09-06 6:48 ` Ahmad Gani
2025-09-06 7:02 ` Alviro Iskandar Setiawan
2025-09-06 6:47 ` Alviro Iskandar Setiawan
2025-09-09 2:38 ` reyuki
2025-09-06 11:27 ` Ahmad Gani [this message]
2025-09-06 12:01 ` Alviro Iskandar Setiawan
2025-09-06 12:58 ` Ahmad Gani
2025-09-06 13:30 ` Alviro Iskandar Setiawan
2025-09-06 13:44 ` Alviro Iskandar Setiawan
2025-09-06 14:26 ` Ahmad Gani
2025-09-06 14:30 ` Alviro Iskandar Setiawan
2025-09-07 4:22 ` Ammar Faizi
2025-09-07 5:57 ` Ammar Faizi
2025-09-07 6:39 ` Ahmad Gani
2025-09-07 6:40 ` Ahmad Gani
2025-09-07 6:43 ` Ammar Faizi
2025-09-07 7:06 ` Ammar Faizi
2025-09-07 7:17 ` Ahmad Gani
2025-09-07 9:52 ` Ahmad Gani
2025-09-07 10:19 ` Ammar Faizi
2025-09-07 10:36 ` Ahmad Gani
2025-09-06 7:14 ` Alviro Iskandar Setiawan
2025-09-06 7:21 ` Ahmad Gani
2025-09-06 7:47 ` Alviro Iskandar Setiawan
2025-09-06 11:01 ` Ahmad Gani
2025-09-05 9:18 ` [PATCH gwproxy v8 0/2] Initial work on integration of DNS parser lib in gwproxy Ammar Faizi
2025-09-05 9:34 ` Alviro Iskandar Setiawan
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAADvAgpOzC_VFH0O8KD_vWzFv27JFxbW13yOrfWj8zD5bbFNSg@mail.gmail.com \
--to=reyuki@gnuweeb.org \
--cc=alviro.iskandar@gnuweeb.org \
--cc=ammarfaizi2@gnuweeb.org \
--cc=gwml@vger.gnuweeb.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox