[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/5] Improve portability (particularly for Woe32)
From: |
Georgiy Tugai |
Subject: |
Re: [PATCH 2/5] Improve portability (particularly for Woe32) |
Date: |
Sun, 28 Mar 2021 09:39:16 +0000 |
Thanks for pointing that out.
I assume that this patch is not the place to rewrite the MI I/O subsystem;
for this first portability pass, I would accept requiring --disable-mi on
Windows.
Should I leave the HAVE_FCNTL ifdefs in, or no?
> Hi,
>
> Regarding this patch:
>
> @@ -167,6 +168,7 @@ pk_mi_send_frame_msg (const char payload)
> / Set fd to non-blocking and return old flags or -1 on error. */static int
> pk_mi_fd_set_nonblocking (int fd)
> {
> +#if defined HAVE_FCNTL
> int flags = fcntl (fd, F_GETFL, 0);
>
> if (flags >= 0 && (flags & O_NONBLOCK) == 0)
> @@ -179,16 +181,21 @@ static int pk_mi_fd_set_nonblocking (int fd)
> perror ("fcntl");
>
> return flags;
> +#else
>
> - return 0;
> +#endif
> }
>
> Gnulib has support for non-blocking sockets also on native Windows;
> you need the 'nonblocking' module for this.
>
> However, the 'select' module has problems: It can happen (on Windows)
> that select() reports that a file descriptor has data to be read when
> it doesn't, or vice versa. Especially for pipes.
>
> The approach I would recommend to avoid this is to use multithreading:
> use an extra thread for the MI I/O, that only uses read() and write(),
> no select() nor poll(). At least on native Windows. (That's also how
> the Gnulib modules 'pipe-filter-ii' and 'pipe-filter'gi' operate.)
>
> Bruno
>