diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Read and write slot keys and pages in full
xread and xwrite may move fewer bytes than asked. A short write of the
key left a slot that could never match, a short read of it reported a
collision, and a page write that moved nothing looped for ever.
Diffstat (limited to 'source')
| -rw-r--r-- | source/cache.c | 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/html.c | 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 files changed, 7 insertions, 3 deletions
diff --git a/source/cache.c b/source/cache.c index 60e071b..af391db 100644 --- a/source/cache.c +++ b/source/cache.c @@ -85,7 +85,7 @@ static int open_slot(struct cache_slot *slot) if (fstat(slot->cache_fd, &slot->st)) return errno; - slot->buflen = xread(slot->cache_fd, slot->buf, sizeof(slot->buf)); + slot->buflen = read_in_full(slot->cache_fd, slot->buf, sizeof(slot->buf)); if (slot->buflen < 0) return errno; @@ -265,7 +265,7 @@ static int lock_slot(struct cache_slot *slot) // start from empty now that nobody else can be writing it. if (ftruncate(slot->lock_fd, 0) < 0) return errno; - if (xwrite(slot->lock_fd, slot->key, slot->keylen + 1) < 0) + if (write_in_full(slot->lock_fd, slot->key, slot->keylen + 1) < 0) return errno; return 0; } diff --git a/source/html.c b/source/html.c index ef74bb3..367cea7 100644 --- a/source/html.c +++ b/source/html.c @@ -65,7 +65,11 @@ static void write_out(const char *data, size_t size) while (size) { ssize_t written = xwrite(STDOUT_FILENO, data, size); - if (written < 0) + // A write that moves nothing would repeat for ever, so it + // counts as a full device, the way write_in_full treats it. + if (!written) + errno = ENOSPC; + if (written <= 0) break; data += written; size -= written; |
