mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 15:38:33 +00:00
Revert channel logging, rebased on new code below
This commit is contained in:
@@ -15168,8 +15168,7 @@ static void f_sockconnect(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *error = NULL;
|
const char *error = NULL;
|
||||||
eval_format_source_name_line((char *)IObuff, sizeof(IObuff));
|
uint64_t id = channel_connect(tcp, address, 50, &error);
|
||||||
uint64_t id = channel_connect(tcp, address, 50, (char *)IObuff, &error);
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
EMSG2(_("connection failed: %s"), error);
|
EMSG2(_("connection failed: %s"), error);
|
||||||
@@ -22488,9 +22487,8 @@ static inline bool common_job_start(TerminalJobData *data, typval_T *rettv)
|
|||||||
|
|
||||||
|
|
||||||
if (data->rpc) {
|
if (data->rpc) {
|
||||||
eval_format_source_name_line((char *)IObuff, sizeof(IObuff));
|
// the rpc channel takes over the in and out streams
|
||||||
// RPC channel takes over the in/out streams.
|
channel_from_process(proc, data->id);
|
||||||
channel_from_process(proc, data->id, (char *)IObuff);
|
|
||||||
} else {
|
} else {
|
||||||
wstream_init(proc->in, 0);
|
wstream_init(proc->in, 0);
|
||||||
if (proc->out) {
|
if (proc->out) {
|
||||||
@@ -22855,4 +22853,3 @@ void ex_checkhealth(exarg_T *eap)
|
|||||||
|
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -115,15 +115,12 @@ void channel_teardown(void)
|
|||||||
/// Creates an API channel by starting a process and connecting to its
|
/// Creates an API channel by starting a process and connecting to its
|
||||||
/// stdin/stdout. stderr is handled by the job infrastructure.
|
/// stdin/stdout. stderr is handled by the job infrastructure.
|
||||||
///
|
///
|
||||||
/// @param proc process object
|
/// @param argv The argument vector for the process. [consumed]
|
||||||
/// @param id (optional) channel id
|
/// @return The channel id (> 0), on success.
|
||||||
/// @param source description of source function, rplugin name, TCP addr, etc
|
/// 0, on error.
|
||||||
///
|
uint64_t channel_from_process(Process *proc, uint64_t id)
|
||||||
/// @return Channel id (> 0), on success. 0, on error.
|
|
||||||
uint64_t channel_from_process(Process *proc, uint64_t id, char *source)
|
|
||||||
{
|
{
|
||||||
Channel *channel = register_channel(kChannelTypeProc, id, proc->events,
|
Channel *channel = register_channel(kChannelTypeProc, id, proc->events);
|
||||||
source);
|
|
||||||
incref(channel); // process channels are only closed by the exit_cb
|
incref(channel); // process channels are only closed by the exit_cb
|
||||||
channel->data.proc = proc;
|
channel->data.proc = proc;
|
||||||
|
|
||||||
@@ -142,8 +139,7 @@ uint64_t channel_from_process(Process *proc, uint64_t id, char *source)
|
|||||||
/// @param watcher The SocketWatcher ready to accept the connection
|
/// @param watcher The SocketWatcher ready to accept the connection
|
||||||
void channel_from_connection(SocketWatcher *watcher)
|
void channel_from_connection(SocketWatcher *watcher)
|
||||||
{
|
{
|
||||||
Channel *channel = register_channel(kChannelTypeSocket, 0, NULL,
|
Channel *channel = register_channel(kChannelTypeSocket, 0, NULL);
|
||||||
watcher->addr);
|
|
||||||
socket_watcher_accept(watcher, &channel->data.stream);
|
socket_watcher_accept(watcher, &channel->data.stream);
|
||||||
incref(channel); // close channel only after the stream is closed
|
incref(channel); // close channel only after the stream is closed
|
||||||
channel->data.stream.internal_close_cb = close_cb;
|
channel->data.stream.internal_close_cb = close_cb;
|
||||||
@@ -156,9 +152,8 @@ void channel_from_connection(SocketWatcher *watcher)
|
|||||||
&channel->data.stream);
|
&channel->data.stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param source description of source function, rplugin name, TCP addr, etc
|
uint64_t channel_connect(bool tcp, const char *address,
|
||||||
uint64_t channel_connect(bool tcp, const char *address, int timeout,
|
int timeout, const char **error)
|
||||||
char *source, const char **error)
|
|
||||||
{
|
{
|
||||||
if (!tcp) {
|
if (!tcp) {
|
||||||
char *path = fix_fname(address);
|
char *path = fix_fname(address);
|
||||||
@@ -170,7 +165,7 @@ uint64_t channel_connect(bool tcp, const char *address, int timeout,
|
|||||||
xfree(path);
|
xfree(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel *channel = register_channel(kChannelTypeSocket, 0, NULL, source);
|
Channel *channel = register_channel(kChannelTypeSocket, 0, NULL);
|
||||||
if (!socket_connect(&main_loop, &channel->data.stream,
|
if (!socket_connect(&main_loop, &channel->data.stream,
|
||||||
tcp, address, timeout, error)) {
|
tcp, address, timeout, error)) {
|
||||||
decref(channel);
|
decref(channel);
|
||||||
@@ -323,10 +318,11 @@ bool channel_close(uint64_t id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an API channel from stdin/stdout. Used to embed Nvim.
|
/// Creates an API channel from stdin/stdout. This is used when embedding
|
||||||
|
/// Neovim
|
||||||
void channel_from_stdio(void)
|
void channel_from_stdio(void)
|
||||||
{
|
{
|
||||||
Channel *channel = register_channel(kChannelTypeStdio, 0, NULL, NULL);
|
Channel *channel = register_channel(kChannelTypeStdio, 0, NULL);
|
||||||
incref(channel); // stdio channels are only closed on exit
|
incref(channel); // stdio channels are only closed on exit
|
||||||
// read stream
|
// read stream
|
||||||
rstream_init_fd(&main_loop, &channel->data.std.in, 0, CHANNEL_BUFFER_SIZE);
|
rstream_init_fd(&main_loop, &channel->data.std.in, 0, CHANNEL_BUFFER_SIZE);
|
||||||
@@ -342,7 +338,7 @@ void channel_from_stdio(void)
|
|||||||
/// when an instance connects to its own named pipe.
|
/// when an instance connects to its own named pipe.
|
||||||
uint64_t channel_create_internal(void)
|
uint64_t channel_create_internal(void)
|
||||||
{
|
{
|
||||||
Channel *channel = register_channel(kChannelTypeInternal, 0, NULL, NULL);
|
Channel *channel = register_channel(kChannelTypeInternal, 0, NULL);
|
||||||
incref(channel); // internal channel lives until process exit
|
incref(channel); // internal channel lives until process exit
|
||||||
return channel->id;
|
return channel->id;
|
||||||
}
|
}
|
||||||
@@ -778,12 +774,9 @@ static void close_cb(Stream *stream, void *data)
|
|||||||
decref(data);
|
decref(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param source description of source function, rplugin name, TCP addr, etc
|
|
||||||
static Channel *register_channel(ChannelType type, uint64_t id,
|
static Channel *register_channel(ChannelType type, uint64_t id,
|
||||||
MultiQueue *events, char *source)
|
MultiQueue *events)
|
||||||
{
|
{
|
||||||
// Jobs and channels share the same id namespace.
|
|
||||||
assert(id == 0 || !pmap_get(uint64_t)(channels, id));
|
|
||||||
Channel *rv = xmalloc(sizeof(Channel));
|
Channel *rv = xmalloc(sizeof(Channel));
|
||||||
rv->events = events ? events : multiqueue_new_child(main_loop.events);
|
rv->events = events ? events : multiqueue_new_child(main_loop.events);
|
||||||
rv->type = type;
|
rv->type = type;
|
||||||
@@ -795,14 +788,6 @@ static Channel *register_channel(ChannelType type, uint64_t id,
|
|||||||
rv->next_request_id = 1;
|
rv->next_request_id = 1;
|
||||||
kv_init(rv->call_stack);
|
kv_init(rv->call_stack);
|
||||||
pmap_put(uint64_t)(channels, rv->id, rv);
|
pmap_put(uint64_t)(channels, rv->id, rv);
|
||||||
|
|
||||||
ILOG("new channel %" PRIu64 " (%s): %s", rv->id,
|
|
||||||
(type == kChannelTypeProc ? "proc"
|
|
||||||
: (type == kChannelTypeSocket ? "socket"
|
|
||||||
: (type == kChannelTypeStdio ? "stdio"
|
|
||||||
: (type == kChannelTypeInternal ? "internal" : "?")))),
|
|
||||||
(source ? source : "?"));
|
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user