From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher Baines Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Define SO_RCVTIMEO and SO_SNDTIMEO. Date: Sun, 18 Sep 2022 16:11:23 +0200 Message-ID: <87leqgrcsc.fsf@cbaines.net> References: <20220917080512.17824-1-mail@cbaines.net> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9752"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.8.9; emacs 28.1 Cc: guile-devel@gnu.org To: Maxime Devos Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Sep 18 16:13:45 2022 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oZv3J-0002Oy-HS for guile-devel@m.gmane-mx.org; Sun, 18 Sep 2022 16:13:45 +0200 Original-Received: from localhost ([::1]:37182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oZv3H-0000Rp-VQ for guile-devel@m.gmane-mx.org; Sun, 18 Sep 2022 10:13:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZv34-0000Re-TT for guile-devel@gnu.org; Sun, 18 Sep 2022 10:13:30 -0400 Original-Received: from mira.cbaines.net ([2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27]:55113) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oZv33-0007gs-Ec for guile-devel@gnu.org; Sun, 18 Sep 2022 10:13:30 -0400 Original-Received: from localhost (unknown [134.157.22.165]) by mira.cbaines.net (Postfix) with ESMTPSA id A481F27BBE9; Sun, 18 Sep 2022 15:13:27 +0100 (BST) Original-Received: from felis (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 85637154; Sun, 18 Sep 2022 14:13:26 +0000 (UTC) In-reply-to: Received-SPF: pass client-ip=2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27; envelope-from=mail@cbaines.net; helo=mira.cbaines.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:21352 Archived-At: --=-=-= Content-Type: text/plain Thanks for the feedback Maxime, I obviously lost track of some things after letting this patch languish for a while. Maxime Devos writes: > On 17-09-2022 10:05, Christopher Baines wrote: >> + if (ioptname == SO_RCVTIMEO || ioptname == SO_SNDTIMEO) >> + { >> + SCM_ASSERT (scm_is_pair (value), value, SCM_ARG4, FUNC_NAME); > > How about using SCM_ASSERT_TYPE instead to improve the error message a > little? I've switched to using SCM_ASSERT_TYPE now. >> + opt_time.tv_sec = scm_to_ulong (SCM_CAR (value)); >> + opt_time.tv_usec = scm_to_ulong (SCM_CDR (value)); > I think it needs to be documented how to actually use SO_RCVTIMEO / > SO_SNDTIMEO (more specifically, the types). For example, the user > might expect to enter flonums 1.567 as time durations (in seconds) > instead, or a duration from SRFI 19. How is the user supposed to know > the appropriate type, aside from experimenting and reading the source > code? > > Also, it is not documented there is a maximum on the number of > seconds, I recommend to document that there is some limit, or > alternatively clip numbers to the maximum. I've added some documentation now, I'm not sure the interface is perfect, but it should work. >> + optlen = sizeof (opt_time); >> + optval = &opt_time; >> + } >> + > > I think this needs a #if defined(SO_RCVTIMEO) && defined(SO_SNDTIMEO), > for systems that don't have those. Alternatively, if all systems have > those, it seems to me that the #ifdef in I guess it should be conditional, so I've added the if in to getsockopt and setsockopt. >> +#ifdef SO_RCVTIMEO >> + scm_c_define ("SO_RCVTIMEO", scm_from_int (SO_RCVTIMEO)); >> +#endif >> +#ifdef SO_SNDTIMEO >> + scm_c_define ("SO_SNDTIMEO", scm_from_int (SO_SNDTIMEO)); >> +#endif > > can be removed. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmMnJ4NfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh aW5lcy5uZXQACgkQXiijOwuE9XdLpQ/9HjO770CXrWEM/g3ddkKQo9pb380aae6Y pGGd9bvFKT9NNAC0GoPz7k6+GlhzWpRwcMJLAaNRVPxsO/sWY/J9AvSTSqZrO9Bu scQB7rg/Gi3JmWX95YFSvcPIBgOfkbOwxIH47WRglXYDy6ps/BHultYDaObnhOGx U/3e+Idilq58SAlRMRtKP7Ip6hLz+xwZkMv7cKr/2h6Yf0QOQMPj4TDOkui2ufml TEEKqXIy8HaR+R1nyGdraXkUqfQfZgsjQ+frVGshAVSTSrf6bkLPHYia3QU42MBI fYUEKBC/Xm8YucceKsJO6sZISwnOsqcEUG2fSFd/dyEyKosabVNpWW8AoLPPjBEe UK1mc6FpETAzt6AxlPc1a9f9UqziB3UsIbIZVyx1Fwi94u/NaNSPow+K7a+AbTPP hyp7Ra+mJpm7b9cIWW0h88TwiZg02zCpdHeN4OZcVs8R1/8zxzIJnPzATgYrr2O3 RB3Zq3DjJqMwiZVSTe9NEZiBInvBGcGfN8ATKajbnBU4gWksBfsoWfLiiEi/7He+ IA5715nkKfo7Fu8W1pmCQd3Z75wtUfZrThu9pOi5JYq6hUf3AZQFeUsyvaa7s8r8 T9cYUfFoqIEi46Lmg/Syg/r23dlT71dcEPARUXEX439ctFA0J3W3SHUBrxTyXyvJ M+1Hz+oorKU= =VlOp -----END PGP SIGNATURE----- --=-=-=--