aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/event/stream.c
Commit message (Collapse)AuthorAge
* fix(channel): stack-buffer-overflow with exit during connection (#39387)zeertzjq2026-04-25
| | | | | | Problem: When Nvim exits while connecting to a socket it leads to stack-buffer-overflow. Solution: Associate the handle with the Stream and use the Stream's internal_close_cb to update the "closed" status.
* revert: "refactor(process): don't read from PTY master using uv_pipe_t" (#37401)zeertzjq2026-03-30
| | | This reverts commit 75c8f755015e4724ba45bd84137d41efa40a3025.
* fix(pty): prevent orphan conhost.exe on Windows 10 #38244tao2026-03-20
| | | | | | | | | | | | | | | | | Problem: On Windows 10, the ConPTY closing order is strict. Calling ClosePseudoConsole after closing the output stream can easily lead to accidental deadlocks, leaving orphan conhost.exe processes. See https://learn.microsoft.com/en-us/windows/console/closepseudoconsole#remarks and https://learn.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session#ending-the-pseudoconsole-session Solution: Based on the warning in the docs above, we need to call ClosePseudoConsole on a separate thread first so that the output pipe can fully drain on the main thread. Also, `wait_eof_timer` is outdated, so I removed it to avoid extra cleanup logic around it (it was introduced in the early winpty days). Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* refactor(process): don't read from PTY master using uv_pipe_tzeertzjq2026-01-15
| | | | | | | | | Using uv_pipe_t to read from PTY master may drop data if the PTY process exits immediately after output, as libuv treats a partial read after POLLHUP as EOF, which isn't true for PTY master on Linux. Therefore use uv_poll_t instead. This commit can be reverted if libuv/libuv#4992 is fixed for uv_pipe_t.
* refactor(event/stream.c): fix confusing indent (#37398)zeertzjq2026-01-15
|
* fix(socket): avoid stack-use-after-return after timeout (#36405)zeertzjq2025-11-01
| | | | | | | | | | | | | | | | | | | Problem: In socket_connect(), if connecting to the given TCP address times out, libuv is still trying to connect to the address, and connect_cb may be called when running the libuv event loop after the `status` variable referenced by `req.data` goes out of scope. Solution: Close the uv_tcp_t handle and wait for connect_cb to be called before retrying or failing in socket_connect(). This also avoid leaking libuv handles. The tests added here only check that the non-timeout case still works, as checking the timeout case is very hard without modifications to the code. Removing the first LOOP_PROCESS_EVENT_UNTIL() in socket_connect() (the one with the timeout) is a way to check that manually. Also add a comment about the cause of the ASAN error in #34586.
* Merge pull request #36393 from zeertzjq/rstream-close-cbzeertzjq2025-10-31
| | | fix(channel): closing socket with pending writes leaks memory
* feat(ui): :connect command #34586Siddhant Agarwal2025-08-14
| | | | Add the `:connect <address>` command which connects the currently running TUI to the server at the given address.
* refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl2025-08-14
| | | | | | | | | These are not needed after #35129 but making uncrustify still play nice with them was a bit tricky. Unfortunately `uncrustify --update-config-with-doc` breaks strings with backslashes. This issue has been reported upstream, and in the meanwhile auto-update on every single run has been disabled.
* refactor(channel): redundant channel_close()Justin M. Keyes2025-03-24
| | | | | | | | | | Problem: `receive_msgpack()` calls `channel_close()` just before calling `chan_close_on_err()`, even though `chan_close_on_err()` always calls `channel_close()`. Solution: Remove the redunant `channel_close()` in `receive_msgpack()`.
* feat(ui): UI :detach commandJustin M. Keyes2025-02-10
| | | | | | | | | | | Problem: Cannot detach the current UI. Solution: - Introduce `:detach`. - Introduce `Channel.detach`. Co-authored-by: bfredl <bjorn.linse@gmail.com>
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* fix(channel): handle writing to file instead of pipe (#30519)zeertzjq2024-09-26
|
* refactor(stream.c): unused params in stream_close #30356Justin M. Keyes2024-09-12
|
* refactor(io): make rstream use a linear bufferbfredl2024-06-08
| | | | | | | | | If you like it you shouldn't put a ring on it. This is what _every_ consumer of RStream used anyway, either by calling rbuffer_reset, or rbuffer_consumed_compact (same as rbuffer_reset without needing a scratch buffer), or by consuming everything in each stream_read_cb call directly.
* refactor(io): separate types for read and write streamsbfredl2024-05-31
| | | | | | | | | | | | This is a structural refactor with no logical changes, yet. Done in preparation for simplifying rstream/rbuffer which will require more state inline in RStream. The initial idea was to have RStream and WStream as sub-types symetrically but that doesn't work, as sockets are both reading and writing. Also there is very little write-specific state to start with, so the benefit of a separate WStream struct is a lot smaller. Just document what fields in `Stream` are write specific.
* refactor: run IWYU on entire repodundargoc2023-12-21
| | | | Reference: https://github.com/neovim/neovim/issues/6371.
* refactor: move non-symbols to defs.h headersdundargoc2023-12-17
|
* fix(stream): do not close handle if it is already closing (#26537)Gregory Anders2023-12-12
| | | | | uv_close asserts that a handle is not already closing. We can guard against this assertion failure by manually checking the handle's closing status ourselves.
* build: don't define FUNC_ATTR_* as empty in headers (#26317)zeertzjq2023-11-30
| | | | | | FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header.
* build(IWYU): fix includes for func_attr.hdundargoc2023-11-27
|
* refactor: iwyu (#26062)zeertzjq2023-11-16
|
* build: remove PVSdundargoc2023-11-12
| | | | | | | We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable.
* build: allow IWYU to fix includes for all .c filesdundargoc2022-11-15
| | | | | | | | | | Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers.
* vim-patch:8.1.0941: macros for MS-Windows are inconsistent (#20215)dundargoc2022-09-18
| | | | | | | Problem: Macros for MS-Windows are inconsistent, using "32", "3264 and others. Solution: Use MSWIN for all MS-Windows builds. Use FEAT_GUI_MSWIN for the GUI build. (Hirohito Higashi, closes vim/vim#3932) https://github.com/vim/vim/commit/4f97475d326c2773a78561fb874e4f23c25cbcd9
* Refactor/uncrustify (#15790)dundargoc2021-09-29
| | | | | | | | | | | | | * refactor: format with uncrustify * fixup(dundar): fix functions comments * fixup(dundar): remove space between variable and ++/-- * fixup(dundar): better workaround for macro attributes This is done to be able to better use uncrustify rules for macros * fixup(justin): make preprocessors follow neovim style guide
* refactor: format files with uncrustify #15663dundargoc2021-09-14
|
* chore: use codespell to spell check #15016dundargoc2021-07-07
|
* win/TUI: enable mouse on ConEmu and vtpcon without vtierw72020-05-26
|
* win: use virtual terminal input (VTI) if available #11803erw72020-05-26
| | | | | fixes #9514 fixes #11773
* Test on actual libuv version number, not on existence of symbol.Matěj Cepl2020-04-21
| | | | | | uv_stream_get_write_queue_size isn't a define, it's a function. It seems like this would always be shadowing the actual function name.
* Make neovim building even with libuv 1.18.0Matěj Cepl2020-04-21
| | | | (found for example on openSUSE/Leap 15.*)
* win: stream: reset tty stream on closeAnciety2019-08-20
| | | | | | | | | | This was overlooked in 8072f085d2ed. Analogous to 8a782f1699e2. fix #10668 ref 8072f085d2ed #9884 ref 8a782f1699e2 #2377
* stream: log unwritten bytes, if any #10663Justin M. Keyes2019-08-01
|
* build: fix some warningsJustin M. Keyes2019-06-03
| | | | | | | | | | | | | | | | | | ../src/nvim/event/rstream.c:119:44: warning: format specifies type 'void *' but the argument has type 'Stream *' (aka 'struct stream *') [-Wformat-pedantic] DLOG("Closing Stream (%p): %s (%s)", stream, ~~ ^~~~~~ ../src/nvim/event/stream.c:95:30: warning: format specifies type 'void *' but the argument has type 'Stream *' (aka 'struct stream *') [-Wformat-pedantic] DLOG("closing Stream: %p", stream); ~~ ^~~~~~ ../src/nvim/msgpack_rpc/channel.c:71:72: warning: format specifies type 'void *' but the argument has type 'Stream *' (aka 'struct stream *') [-Wformat-pedantic] DLOG("rpc ch %" PRIu64 " in-stream=%p out-stream=%p", channel->id, in, out); ~~ ^~ ../src/nvim/msgpack_rpc/channel.c:71:76: warning: format specifies type 'void *' but the argument has type 'Stream *' (aka 'struct stream *') [-Wformat-pedantic] DLOG("rpc ch %" PRIu64 " in-stream=%p out-stream=%p", channel->id, in, out); ~~ ^~~ ../src/nvim/msgpack_rpc/channel.c:226:28: warning: format specifies type 'void *' but the argument has type 'Stream *' (aka 'struct stream *') [-Wformat-pedantic] channel->id, count, stream); ^~~~~~
* win: stream_init() issue with tty on Windows #9884erw72019-04-28
| | | ref #9825
* channels: generalize jobclose()Björn Linse2017-11-25
|
* log: some DEBUG-level stream loggingJustin M. Keyes2017-08-21
|
* *: Fix all V641 errorsZyX2017-05-20
|
* *: Add comment to all C filesZyX2017-04-19
|
* stream: set data together with callbackBjörn Linse2016-08-20
|
* process.c: Prevent data loss for process output streamsoni-link2016-05-15
| | | | | For a terminating process, it's output streams could be closed, before all data is read.
* Fix comments for os_* functions return valueRui Abreu Ferreira2015-11-25
| | | | | | In windows libuv does not return -errno, instead it uses negative error codes e.g. UV_ENOENT. This commit changes the comments in os_* functions to reflect this.
* Fix warning: stream.c: stream_init(): Dead store: HI.oni-link2015-09-08
| | | | | | | | | | Problem : Dead store @ 59. Diagnostic : Harmless issue. Rationale : loop is a function parameter that is not used anymore after this line. Resolution : Remove line. Based on: http://neovim.io/doc/reports/clang/report-27475f.html#EndPath
* event: Refactor async event processingThiago de Arruda2015-08-13
| | | | | | | | | | - Improve the implementation of deferred/immediate events. - Use the new queue module to change how/when events are queued/processed by giving a private queue to each emitter. - Immediate events(which only exist to break uv_run recursion) are now represented in the `loop->fast_events` queue. - Events pushed to child queues are propagated to the event loop main queue and processed as K_EVENT keys.
* events: Add missing function attributes to some APIsThiago de Arruda2015-08-13
|
* rstream/wstream: Unify structures and simplify APIThiago de Arruda2015-07-17
- Simplify RStream/WStream API and make it more consistent with libuv. - Move into the event loop layer(event subdirectory) - Remove uv_helpers module. - Simplify job/process internal modules/API. - Unify RStream and WStream into a single structure. This is necessary because libuv streams can be readable and writable at the same time(and because the uv_helpers.c hack to associate multiple streams with libuv handle was removed) - Make struct definition public, allowing more flexible/simple memory management by users of the module. - Adapt channel/job modules to cope with the changes.