aboutsummaryrefslogtreecommitdiff
path: root/jim-aio.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2022-04-05 08:36:50 +1000
committerSteve Bennett <steveb@workware.net.au>2022-04-05 08:36:50 +1000
commita4adf6021e817dc0dd6f1028f0b4f9a7abbeae5a (patch)
treec456b8caef9a378490a153c4c73afba86f3e1edb /jim-aio.c
parentb0271cca8e335a1ebe4e3d6a8889bd4d7d5e30e6 (diff)
downloadjimtcl-a4adf6021e817dc0dd6f1028f0b4f9a7abbeae5a.zip
jimtcl-a4adf6021e817dc0dd6f1028f0b4f9a7abbeae5a.tar.gz
jimtcl-a4adf6021e817dc0dd6f1028f0b4f9a7abbeae5a.tar.bz2
aio: read: better handling of -pending
Once we determine the number of pending bytes to read, there is no need to read one at a time. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-aio.c')
-rw-r--r--jim-aio.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/jim-aio.c b/jim-aio.c
index 8315c35..4b3237f 100644
--- a/jim-aio.c
+++ b/jim-aio.c
@@ -742,13 +742,16 @@ static int aio_cmd_read(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
int retval;
int readlen;
- if (neededLen == -1) {
+ if (pending) {
+ readlen = 1;
+ }
+ else if (neededLen == -1) {
readlen = AIO_BUF_LEN;
}
else {
readlen = (neededLen > AIO_BUF_LEN ? AIO_BUF_LEN : neededLen);
}
- retval = af->fops->reader(af, buf, pending ? 1 : readlen);
+ retval = af->fops->reader(af, buf, readlen);
if (retval > 0) {
Jim_AppendString(interp, objPtr, buf, retval);
if (neededLen != -1) {
@@ -759,6 +762,7 @@ static int aio_cmd_read(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
* we do a second read to fetch any buffered data
*/
neededLen = af->fops->pending(af);
+ pending = 0;
}
}
if (retval <= 0) {