Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-09-16Cygwin: pipe, fifo: Move query_hdl and hdl_cnt_mtx to fhandler_pipe.Takashi Yano
- query_hdl and hdl_cnt_mtx are moved from fhandler_pipe_fifo to fhandler_pipe. Then reader_closed() is changed to virtual and overridden in fhandler_pipe.
2021-09-16Cygwin: pipe: Fix race issue regarding handle count.Takashi Yano
- This patch fixes the race issue in the handle counting to detect closure of read pipe, which is introduced by commit f79a4611. A mutex hdl_cnt_mtx is introduced for this issue.
2021-09-16Cygwin: pipe: Fix error handling in fhandler_pip::create().Takashi Yano
- Currently, error handling in fhandler_pipe::create() is broken. This patch fixes that.
2021-09-16Cygwin: close_all_files: Do not duplicate stderr for write pipe.Takashi Yano
- Currently, the stderr handle is duplicated in close_all_files(). This interferes the handle counting for detecting closure of read pipe, which is introduced by commit f79a4611. This patch stops duplicating stderr handle if it is write pipe.
2021-09-16Cygwin: select: check for negative return from pipe_data_availableKen Brown
Make sure except_ready is set (if except_selected) on a negative return from pipe_data_available.
2021-09-15newlib: sig2str: use __restrictMike Frysinger
This matches the header prototype style and most of newlib, and fixes building with older versions of gcc which only accept the __ form.
2021-09-15libgloss: add missing aclocal.m4 filesMike Frysinger
These subdirs were missing aclocal.m4 files pulling in macros from ../acinclude.m4 which caused some macros to not be expanded. For example, autoconf complains: configure.ac:25: error: possibly undefined macro: LIB_AC_PROG_CC If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. These were generated with aclocal-1.9 as that seems to be what was used in these dirs previously, and with whatever version of autoconf the specific subdir was using. This should minimize diffs.
2021-09-15libgloss: epiphany: rename symbol prefix cache varMike Frysinger
Autoconf emits a warning for this: configure.ac:75: warning: AC_CACHE_VAL(libc_symbol_prefix, ...): suspicious cache-id, must contain _cv_ to be cached Rename the variable to match the naming in libnosys/ subdir.
2021-09-15libgloss: fix AC_LANG_SOURCE warnings w/newer autoconfMike Frysinger
When running autoconf-2.69 in here, we get: configure.ac:57: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body ../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from... ../../lib/autoconf/general.m4:2503: _AC_PREPROC_IFELSE is expanded from... ../../lib/autoconf/general.m4:2518: AC_PREPROC_IFELSE is expanded from... configure.ac:57: the top level configure.ac:61: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body ../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from... ../../lib/autoconf/general.m4:2503: _AC_PREPROC_IFELSE is expanded from... ../../lib/autoconf/general.m4:2518: AC_PREPROC_IFELSE is expanded from... configure.ac:61: the top level Add AC_LANG_PROGRAM wrappings to fix these.
2021-09-15Cygwin: pipes: don't call NtQueryInformationFile on read side of pipesCorinna Vinschen
NtQueryInformationFile hangs if it's called on the read side handle of a pipe while another thread or process is performing a blocking read. Avoid select potentially hanging by calling NtQueryInformationFile only on the write side of the pipe and using PeekNamedPipe otherwise. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-15Cygwin: drop useless method fhandler_base::has_ongoing_ioCorinna Vinschen
This was a remnant of the fhandler_base_overlapped class. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-15Cygwin: pipe: Do not call PeekNamedPipe() if it is not necessary.Takashi Yano
- In pipe_data_available() in select.cc, PeekNamedPipe() call is not needed if WriteQuotaAvailable is non-zero because we already know the write pipe has a space. Therefore, with this patch, PeekNamedPipe() is called only when WriteQuotaAvailable is zero. This makes select() on pipe faster a bit.
2021-09-14Cygwin: document the recent pipe changesKen Brown
2021-09-14Cygwin: pipe: Fix handling of EPIPE and SIGPIPE in raw_write().Takashi Yano
2021-09-14Cygwin: pipe, fifo: Release select_sem semaphore as much as needed.Takashi Yano
- Currently, raw_read(), raw_write() and close() release select_sem unconditionally even if no waiter for select_sem exists. With this patch, only the minimum number of semaphores required is released.
2021-09-14Cygwin: pipe: Use read pipe handle for select() on write pipe.Takashi Yano
- Usually WriteQuotaAvailable retrieved by NtQueryInformationFile() on the write side reflects the space available in the inbound buffer on the read side. However, if a pipe read is currently pending, WriteQuotaAvailable on the write side is decremented by the number of bytes the read side is requesting. So it's possible (even likely) that WriteQuotaAvailable is 0, even if the inbound buffer on the read side is not full. This can lead to a deadlock situation: The reader is waiting for data, but select on the writer side assumes that no space is available in the read side inbound buffer. Currently, to avoid this stuation, read() does not request larger block than pipe size - 1. However, this mechanism does not take effect if the reader side is non-cygwin app. The only reliable information is available on the read side, so fetch info from the read side via the pipe-specific query handle (query_hdl) introduced. If the query_hdl (read handle) is kept in write side, writer can not detect closure of read pipe. Therefore, raw_write() counts write handle and query_hdl. If they are equal, only the pairs of write handle and query_hdl are alive. In this case, raw_write() returns EPIPE and raises SIGPIPE. - Nonblocking pipes (PIPE_NOWAIT) are not well handled by non-Cygwin tools, so convert pipe handles to PIPE_WAIT handles when spawning a non-Cygwin process.
2021-09-14Cygwin: pipe, fifo: Call set_no_inheritance() for adjunct handles.Takashi Yano
- Currntly, set_no_inheritance() is not called for the adjunct handles such as select_sem. This patch fixes the issue.
2021-09-14Cygwin: fhandler_base::dup Reflect O_CLOEXEC to inheritance flag.Takashi Yano
- Currently fhandler_base::dup duplicates handles with bInheritHandle TRUE unconditionally. This patch reflects O_CLOEXEC flag to that parameter.
2021-09-13Cygwin: pipes: do not duplicate sec_none{_nih} locally when creating objectsCorinna Vinschen
We already fetched the correct SECURITY_ATTRIBUTES at the start of fhandler_pipe::create, so using another SECURITY_ATTRIBUTES object for the mutex and semaphore objects doesn't make much sense. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: fix inheritence of select_sem on write side of pipeCorinna Vinschen
select_sem gets created on the read side with inheritence settings depending on the O_CLOEXEC flag. Then it gets duplicated to the write side with unconditional inheritence. Fix that. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipe: Fix deadlock if pipe is created by non-cygwin app.Takashi Yano
2021-09-13Cygwin: fifo: Utilize select_sem for fifo as well as pipe.Takashi Yano
2021-09-13Cygwin: pipes: always signal select_sem if any bytes are read or writtenCorinna Vinschen
Fold all code branches potentially having read or written data into a single if branch, so signalling select_sem catches all cases. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipe: Fix notification timing of select_sem.Takashi Yano
- Make select_sem notify even when read/write partially.
2021-09-13Cygwin: select: Introduce select_sem semaphore for pipe.Takashi Yano
- This patch introduces select_sem semaphore which notifies pipe status change.
2021-09-13Revert "Cygwin: select: Improve select/poll response."Takashi Yano
... because this commit (23bb19ef) causes high CPU load.
2021-09-13Cygwin: set buffer size for pipes created by non-Cygwin processesKen Brown
Rename fhandler_pipe_and_fifo::max_atomic_write to pipe_buf_size. This reflect its actual meaning better. The fhandler_pipe_and_fifo constructor initializes it to DEFAULT_PIPEBUFSIZE (== 64K), which is the buffer size for the windows pipes created by fhandler_pipe and fhandler_fifo. But if we inherit a stdio pipe handle from a non-Cygwin process, the buffer size could be different. To remedy this, add a method fhandler_pipe::set_pipe_buf_size that queries the OS for the pipe buffer size, and use it in dtable::init_std_file_from_handle.
2021-09-13Cygwin: pipes: drop "tiny pipe" handlingCorinna Vinschen
Given we return 1 already if WriteQuotaAvailable is > 0, the condition for tiny pipes is never true. Fix the comments. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipes: handle signals and thread cancellation in blocking mode onlyCorinna Vinschen
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipes: always terminate async IO in blocking modeCorinna Vinschen
In blocking mode, the underlying IO must always be terminated, one way or the other, to make sure the application knows the exact state after returning from the IO function. Therefore, always call CancelIo in blocking mode. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipes: cancel async IO if thread cancellation is in progressCorinna Vinschen
Just cancelling a thread doesn't cancel async IO started by this thread. Fix this by returning from cygwait and calling CancelIo before canceling self. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipe: Stop counting reader and read all available data.Takashi Yano
- By guarding read with read_mtx, no more than one ReadFile can be called simultaneously. So couting read handles is no longer necessary. - Make raw_read code as similar as possible to raw_write code.
2021-09-13Cygwin: new class fhandler_pipe_fifoKen Brown
This is a parent of fhandler_pipe and fhandler_fifo for code that is common between the two classes. Currently it just contains max_atomic_write and raw_write(). The latter is identical to what used to be fhandler_pipe::raw_write().
2021-09-13Cygwin: FIFO: open pipes with FILE_READ_ATTRIBUTES accessKen Brown
This is needed by NtQueryInformationFile, which is used by select.
2021-09-13Cygwin: pipes: minor code cleanupKen Brown
Clarify a comment in raw_read, and remove a useless line from raw_write.
2021-09-13Cygwin: pipes: nt_create: set read handle to NULL in error caseCorinna Vinschen
Fix accidentally setting read handle to INVALID_HANDLE_VALUE in a single error case. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipes: call nt_create with handle referencesCorinna Vinschen
...to avoid potential pointer mishandling. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipes: workaround unrelibale system infoCorinna Vinschen
FILE_PIPE_LOCAL_INFORMATION::WriteQuotaAvailable is unreliable. Usually WriteQuotaAvailable on the write side reflects the space available in the inbound buffer on the read side. However, if a pipe read is currently pending, WriteQuotaAvailable on the write side is decremented by the number of bytes the read side is requesting. So it's possible (even likely) that WriteQuotaAvailable is 0, even if the inbound buffer on the read side is not full. This can lead to a deadlock situation: The reader is waiting for data, but select on the writer side assumes that no space is available in the read side inbound buffer. This patch implements a workaround by never trying to read more than half the buffer size blocking if the read buffer is empty. This first cut tries to take the number of open readers into account by reducing the amount of requested bytes accordingly. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipes: fix POSIX requirement for non-blocking pipe writesCorinna Vinschen
POSIX requires atomicity for non-blocking writes <= PIPE_BUF bytes and writing of at least 1 byte if any buffer space is left. Windows NtWriteFile returns STATUS_SUCCESS and "0 bytes written" if the write doesn't match buffer space. Fix this discrepancy. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipes: create pipes with synchronization enabledCorinna Vinschen
This isn't used by Cygwin, but it might be used by Win32 processes inheriting the handle. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipes: use NtClose when file has been opened with an NtXxx functionCorinna Vinschen
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipes: always close read side pipe handle in error caseCorinna Vinschen
Add missing CloseHandle. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: pipes: fix a bug in raw_writeCorinna Vinschen
The buffer pointer is incremented by "chunk", which is what we typically try to write, but this isn't what actually got written. Increment the buffer pointer by what we actually wrote, as returned by NtWriteFile. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: move get_obj_handle_count() to miscfuncs.ccCorinna Vinschen
get_obj_handle_count() is used in flock only so far, but pipe handling might have a usage, too, soon. Given that this function might be generally useful and isn't restricted to flock usage, move it to miscfuncs.cc and make it non-static. Add a prototype in miscfuncs.h. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Cygwin: _pipe: add a commentCorinna Vinschen
I wasted valuable minutes of my life just to find out why we export this weird version of pipe. In the pre-2000 era the idea was Cygwin could be used as drop-in replacement for msvcrt.dll, apparently. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-13Revert "Cygwin: fhandler_pipe.cc:nt_select: fix flags"Corinna Vinschen
This reverts commit a62f4d128505481c4c683e813a3b16da641af6ff.
2021-09-13Revert "Cygwin: fhandler_pipe.cc:nt_select: fix flags again"Corinna Vinschen
This reverts commit c35db324efb5cdc6605eac947e0d4fdeb45e8b43.
2021-09-13Cygwin: fhandler_pipe.cc:nt_select: fix flags againKen Brown
2021-09-13Cygwin: fhandler_pipe.cc:nt_select: fix flagsKen Brown
2021-09-13Revert "Cygwin: pipe: Revert to create() rather than nt_create()."Ken Brown
This reverts commit 5a7a0d34c74a55aa1e76644e61bf4889051cb640.