Pass failure to send data to child because of full buffer up the stack
This commit is contained in:
parent
672cf9fffe
commit
495981bade
@ -245,7 +245,6 @@ schedule_write_to_child(unsigned long id, unsigned int num, ...) {
|
||||
children_mutex(lock);
|
||||
for (size_t i = 0; i < self->count; i++) {
|
||||
if (children[i].id == id) {
|
||||
found = true;
|
||||
Screen *screen = children[i].screen;
|
||||
screen_mutex(lock, write);
|
||||
size_t space_left = screen->write_buf_sz - screen->write_buf_used;
|
||||
@ -259,6 +258,7 @@ schedule_write_to_child(unsigned long id, unsigned int num, ...) {
|
||||
screen->write_buf = PyMem_RawRealloc(screen->write_buf, screen->write_buf_sz);
|
||||
if (screen->write_buf == NULL) { fatal("Out of memory."); }
|
||||
}
|
||||
found = true;
|
||||
va_start(ap, num);
|
||||
for (unsigned int i = 0; i < num; i++) {
|
||||
data = va_arg(ap, const char*);
|
||||
|
||||
@ -992,7 +992,7 @@ class Screen:
|
||||
def resize(self, width: int, height: int) -> None:
|
||||
pass
|
||||
|
||||
def send_escape_code_to_child(self, code: int, text: str) -> None:
|
||||
def send_escape_code_to_child(self, code: int, text: str) -> bool:
|
||||
pass
|
||||
|
||||
def reset_callbacks(self) -> None:
|
||||
|
||||
@ -755,14 +755,17 @@ write_to_test_child(Screen *self, const char *data, size_t sz) {
|
||||
PyObject *r = PyObject_CallMethod(self->test_child, "write", "y#", data, sz); if (r == NULL) PyErr_Print(); Py_CLEAR(r);
|
||||
}
|
||||
|
||||
static void
|
||||
static bool
|
||||
write_to_child(Screen *self, const char *data, size_t sz) {
|
||||
if (self->window_id) schedule_write_to_child(self->window_id, 1, data, sz);
|
||||
bool written = false;
|
||||
if (self->window_id) written = schedule_write_to_child(self->window_id, 1, data, sz);
|
||||
if (self->test_child != Py_None) { write_to_test_child(self, data, sz); }
|
||||
return written;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
write_escape_code_to_child(Screen *self, unsigned char which, const char *data) {
|
||||
bool written = false;
|
||||
const char *prefix, *suffix = self->modes.eight_bit_controls ? "\x9c" : "\033\\";
|
||||
switch(which) {
|
||||
case DCS:
|
||||
@ -785,9 +788,9 @@ write_escape_code_to_child(Screen *self, unsigned char which, const char *data)
|
||||
}
|
||||
if (self->window_id) {
|
||||
if (suffix[0]) {
|
||||
schedule_write_to_child(self->window_id, 3, prefix, strlen(prefix), data, strlen(data), suffix, strlen(suffix));
|
||||
written = schedule_write_to_child(self->window_id, 3, prefix, strlen(prefix), data, strlen(data), suffix, strlen(suffix));
|
||||
} else {
|
||||
schedule_write_to_child(self->window_id, 2, prefix, strlen(prefix), data, strlen(data));
|
||||
written = schedule_write_to_child(self->window_id, 2, prefix, strlen(prefix), data, strlen(data));
|
||||
}
|
||||
}
|
||||
if (self->test_child != Py_None) {
|
||||
@ -795,6 +798,7 @@ write_escape_code_to_child(Screen *self, unsigned char which, const char *data)
|
||||
write_to_test_child(self, data, strlen(data));
|
||||
if (suffix[0]) write_to_test_child(self, suffix, strlen(suffix));
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -3162,8 +3166,8 @@ send_escape_code_to_child(Screen *self, PyObject *args) {
|
||||
int code;
|
||||
char *text;
|
||||
if (!PyArg_ParseTuple(args, "is", &code, &text)) return NULL;
|
||||
write_escape_code_to_child(self, code, text);
|
||||
Py_RETURN_NONE;
|
||||
if (write_escape_code_to_child(self, code, text)) Py_RETURN_TRUE;
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@ -144,7 +144,7 @@ void screen_restore_cursor(Screen *);
|
||||
void screen_save_cursor(Screen *);
|
||||
void screen_restore_modes(Screen *);
|
||||
void screen_save_modes(Screen *);
|
||||
void write_escape_code_to_child(Screen *self, unsigned char which, const char *data);
|
||||
bool write_escape_code_to_child(Screen *self, unsigned char which, const char *data);
|
||||
void screen_cursor_position(Screen*, unsigned int, unsigned int);
|
||||
void screen_cursor_back(Screen *self, unsigned int count/*=1*/, int move_direction/*=-1*/);
|
||||
void screen_erase_in_line(Screen *, unsigned int, bool);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user