dj(1): fix inaccurate statistics after Io_read and Io_write
This commit is contained in:
parent
906eb92f5a
commit
9e8b82c4bb
13
src/dj.c
13
src/dj.c
@ -69,16 +69,19 @@ static int write_flags = O_WRONLY | O_CREAT;
|
||||
|
||||
static struct Io *
|
||||
Io_read(struct Io *io){
|
||||
int t;
|
||||
|
||||
assert(io->bs > 0);
|
||||
assert(io->bufuse < io->bs);
|
||||
|
||||
io->bytes += (io->bufuse = read(io->fd, &(io->buf)[io->bufuse],
|
||||
io->bufuse += (t = read(io->fd, &(io->buf)[io->bufuse],
|
||||
io->bs - io->bufuse));
|
||||
|
||||
assert(io->bufuse <= io->bs);
|
||||
|
||||
io->prec += (0 < io->bufuse && io->bufuse < io->bs);
|
||||
io->rec += (io->bufuse == io->bs);
|
||||
io->bytes += t;
|
||||
io->prec += (0 < io->bufuse && io->bufuse < io->bs);
|
||||
io->rec += (io->bufuse == io->bs);
|
||||
|
||||
return io;
|
||||
}
|
||||
@ -94,8 +97,8 @@ Io_write(struct Io *io){
|
||||
memmove(io->buf, &(io->buf)[t], (io->bufuse -= t));
|
||||
|
||||
io->bytes += t;
|
||||
io->prec += (t > 0 && io->bufuse > 0);
|
||||
io->rec += (t > 0 && io->bufuse == 0);
|
||||
io->prec += (0 < io->bufuse && 0 < t);
|
||||
io->rec += (io->bufuse == 0 && 0 < t);
|
||||
|
||||
return io;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user