aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/api/vim.c1
-rw-r--r--src/nvim/event/multiqueue.c1
-rw-r--r--src/nvim/msgpack_rpc/channel.c7
-rw-r--r--src/nvim/msgpack_rpc/channel.h5
-rw-r--r--src/nvim/normal.c1
-rw-r--r--src/nvim/os/input.c8
6 files changed, 11 insertions, 12 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index a00afc24fa..11f15b5ad1 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -11,7 +11,6 @@
#include "nvim/api/vim.h"
#include "nvim/ascii.h"
-#include "nvim/log.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/buffer.h"
diff --git a/src/nvim/event/multiqueue.c b/src/nvim/event/multiqueue.c
index a479a032f4..66a261b554 100644
--- a/src/nvim/event/multiqueue.c
+++ b/src/nvim/event/multiqueue.c
@@ -55,7 +55,6 @@
#include "nvim/event/multiqueue.h"
#include "nvim/memory.h"
-#include "nvim/log.h"
#include "nvim/os/time.h"
typedef struct multiqueue_item MultiQueueItem;
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index 9e43924db1..911f2a6fa4 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -28,7 +28,6 @@
#include "nvim/map.h"
#include "nvim/log.h"
#include "nvim/misc1.h"
-#include "nvim/state.h"
#include "nvim/lib/kvec.h"
#include "nvim/os/input.h"
@@ -91,6 +90,7 @@ static msgpack_sbuffer out_buffer;
/// Initializes the module
void channel_init(void)
{
+ ch_before_blocking_events = multiqueue_new_child(main_loop.events);
channels = pmap_new(uint64_t)();
event_strings = pmap_new(cstr_t)();
msgpack_sbuffer_init(&out_buffer);
@@ -446,9 +446,8 @@ static void handle_request(Channel *channel, msgpack_object *request)
&& !strncmp("nvim_get_mode", method->via.bin.ptr, method->via.bin.size);
if (is_get_mode && !input_blocking()) {
- // Schedule on the main loop with special priority. #6247
- Event ev = event_create(kEvPriorityAsync, on_request_event, 1, evdata);
- multiqueue_put_event(channel->events, ev);
+ // Defer the event to a special queue used by os/input.c. #6247
+ multiqueue_put(ch_before_blocking_events, on_request_event, 1, evdata);
} else {
// Invoke immediately.
on_request_event((void **)&evdata);
diff --git a/src/nvim/msgpack_rpc/channel.h b/src/nvim/msgpack_rpc/channel.h
index 0d92976d02..f8fe6f129b 100644
--- a/src/nvim/msgpack_rpc/channel.h
+++ b/src/nvim/msgpack_rpc/channel.h
@@ -11,6 +11,11 @@
#define METHOD_MAXLEN 512
+/// HACK: os/input.c drains this queue immediately before blocking for input.
+/// Events on this queue are async-safe, but they need the resolved state
+/// of os_inchar(), so they are processed "just-in-time".
+MultiQueue *ch_before_blocking_events;
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "msgpack_rpc/channel.h.generated.h"
#endif
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 09ad7beb4b..f73e3079b9 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -14,7 +14,6 @@
#include <stdlib.h>
#include "nvim/vim.h"
-#include "nvim/log.h"
#include "nvim/ascii.h"
#include "nvim/normal.h"
#include "nvim/buffer.h"
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index de6d4a9010..31e06ce404 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -23,7 +23,7 @@
#include "nvim/main.h"
#include "nvim/misc1.h"
#include "nvim/state.h"
-#include "nvim/log.h"
+#include "nvim/msgpack_rpc/channel.h"
#define READ_BUFFER_SIZE 0xfff
#define INPUT_BUFFER_SIZE (READ_BUFFER_SIZE * 4)
@@ -342,11 +342,9 @@ static bool input_poll(int ms)
}
if ((ms == - 1 || ms > 0) && !events_enabled && !input_eof) {
- // We have discovered that the pending input will provoke a blocking wait.
- // Process any events marked with priority `kEvPriorityAsync`: these events
- // must be handled after flushing input. See channel.c:handle_request #6247
+ // The pending input provoked a blocking wait. Do special events now. #6247
blocking = true;
- multiqueue_process_priority(main_loop.events, kEvPriorityAsync);
+ multiqueue_process_events(ch_before_blocking_events);
}
LOOP_PROCESS_EVENTS_UNTIL(&main_loop, NULL, ms, input_ready() || input_eof);
blocking = false;