summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Cygwin: termios: Set ECHOE, ECHOK, ECHOCTL and ECHOKE by default.Takashi Yano via Cygwin-patches2020-05-191-1/+2
| | | | | | | | - Backspace key does not work correctly in linux session opend by ssh from cygwin console if the shell is bash. This is due to lack of these flags. Addresses: https://cygwin.com/pipermail/cygwin/2020-May/244837.html.
* cygwin: doc: Add keywords for ACE order issuesDavid Macek via Cygwin-patches2020-05-191-5/+7
| | | | | | | | | | | | Windows Explorer shows a warning with Cygwin-created DACLs, but putting the text of the warning into Google doesn't lead to the relevant Cygwin docs. Let's copy the warning text into the docs in the hopes of helping confused users. Most of the credit for the wording belongs to Yaakov Selkowitz. Latest inquiry: <https://cygwin.com/pipermail/cygwin/2020-May/244814.html> Signed-off-by: David Macek <david.macek.0@gmail.com>
* Cygwin: FIFO: improve the interruptibility of raw_readKen Brown2020-05-111-4/+2
| | | | | | | | During a blocking read, we sleep for 1 ms after each iteration through the connected writers. Currently we do this by calling Sleep (1). Remove this call to Sleep and instead change the timeout in the cygwait call from 0 to 1, so that raw_read can be interrupted while sleeping.
* Cygwin: FIFO: code simplificationKen Brown2020-05-113-67/+44
| | | | | | | | | | | | | | | | | | | | | | | | | There are currently three functions that call NtQueryInformationFile to determine the state of a pipe instance. Do this only once, in a new fifo_client_handler::set_state () function, and call that when state information is needed. Remove the fifo_client_handler methods pipe_state and get_state, which are no longer needed. Make fhandler_fifo::get_fc_handler return a reference, for use in select.cc:peek_fifo. Make other small changes to ensure that this commit doesn't change any decisions based on the state of a fifo_client_handler. The tricky part is interpreting FILE_PIPE_CLOSING_STATE, which we translate to fc_closing. Our current interpretation, which is not changing as a result of this commit, is that the writer at the other end of the pipe instance is viewed as still connected from the point of view of raw_read and determining EOF. But it is not viewed as still connected if we are deciding whether to unblock a new reader that is trying to open.
* Cygwin: fifo: fix type of fifo_reader_id_t operatorsCorinna Vinschen2020-05-081-2/+2
| | | | | | | | fifo_reader_id_t::operator == and != have been defined without type accidentally. For some weird reason, only x86 gcc complains about this problem, not x86_64 gcc. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: add pseudo console patch to release textCorinna Vinschen2020-05-081-0/+4
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Document recent FIFO changesKen Brown2020-05-082-0/+10
|
* Cygwin: FIFO: update commentaryKen Brown2020-05-081-23/+35
| | | | | | The beginning of fhandler_fifo.cc contains a long comment giving an overview of the FIFO implementation. This is now updated to describe the support for multiple readers.
* Cygwin: FIFO: support opening multiple readersKen Brown2020-05-082-11/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although we can have multiple readers open because of dup/fork/exec, the current code does not support multiple readers opening a FIFO by explicitly calling 'open'. The main complication in supporting this is that when a blocking reader tries to open and there's already one open, it has to check whether there any writers open. It can't rely on the write_ready event, whose state hasn't changed since the first writer opened. To fix this, add two new named events, check_write_ready_evt and write_ready_ok_evt, and a new method, check_write_ready(). The first event signals the owner's reader thread to call check_write_ready(), which polls the fc_handler list to check for connected writers. If it finds none, it checks to see if there's a writer in the process and then sets/resets write_ready appropriately. When check_write_ready() finishes it sets write_ready_ok_evt to signal the reader that write_ready has been updated. The polling is done via fifo_client_handler::pipe_state(). As long as it's calling that function anyway, check_write_ready() updates the state of each handler. Also add a new lock to prevent a race if two readers are trying to open simultaneously.
* Cygwin: FIFO: allow any reader to take ownershipKen Brown2020-05-083-16/+122
| | | | | | | | | | | | | | | | | | | | | Add a take_ownership method, used by raw_read and select.cc:peek_fifo. It wakes up all fifo_reader_threads and allows the caller to become owner. The work is done by the fifo_reader_threads. For synchronization we introduce several new fhandler_fifo data members and methods: - update_needed_evt signals the current owner to stop listening for writer connections and update its fc_handler list. - shared_fc_handler() gets and sets the status of the fc_handler update process. - get_pending_owner() and set_pending_owner() get and set the reader that is requesting ownership. Finally, a new 'reading_lock' prevents two readers from trying to take ownership simultaneously.
* Cygwin: FIFO: find a new owner when closingKen Brown2020-05-082-11/+112
| | | | | | | | | | | | | | | | If the owning reader is closing, wait for another reader (if there is one) to take ownership before closing the owner's pipe handles. To synchronize the ownership transfer, add events owner_needed_evt and owner_found_evt, and add methods owner_needed and owner_found to set/reset them. Modify the fifo_reader_thread function to wake up all non-owners when a new owner is needed. Make a cosmetic change in close so that fhandler_base::close is called only if we have a write handle. This prevents strace output from being littered with statements that the null handle is being closed.
* Cygwin: FIFO: take ownership on execKen Brown2020-05-082-46/+107
| | | | | | | | | | | | | | | If fixup_after_exec is called on a non-close-on-exec reader whose parent is the owner, transfer ownership to the child. Otherwise the parent's pipe handles will be closed before any other reader can duplicate them. To help with this, make the cancel_evt and thr_sync_evt handles inheritable, so that the child can terminate the parent's fifo_reader_thread (and the parent will update the shared fc_handler list). Add an optional argument 'from_exec' to update_my_handlers to simplify its use in this case; no handle duplication is required.
* Cygwin: FIFO: add a shared fifo_client_handler listKen Brown2020-05-082-27/+269
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is in a new shared memory section. We will use it for temporary storage of the owner's fc_handler list when we need to change owner. The new owner can then duplicate the pipe handles from that list before taking ownership. Add several shared data members and methods that are needed for the duplication process Add methods update_my_handlers and update_shared_handlers that carry out the duplication. Allow the shared list to grow dynamically, up to a point. Do this by initially reserving a block of memory (currently 100 pages) and only committing pages as needed. Add methods create_shared_fc_handler, reopen_shared_fc_handler, and remap_shared_fc_handler to create the new shared memory section, reopen it, and commit new pages. The first is called in open, the second is called in dup/fork/exec, and the third is called in update_shared_handlers if more shared memory is needed. Modify the fifo_reader_thread function to call update_my_handlers when it finds that there is no owner. Also make it call update_shared_handlers when the owner's thread terminates, so that the new owner will have an accurate shared fc_handler list from which to duplicate. For convenience, add new methods cleanup_handlers and close_all_handlers. And add an optional arg to add_client_handler that allows it to create a new fifo_client_handler without creating a new pipe instance.
* Cygwin: FIFO: allow fc_handler list to grow dynamicallyKen Brown2020-05-082-21/+26
| | | | | | | | | Make fc_handler a pointer to malloc'd memory instead of a fixed-size array. The size is now a new data member 'shandlers'. Call realloc in add_client_handler if we need to grow the array. free fc_handler in close. As long as we're touching that code, also remove an unneeded lock.
* Cygwin: FIFO: designate one reader as ownerKen Brown2020-05-082-109/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Among all the open readers of a FIFO, one is declared to be the owner. This is the only reader that listens for client connections, and it is the only one that has an accurate fc_handler list. Add shared data and methods for getting and setting the owner, as well as a lock to prevent more than one reader from accessing these data simultaneously. Modify the fifo_reader_thread so that it checks the owner at the beginning of its loop. If there is no owner, it takes ownership. If there is an owner but it is a different reader, the thread just waits to be canceled. Otherwise, it listens for client connections as before. Remove the 'first' argument from create_pipe_instance. It is not needed, and it may be confusing in the future since only the owner knows whether a pipe instance is the first. When opening a reader, don't return until the fifo_reader_thread has time to set an owner. If the owner closes, indicate that there is no longer an owner. Clear the child's fc_handler list in dup, and don't bother duplicating the handles. The child never starts out as owner, so it can't use those handles. Do the same thing in fixup_after_fork in the close-on-exec case. In the non-close-on-exec case, the child inherits an fc_handler list that it can't use, but we can just leave it alone; the handles will be closed when the child is closed.
* Cygwin: FIFO: introduce a new type, fifo_reader_id_tKen Brown2020-05-082-1/+31
| | | | | | | | This uniquely identifies an fhandler_fifo open for reading in any process. Add a new data member 'me' of this type, which is set in open, dup, fork, and exec.
* Cygwin: FIFO: keep track of the number of readersKen Brown2020-05-082-8/+22
| | | | | | | | Add data and methods to the shared memory that keep track of the number of open readers. Increment this number in open, dup, fork, and exec. Decrement it in close. Reset read_ready if there are no readers left.
* Cygwin: FIFO: add shared memoryKen Brown2020-05-082-4/+106
| | | | | | | | | | | | | | Even though we currently allow a FIFO to be opened for reading only once, we can still have more than one reader open because of dup and fork. Add a named shared memory section accessible to all readers of a given FIFO. In future commits we will add information needed by all readers to this section Add a class fifo_shmem_t that lets us access this information. Add a method create_shmem that is called when a reader opens, and add a method reopen_shmem that is called by dup, fork, and exec. (Each new reader needs its own view of the shared memory.)
* Cygwin: FIFO: use a cygthread instead of a homemade threadKen Brown2020-05-082-125/+65
| | | | | | | | | | This will simplify future work. Rename the thread from "listen_client_thread" to "fifo_reader_thread" because it will be used for more than just listening. Remove the fixup_before stuff, which won't be needed after future changes to fixup_after_fork and fixup_after_exec.
* Cygwin: FIFO: make opening a writer more robustKen Brown2020-05-082-100/+168
| | | | | | | | | | | | | | | | | - Make read_ready a manual-reset event. - Signal read_ready in open instead of in the listen_client_thread. - Don't reset read_ready when the listen_client thread terminates; instead do it in close(). - Rearrange open and change its error handling. - Add a wait_open_pipe method that waits for a pipe instance to be available and then calls open_pipe. Use it when opening a writer if we can't connect immediately. This can happen if the system is heavily loaded and/or if many writers are trying to open simultaneously.
* Cygwin: FIFO: fix hit_eofKen Brown2020-05-083-49/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to Posix, a FIFO open for reading is at EOF if it is empty and there are no writers open. The only way to test this is to poll the fifo_client_handlers as in raw_read and select.cc:peek_fifo. The current hit_eof instead relies on the value of nconnected, which can be out of date. On the one hand, it doesn't take into account writers that were connected but have since closed. On the other hand, it doesn't take into account writers that are in the process of opening but haven't yet connected. Fix this by introducing a maybe_eof method that tentatively assumes EOF if there are no connected writers after polling. Then check for writers currently opening (via a new 'writer_opening' event), and wait for the fifo_reader_thread to record any new connection that was made while we were polling. To handle the needs of peek_fifo, replace the get_fc_handle method by a get_fc_handler method, and add a fifo_client_handler::get_state method. Remove the is_connected method, which was used only in peek_fifo and is no longer needed. Remove the nconnected data member, which was used only for the flawed hit_eof. Add some comments about events to fhandler.h.
* Cygwin: FIFO: dup/fork/exec: make sure child starts unlockedKen Brown2020-05-081-8/+23
| | | | | There can be deadlocks if the child starts with its fifo_client_lock in the locked state.
* Cygwin: FIFO: honor the flags argument in dupKen Brown2020-05-081-27/+33
| | | | Also improve the error handling.
* Cygwin: FIFO: remove the arm methodKen Brown2020-05-082-32/+3
| | | | | There's no reason to check for errors when we set read_ready or write_ready. We don't do that for other events.
* Cygwin: FIFO: simplify the listen_client_thread codeKen Brown2020-05-082-74/+47
| | | | | | | | | | | | | | | | | | Always return 0; no one is doing anything with the return value anyway. Remove the return value from stop_listen_client. Make the connection event auto-reset, so that we don't have to reset it later. Simplify the process of connecting a bogus client when thread termination is signaled. Make some failures fatal. Remove the unnecessary extra check for thread termination near the end of listen_client_thread.
* Cygwin: FIFO: change the fifo_client_connect_state enumKen Brown2020-05-082-17/+22
| | | | | | | | | | | | | | | | | Make the values correspond to the possible return values of fifo_client_handler::pipe_state(). When cleaning up the fc_handler list in listen_client_thread(), don't delete handlers in the fc_closing state. I think the pipe might still have input to be read in that case. Set the state to fc_closing later in the same function if a connection is made and the status returned by NtFsControlFile is STATUS_PIPE_CLOSING. In raw_read, don't error out if NtReadFile returns an unexpected status; just set the state of that handler to fc_error. One writer in a bad state doesn't justify giving up on reading.
* Cygwin: FIFO: simplify the fifo_client_handler structureKen Brown2020-05-082-65/+19
| | | | | | Replace the 'fhandler_base *' member by a HANDLE to the server side of the Windows named pipe instance. Make the corresponding simplifications throughout.
* Cygwin: FIFO: minor change - use NtCloseKen Brown2020-05-081-16/+16
| | | | | Replace CloseHandle by NtClose since all handles are created by NT functions.
* Revert "localtime define _DIAGASSERT" and followups affecting localtime.ccCorinna Vinschen2020-05-041-302/+236
| | | | | | | | | | | | | | | This reverts commits 453b6d17bf0581e55258c5eb6dc7afbad1927cab, 489a47d6036660a6cbab1addfb2b7678c0de8bf2, 3003c3dacd157c11f5e035bc18bdd30631800720, 9e29639ca01208a4a8bac5b9d0f6491b34b1017e, a40701c7dc9970457a19728e371c71e7501057e7, 0a41de2725dbf2f325e55016d85d76560845ff8d, b8aa5f7a0fe70a9a53fe4019227271a78758ae67, 0f4bda879283eaf013f86dd80e5588721a811ea0, 65bf580752db7ac01ecae19dc56aa26ea34f5e47, 3f0c2ac96e7c493bbfc2bc1b0c1274445b756a9d, 76d4d40b8b23d046473a5946cf6b83faa36ae7be, f2e06d8af5f390d81b64375a69ca834ca19d6029.
* setup_pseudoconsole(): handle missing/incorrect helper gracefullyJohannes Schindelin2020-05-041-1/+17
| | | | | | | | | | | | | When `cygwin-console-helper.exe` is either missing, or corresponds to a different Cygwin runtime, we currently wait forever while setting up access to the pseudo console, even long after the process is gone that was supposed to signal that it set up access to the pseudo console. Let's handle that more gracefully: if the process exited without signaling, we cannot use the pseudo console. In that case, let's just fall back to not using it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* localtime define _DIAGASSERTCorinna Vinschen2020-04-291-2/+4
|
* localtime 1.82Corinna Vinschen2020-04-281-22/+15
|
* localtime 1.81Corinna Vinschen2020-04-281-104/+101
|
* localtime 1.80Corinna Vinschen2020-04-281-4/+12
|
* localtime 1.79Corinna Vinschen2020-04-281-3/+3
|
* localtime 1.78Corinna Vinschen2020-04-281-64/+68
|
* localtime 1.77Corinna Vinschen2020-04-281-3/+3
|
* localtime 1.76Corinna Vinschen2020-04-281-3/+3
|
* localtime 1.75Corinna Vinschen2020-04-281-3/+8
|
* localtime 1.74Corinna Vinschen2020-04-281-88/+133
|
* localtime 1.73Corinna Vinschen2020-04-271-7/+17
|
* Cygwin: localtime.cc: reformat for easier patchingCorinna Vinschen2020-04-271-8/+10
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: add release message for fixed floppy bugsCorinna Vinschen2020-04-241-0/+4
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: raw disk I/O: lock floppys as wellCorinna Vinschen2020-04-241-2/+2
| | | | | | | | | The workaround to access the full disk required since Vista and described in http://support.microsoft.com/kb/942448 (NOT ACCESSIBLE at the time of writing this commit message) is required on floppy drives as well. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: raw disk I/O: Fix return value in error caseCorinna Vinschen2020-04-241-3/+4
| | | | | | | | | | | | | | | The cast to generate the return value uses a DWORD variable as test and set value. The error case is the constant -1. Given the type of the other half of the conditioal expression, -1 is cast to DWORD as well. On 64 bit, this results in the error case returning a 32 bit -1 value which is equivalent to (ssize_t) 4294967295 rather than (ssize_t) -1. Add a fixing cast. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: file I/O: make sure to treat write return value as ssize_tCorinna Vinschen2020-04-241-3/+3
| | | | | | | | The return type of fhandler write methods is ssize_t. Don't use an int to store the return value, use ssize_t. Use ptrdiff_t for the buffer size. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: accounts: Report unrecognized db_* nsswitch.conf keywordsDavid Macek via Cygwin-patches2020-04-221-0/+2
| | | | Signed-off-by: David Macek <david.macek.0@gmail.com>
* Cygwin: accounts: Don't keep old schemes when parsing nsswitch.confDavid Macek via Cygwin-patches2020-04-222-4/+8
| | | | | | | | | | | | | | | | | The implicit assumption seemed to be that any subsequent occurence of the same setting in nsswitch.conf is supposed to rewrite the previous ones completely. This was not the case if the third or any further schema was previously defined and the last line defined less than that (but at least 2), for example: ``` db_home: windows cygwin /myhome/%U db_home: cygwin desc ``` Let's document this behavior as well. Signed-off-by: David Macek <david.macek.0@gmail.com>
* Cygwin: accounts: Unify nsswitch.conf db_* defaultsDavid Macek via Cygwin-patches2020-04-222-21/+11
| | | | Signed-off-by: David Macek <david.macek.0@gmail.com>
* Cygwin: Add David Macek to CONTRIBUTORSCorinna Vinschen2020-04-211-0/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>