Cygwin: FIFO: use a retry loop when opening a writer

There may be short periods when there's no pipe instance available.
Keep trying.
This commit is contained in:
Ken Brown 2019-04-14 19:16:02 +00:00 committed by Corinna Vinschen
parent 6b20be0944
commit c5bc7a8065
1 changed files with 31 additions and 21 deletions

View File

@ -30,6 +30,12 @@ STATUS_PIPE_EMPTY simply means there's no data to be read. */
|| _s == STATUS_PIPE_BROKEN \ || _s == STATUS_PIPE_BROKEN \
|| _s == STATUS_PIPE_EMPTY; }) || _s == STATUS_PIPE_EMPTY; })
#define STATUS_PIPE_NO_INSTANCE_AVAILABLE(status) \
({ NTSTATUS _s = (status); \
_s == STATUS_INSTANCE_NOT_AVAILABLE \
|| _s == STATUS_PIPE_NOT_AVAILABLE \
|| _s == STATUS_PIPE_BUSY; })
fhandler_fifo::fhandler_fifo (): fhandler_fifo::fhandler_fifo ():
fhandler_base (), read_ready (NULL), write_ready (NULL), fhandler_base (), read_ready (NULL), write_ready (NULL),
listen_client_thr (NULL), lct_termination_evt (NULL), nhandlers (0), listen_client_thr (NULL), lct_termination_evt (NULL), nhandlers (0),
@ -543,28 +549,32 @@ fhandler_fifo::open (int flags, mode_t)
listen_client thread is running. Then signal write_ready. */ listen_client thread is running. Then signal write_ready. */
if (writer) if (writer)
{ {
if (!wait (read_ready)) while (1)
{ {
res = error_errno_set; if (!wait (read_ready))
goto out; {
} res = error_errno_set;
NTSTATUS status = open_pipe (); goto out;
if (!NT_SUCCESS (status)) }
{ NTSTATUS status = open_pipe ();
debug_printf ("create of writer failed"); if (NT_SUCCESS (status))
__seterrno_from_nt_status (status); {
res = error_errno_set; set_pipe_non_blocking (get_handle (), true);
goto out; if (!arm (write_ready))
} res = error_set_errno;
else if (!arm (write_ready)) else
{ res = success;
res = error_set_errno; goto out;
goto out; }
} else if (STATUS_PIPE_NO_INSTANCE_AVAILABLE (status))
else Sleep (1);
{ else
set_pipe_non_blocking (get_handle (), true); {
res = success; debug_printf ("create of writer failed");
__seterrno_from_nt_status (status);
res = error_errno_set;
goto out;
}
} }
} }
out: out: