X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fpty.c;h=52a426c0e15fd8314571570bcb94f8291cc3ae85;hb=0c124f8b2c93d2c7d6eefca3bdc59b28250fc077;hp=11d76f825fd890d2569ba52924cf035047816424;hpb=a47d1dfd0823cd3978dd10e217dadcee7e01b265;p=elogind.git diff --git a/src/shared/pty.c b/src/shared/pty.c index 11d76f825..52a426c0e 100644 --- a/src/shared/pty.c +++ b/src/shared/pty.c @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include @@ -67,7 +67,7 @@ #include "ring.h" #include "util.h" -#define PTY_BUFSIZE 16384 +#define PTY_BUFSIZE 4096 enum { PTY_ROLE_UNKNOWN, @@ -105,6 +105,7 @@ int pty_new(Pty **out) { pty->ref = 1; pty->fd = -1; + pty->barrier = (Barrier) BARRIER_NULL; pty->fd = posix_openpt(O_RDWR | O_NOCTTY | O_CLOEXEC | O_NONBLOCK); if (pty->fd < 0) @@ -127,7 +128,7 @@ int pty_new(Pty **out) { if (r < 0) return -errno; - r = barrier_init(&pty->barrier); + r = barrier_create(&pty->barrier); if (r < 0) return r; @@ -304,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)