aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/os/channel.c15
-rw-r--r--src/nvim/os/msgpack_rpc.c36
2 files changed, 11 insertions, 40 deletions
diff --git a/src/nvim/os/channel.c b/src/nvim/os/channel.c
index bad82bc272..bc1bef3a57 100644
--- a/src/nvim/os/channel.c
+++ b/src/nvim/os/channel.c
@@ -22,8 +22,10 @@
#include "nvim/memory.h"
#include "nvim/os_unix.h"
#include "nvim/message.h"
+#include "nvim/term.h"
#include "nvim/map.h"
#include "nvim/log.h"
+#include "nvim/misc1.h"
#include "nvim/lib/kvec.h"
#define CHANNEL_BUFFER_SIZE 0xffff
@@ -331,11 +333,10 @@ static void parse_msgpack(RStream *rstream, void *data, bool eof)
msgpack_unpacked unpacked;
msgpack_unpacked_init(&unpacked);
- UnpackResult result;
+ msgpack_unpack_return result;
// Deserialize everything we can.
- while ((result = msgpack_rpc_unpack(channel->unpacker, &unpacked))
- == kUnpackResultOk) {
+ while ((result = msgpack_unpacker_next(channel->unpacker, &unpacked))) {
if (kv_size(channel->call_stack) && is_rpc_response(&unpacked.data)) {
if (is_valid_rpc_response(&unpacked.data, channel)) {
call_stack_pop(&unpacked.data, channel);
@@ -362,7 +363,13 @@ static void parse_msgpack(RStream *rstream, void *data, bool eof)
}
}
- if (result == kUnpackResultFail) {
+ if (result == MSGPACK_UNPACK_NOMEM_ERROR) {
+ OUT_STR(e_outofmem);
+ out_char('\n');
+ preserve_exit();
+ }
+
+ if (result == MSGPACK_UNPACK_PARSE_ERROR) {
// See src/msgpack/unpack_template.h in msgpack source tree for
// causes for this error(search for 'goto _failed')
//
diff --git a/src/nvim/os/msgpack_rpc.c b/src/nvim/os/msgpack_rpc.c
index 485ef0d04b..fe4918b7d9 100644
--- a/src/nvim/os/msgpack_rpc.c
+++ b/src/nvim/os/msgpack_rpc.c
@@ -57,42 +57,6 @@ WBuffer *msgpack_rpc_call(uint64_t channel_id,
return serialize_response(response_id, NULL, rv, sbuffer);
}
-/// Try to unpack a msgpack document from the data in the unpacker buffer. This
-/// function is a replacement to msgpack.h `msgpack_unpack_next` that lets
-/// the called know if the unpacking failed due to bad input or due to missing
-/// data.
-///
-/// @param unpacker The unpacker containing the parse buffer
-/// @param result The result which will contain the parsed object
-/// @return kUnpackResultOk : An object was parsed
-/// kUnpackResultFail : Got bad input
-/// kUnpackResultNeedMore: Need more data
-UnpackResult msgpack_rpc_unpack(msgpack_unpacker* unpacker,
- msgpack_unpacked* result)
- FUNC_ATTR_NONNULL_ALL
-{
- if (result->zone != NULL) {
- msgpack_zone_free(result->zone);
- }
-
- int res = msgpack_unpacker_execute(unpacker);
-
- if (res > 0) {
- result->zone = msgpack_unpacker_release_zone(unpacker);
- result->data = msgpack_unpacker_data(unpacker);
- msgpack_unpacker_reset(unpacker);
- return kUnpackResultOk;
- }
-
- if (res < 0) {
- // Since we couldn't parse it, destroy the data consumed so far
- msgpack_unpacker_reset(unpacker);
- return kUnpackResultFail;
- }
-
- return kUnpackResultNeedMore;
-}
-
/// Finishes the msgpack-rpc call with an error message.
///
/// @param msg The error message