From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server-vie001.gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_DBL_BLOCKED_OPENDNS, URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=new2025; t=1757158104; bh=WKKYWKU15KK4/Fb8+82+q6mD8zXpoJU5pddbF4y/C/g=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type:Content-Transfer-Encoding:Message-ID:Date:From: Reply-To:Subject:To:Cc:In-Reply-To:References:Resent-Date: Resent-From:Resent-To:Resent-Cc:User-Agent:Content-Type: Content-Transfer-Encoding; b=XDQfPcbpNeaAe6JOII12u1l5srB5/YxovSzwtvG2klor1+Yb6o2ZqePPD45YWSV4w S/a2kzxKXCXFk1bKD15U5a66c0/mnsGki28mbn2GjQiBx1jJ0Cu/57bzZ2KpmcyHOM seJ94AxoTuaCGmp/nuXB6yO3MkGRt2X7ndu+ivTjY1HqgYYjnurS9BRMh0JzFgMTzs 89G0McNNtWTCleJjOpy0RGsVTjXG/BRz7dd7bZvW+0SThSdPgP6GTn/qs7lArgEQhx 3C5nR5bG7tNSHL1j/QFtLnAcFRptQsE8sRL57U0AL69d2lmT+e5B9njK/vXBl4ElVv WHZ6lIA97DmOQ== Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id BECC2312798B for ; Sat, 6 Sep 2025 11:28:24 +0000 (UTC) Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-337cc414358so25270801fa.3 for ; Sat, 06 Sep 2025 04:28:24 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCVcuMwngwLyzgaGYHqxZ2ILwVnJYjtag846FxcepsZ/FdOokoDL1/mE7KdAoP112OjkqMK8@vger.gnuweeb.org X-Gm-Message-State: AOJu0Yw9Bk6fHnCZhyPF/gbJobgVL06iu88UgBmJaGY6q/rqkYvdqgO4 2ipNkJLj/LeywhCUd3iZYm2yWRcG4NNePGG8ceglaqYesuRl0dhxbSwuVGD4RG3SmGENi69hHO9 Ly5jhtIA7T2Vka/PbvLDF4D6Gbd+V0yw= X-Google-Smtp-Source: AGHT+IHzr/YVe4YhMhGLQrp7BARjaypomjmYd6s4FN4SESY7YXBLAROnsS8qnaniqtc+3XijR4WSJlrn/1NQaUME+qA= X-Received: by 2002:a2e:ae0a:0:20b0:336:955e:9fcf with SMTP id 38308e7fff4ca-33b4b23335emr5023791fa.9.1757158104194; Sat, 06 Sep 2025 04:28:24 -0700 (PDT) MIME-Version: 1.0 References: <20250829075557.598176-1-reyuki@gnuweeb.org> <20250829075557.598176-3-reyuki@gnuweeb.org> In-Reply-To: From: Ahmad Gani Date: Sat, 6 Sep 2025 18:27:47 +0700 X-Gmail-Original-Message-ID: X-Gm-Features: Ac12FXzhsUN6MoCsGmw5Z70734Ye3m6hIpm75gjFqNNf9XDm9U8pdO4kA2mO1bA Message-ID: Subject: Re: [PATCH gwproxy v8 2/2] gwproxy: refactor code base to add experimental raw DNS backend To: Alviro Iskandar Setiawan Cc: Ammar Faizi , "GNU/Weeb Mailing List" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: On Sat, Sep 6, 2025 at 11:32=E2=80=AFAM Ahmad Gani wrote: > On Fri, Sep 5, 2025 at 11:26=E2=80=AFPM Alviro Iskandar Setiawan wrote: > >> + txid =3D (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=E2=80=94an incrementing counte= r is > better, because randomness doesn=E2=80=99t guarantee uniqueness and is mo= re > 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