From: Robert Pluim <rpluim@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: emacs-27 d66331a: Don't build the Gnulib 'utimens' module on MinGW
Date: Tue, 24 Mar 2020 18:07:13 +0100 [thread overview]
Message-ID: <m2blolhebi.fsf@gmail.com> (raw)
In-Reply-To: <83lfnrax0r.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 23 Mar 2020 17:52:52 +0200")
>>>>> On Mon, 23 Mar 2020 17:52:52 +0200, Eli Zaretskii <eliz@gnu.org> said:
>> From: Robert Pluim <rpluim@gmail.com>
>> Cc: Eli Zaretskii <eliz@gnu.org>
>> Date: Mon, 23 Mar 2020 16:26:24 +0100
>>
>> Apropos: we explicitly donʼt use the gnulib 'select' module, even
>> though it looks like on MSWindows it handles both sockets and
>> pipes. What functionality is it missing?
Eli> SIGCHLD and C-g interrupts, I guess. Maybe something else as well, I
Eli> don't remember.
In that case I should go the other direction. How about the following
to remove the 1-char readahead for sockets (which then allows us to
enable datagram sockets on MSWindows).
modified src/w32.c
@@ -8798,6 +8798,43 @@ _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)
+ {
+ do
+ {
+ rc = WaitForSingleObject (hEv, 500);
+ Sleep (5);
+ } while (rc == WAIT_TIMEOUT
+ && cp->status != STATUS_READ_ERROR
+ && cp->char_avail);
+ 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)
{
@@ -8923,10 +8960,6 @@ sys_read (int fd, char * buffer, unsigned int count)
return -1;
case STATUS_READ_SUCCEEDED:
- /* consume read-ahead char */
- *buffer++ = cp->chr;
- count--;
- nchars++;
cp->status = STATUS_READ_ACKNOWLEDGED;
ResetEvent (cp->char_avail);
modified 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);
modified src/w32proc.c
@@ -1225,7 +1225,10 @@ 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);
+ if (fd_info[cp->fd].flags & FILE_SOCKET)
+ rc = _sys_wait_readable (cp->fd);
+ else
+ rc = _sys_read_ahead (cp->fd);
/* Don't bother waiting for the event if we already have been
told to exit by delete_child. */
next prev parent reply other threads:[~2020-03-24 17:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200323143828.31224.77075@vcs0.savannah.gnu.org>
[not found] ` <20200323143829.ED56720E43@vcs0.savannah.gnu.org>
2020-03-23 15:26 ` emacs-27 d66331a: Don't build the Gnulib 'utimens' module on MinGW Robert Pluim
2020-03-23 15:52 ` Eli Zaretskii
2020-03-24 17:07 ` Robert Pluim [this message]
2020-03-24 18:56 ` Eli Zaretskii
2020-03-24 20:31 ` Robert Pluim
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=m2blolhebi.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.