Fix kitty discarding peer messages in rapid succession
This commit is contained in:
parent
fe3bb92b54
commit
6352f585e8
@ -97,23 +97,24 @@ class Boss:
|
|||||||
self.child_monitor.add_child(window.id, window.child.pid, window.child.child_fd, window.screen)
|
self.child_monitor.add_child(window.id, window.child.pid, window.child.child_fd, window.screen)
|
||||||
self.window_id_map[window.id] = window
|
self.window_id_map[window.id] = window
|
||||||
|
|
||||||
def peer_msg_received(self, msg):
|
def peer_messages_received(self, messages):
|
||||||
import json
|
import json
|
||||||
msg = json.loads(msg.decode('utf-8'))
|
for msg in messages:
|
||||||
if isinstance(msg, dict) and msg.get('cmd') == 'new_instance':
|
msg = json.loads(msg.decode('utf-8'))
|
||||||
startup_id = msg.get('startup_id')
|
if isinstance(msg, dict) and msg.get('cmd') == 'new_instance':
|
||||||
args, rest = parse_args(msg['args'][1:])
|
startup_id = msg.get('startup_id')
|
||||||
args.args = rest
|
args, rest = parse_args(msg['args'][1:])
|
||||||
opts = create_opts(args)
|
args.args = rest
|
||||||
session = create_session(opts, args)
|
opts = create_opts(args)
|
||||||
os_window_id = self.add_os_window(session, wclass=args.cls, wname=args.name, size=initial_window_size(opts), visible=False)
|
session = create_session(opts, args)
|
||||||
if startup_id:
|
os_window_id = self.add_os_window(session, wclass=args.cls, wname=args.name, size=initial_window_size(opts), visible=False)
|
||||||
ctx = init_startup_notification(os_window_id, startup_id)
|
if startup_id:
|
||||||
show_window(os_window_id)
|
ctx = init_startup_notification(os_window_id, startup_id)
|
||||||
if startup_id:
|
show_window(os_window_id)
|
||||||
end_startup_notification(ctx)
|
if startup_id:
|
||||||
else:
|
end_startup_notification(ctx)
|
||||||
safe_print('Unknown message received from peer, ignoring')
|
else:
|
||||||
|
safe_print('Unknown message received from peer, ignoring')
|
||||||
|
|
||||||
def on_child_death(self, window_id):
|
def on_child_death(self, window_id):
|
||||||
window = self.window_id_map.pop(window_id, None)
|
window = self.window_id_map.pop(window_id, None)
|
||||||
|
|||||||
@ -339,11 +339,15 @@ parse_input(ChildMonitor *self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (UNLIKELY(self->messages_count)) {
|
if (UNLIKELY(self->messages_count)) {
|
||||||
while(self->messages_count) {
|
msg = PyTuple_New(self->messages_count);
|
||||||
Message *m = self->messages + --self->messages_count;
|
if (msg) {
|
||||||
msg = PyBytes_FromStringAndSize(m->data, m->sz);
|
for (size_t i = 0; i < self->messages_count; i++) {
|
||||||
free(m->data); m->data = NULL; m->sz = 0;
|
Message *m = self->messages + i;
|
||||||
}
|
PyTuple_SET_ITEM(msg, i, PyBytes_FromStringAndSize(m->data, m->sz));
|
||||||
|
free(m->data); m->data = NULL; m->sz = 0;
|
||||||
|
}
|
||||||
|
self->messages_count = 0;
|
||||||
|
} else fatal("Out of memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UNLIKELY(signal_received)) {
|
if (UNLIKELY(signal_received)) {
|
||||||
@ -357,7 +361,7 @@ parse_input(ChildMonitor *self) {
|
|||||||
}
|
}
|
||||||
children_mutex(unlock);
|
children_mutex(unlock);
|
||||||
if (msg) {
|
if (msg) {
|
||||||
call_boss(peer_msg_received, "O", msg);
|
call_boss(peer_messages_received, "(O)", msg);
|
||||||
Py_CLEAR(msg);
|
Py_CLEAR(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user