X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fpty.c;h=6863be654eaa676a4f82cc12af45b6f2ebb2cecd;hb=086821244b5113f00a0ef993b78dc56aae2a8f6c;hp=adcb32d0be733af138ceb7bec97821065d6cb016;hpb=cf4acf84c6304d34108dadd5e87c9a19ca24dceb;p=elogind.git diff --git a/src/shared/pty.c b/src/shared/pty.c index adcb32d0b..6863be654 100644 --- a/src/shared/pty.c +++ b/src/shared/pty.c @@ -67,7 +67,7 @@ #include "ring.h" #include "util.h" -#define PTY_BUFSIZE 16384 +#define PTY_BUFSIZE 4096 enum { PTY_ROLE_UNKNOWN, @@ -194,13 +194,13 @@ int pty_get_fd(Pty *pty) { } int pty_make_child(Pty *pty) { - char slave_name[1024]; + _cleanup_free_ char *slave_name = NULL; int r, fd; assert_return(pty, -EINVAL); assert_return(pty_is_unknown(pty), -EALREADY); - r = ptsname_r(pty->fd, slave_name, sizeof(slave_name)); + r = ptsname_malloc(pty->fd, &slave_name); if (r < 0) return -errno; @@ -305,11 +305,11 @@ static int pty_dispatch_read(Pty *pty) { /* * We're edge-triggered, means we need to read the whole queue. This, * however, might cause us to stall if the writer is faster than we - * are. Therefore, we read twice and if the second read still returned - * data, we reschedule. + * are. Therefore, try reading as much as 8 times (32KiB) and only + * bail out then. */ - for (i = 0; i < 2; ++i) { + for (i = 0; i < 8; ++i) { len = read(pty->fd, pty->in_buf, sizeof(pty->in_buf) - 1); if (len < 0) { if (errno == EINTR)