From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: ai_flags in calls to getaddrinfo, broader call for reproducibility check Date: Mon, 11 Jan 2021 19:42:02 +0100 Message-ID: <8735z748p1.fsf@gmail.com> References: <83sg7mggls.fsf@gnu.org> <83czymc8nq.fsf@gnu.org> <74b7a0a9-0eb3-7944-19d2-f72424ee72d7@dasyatidae.com> <83eeirfqbo.fsf@gnu.org> <87o8hvscfi.fsf@gmail.com> <8335z7fmnz.fsf@gnu.org> <87ft374axc.fsf@gmail.com> <5cb6a0ac-9fe9-bfc2-5642-3423bd043238@dasyatidae.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35354"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Robin Tarsiger Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jan 11 19:44:15 2021 Return-path: Envelope-to: ged-emacs-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 1kz2Ao-00095P-Jj for ged-emacs-devel@m.gmane-mx.org; Mon, 11 Jan 2021 19:44:14 +0100 Original-Received: from localhost ([::1]:39948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kz2An-0001PJ-L2 for ged-emacs-devel@m.gmane-mx.org; Mon, 11 Jan 2021 13:44:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kz28m-0000ew-Vm for emacs-devel@gnu.org; Mon, 11 Jan 2021 13:42:10 -0500 Original-Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:34613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kz28k-0003o7-JV; Mon, 11 Jan 2021 13:42:08 -0500 Original-Received: by mail-wm1-x334.google.com with SMTP id g25so422405wmh.1; Mon, 11 Jan 2021 10:42:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :mime-version; bh=3orxY0wuHr/Lusj0zV8tJqqHIofE0r8oLQ181WXiato=; b=c6AYzjMEMxwAW0fJY1yWcMhGa5UlcekVyfrXNIDwPCXpPZvK29Ro4TL2O/Q2ppNDsv lvVe++0VTdQYZzqdt7BvYcNIWyXGythlf3cm3WIc/D2CLrMq3J687W/hT35/SuY79od5 ja1x4WYef8S9H5vrPzVvXBEErlZBkq8PMb7zjqtZEjqxrAvRFZRPcOyxPDbcUW+cAI4W D9qJrMEfga3hzcltE7319Cq405xQbbU88MofYhepwQCavf+dteFy4qTXXVztvhkuOIEj j6GvKWEY1KSaMweCMcCsou+pgHq4HWtM7bekINm5xwo5/vWMKy+DrZ3Fo7d+wsrreK4t yXRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version; bh=3orxY0wuHr/Lusj0zV8tJqqHIofE0r8oLQ181WXiato=; b=HXIz+75lD5ios4XadGkUAAruRwep1nQ5CCbL5xmG5rsEuwFRvmYjIxAnWoSj2F640f f5MAdiE1B7SCRmoNRKarIFvqOcAzacD16fuRlP5atcxhWPJR8F3oQAYKFuC7qzyUcP2x Qfbx1HMXlZrIKm31qBGNBTXmBA2Fq3/4bVkOf2LFMJltvyJJs/hM81h8aFA0cRiIHZ7o mxGysX5EEf3Ny4dDh3StC1jc62oM/B1fDYj9JXG3OgCMQzz/LEU1Spgo2J0n9slTr8gq 9+Xwu6Lcf73YzyGj8+RZYKQekoYLJDpx75ub+5XBBq2xxIDlRClTlHl8u2A21RA61Esv UETw== X-Gm-Message-State: AOAM530qfruDnnQb0Z5Qhy7pYsTLkbOuDZR2IebRvz2/xdexxE8hT4hp 1t/uCZKkDVceiK3MSgLin2k6cMUBjEM= X-Google-Smtp-Source: ABdhPJy6cv7rC9QBGjeCim4OibCZpNPVSF+KLWBEzCBcRfXuOwKm98Ruls/TYMfNsHzKZ8WBP1djog== X-Received: by 2002:a1c:204e:: with SMTP id g75mr176356wmg.100.1610390524415; Mon, 11 Jan 2021 10:42:04 -0800 (PST) Original-Received: from rltb ([2a01:e34:ecfc:a861:69b6:6aaf:dbd3:8964]) by smtp.gmail.com with ESMTPSA id y63sm262214wmd.21.2021.01.11.10.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 10:42:03 -0800 (PST) In-Reply-To: <5cb6a0ac-9fe9-bfc2-5642-3423bd043238@dasyatidae.com> (Robin Tarsiger's message of "Mon, 11 Jan 2021 12:30:22 -0600") Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=rpluim@gmail.com; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:262928 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Robin Tarsiger writes: > Robert Pluim wrote: >>> There is no _reliable_ way I know of to determine this programmatically, >>> certainly not without sending some probe queries with a high level of >>> specific control over them, and I expect that would be a rather hairy >>> thing to do just for a few tests, and not reasonably maintainable. >>=20 >> (require 'dns) >> (skip-unless (dns-query "google.com" 'AAAA)) > > Oh, wow, there's _already_ a dns.el in core? Huh. Well, that obviates > my primary concerns about doing direct DNS probes, provided it works > and is a reasonable thing to load for the test suite otherwise... > >> and then do the network-lookup-address-info tests (although on Windows >> this depends on DNS over TCP working, > > Ergh. I just checked with `dig +tcp` against my crappy ISP CPE and it > rejects the connection, which seems like anecdata toward that failing > in a lot of configurations. > Yep. > Do you happen to know OTTOYH _why_ datagram sockets aren't supported > in Emacs on Windows to start with... ? > Because the select implementation on windows does a one-byte readahead to see if data is available, which breaks UDP. I had a patch at one point to fix this, but I remember Eli not being very enthusiastic about it. I=CA=BCve attached what I think is the right version below (my windows box died, so I can't be sure) >> and either /etc/resolv.conf or a >> working nslookup). > The latter should at least be stock on Windows AFAIK. I'd forgotten that > it shows the list of resolver addresses too. It=CA=BCs my least preferred option, it depends on running an external binary and parsing the output, which is fragile. Robert --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=sys_select_improvement.patch diff --git i/src/w32.c w/src/w32.c index 698e10e234..d14abc2f8e 100644 --- i/src/w32.c +++ w/src/w32.c @@ -8798,6 +8798,37 @@ _sys_wait_accept (int fd) return cp->status; } +int +_sys_wait_readable (int fd) +{ + HANDLE hEv; + child_process * cp; + int rc; + + if (fd < 0 || fd >= MAXDESC) + return STATUS_READ_ERROR; + + cp = fd_info[fd].cp; + + if (cp == NULL || cp->fd != fd || cp->status != STATUS_READ_READY) + return STATUS_READ_ERROR; + + cp->status = STATUS_READ_FAILED; + + hEv = pfn_WSACreateEvent (); + rc = pfn_WSAEventSelect (SOCK_HANDLE (fd), hEv, FD_READ); + if (rc != SOCKET_ERROR) + { + rc = WaitForSingleObject (hEv, INFINITE); + pfn_WSAEventSelect (SOCK_HANDLE (fd), NULL, 0); + if (rc == WAIT_OBJECT_0) + cp->status = STATUS_READ_SUCCEEDED; + } + pfn_WSACloseEvent (hEv); + + return cp->status; +} + int _sys_wait_connect (int fd) { diff --git i/src/w32.h w/src/w32.h index cf1dadf64c..4a6b7c4b53 100644 --- i/src/w32.h +++ w/src/w32.h @@ -175,6 +175,7 @@ #define FILE_SERIAL 0x0800 extern int _sys_read_ahead (int fd); extern int _sys_wait_accept (int fd); +extern int _sys_wait_readable (int fd); extern int _sys_wait_connect (int fd); extern HMODULE w32_delayed_load (Lisp_Object); diff --git i/src/w32proc.c w/src/w32proc.c index de33726905..1e109669f7 100644 --- i/src/w32proc.c +++ w/src/w32proc.c @@ -1225,7 +1225,7 @@ reader_thread (void *arg) else if (cp->fd >= 0 && (fd_info[cp->fd].flags & FILE_LISTEN) != 0) rc = _sys_wait_accept (cp->fd); else - rc = _sys_read_ahead (cp->fd); + rc = _sys_wait_readable (cp->fd); /* Don't bother waiting for the event if we already have been told to exit by delete_child. */ --=-=-=--