Commit a714959a authored by jan.koester's avatar jan.koester
Browse files

test

parent 0d5ee6b2
Loading
Loading
Loading
Loading
+13 −3
Changes for src/busserver.cpp: 13 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -134,15 +134,25 @@ void BusServer::accept() {
void BusServer::serve(int fd) {
    auto it = _clients.find(fd);
    if (it == _clients.end()) return;
    char buf[4096];
    Client &c = it->second;
    // what is there, up to one message's worth: the main loop comes back
    // here only every few 100 ms when it has other work
    char buf[65536];
    for (size_t got = 0; got < sysbus::MaxPayload;) {
        ssize_t n = ::read(fd, buf, sizeof(buf));
        if (n < 0 && errno == EINTR) continue;
        if (n < 0 && errno == EAGAIN) {
            if (!got) return;
            break;
        }
        if (n <= 0) {
        if (n < 0 && (errno == EINTR || errno == EAGAIN)) return;
            if (got) break;  // what came before the end still counts
            drop(fd);
            return;
        }
    Client &c = it->second;
        c.decoder.feed(buf, static_cast<size_t>(n));
        got += static_cast<size_t>(n);
    }

    sysbus::Message msg;
    while (c.decoder.next(msg)) {