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