Explicitly set errno on EOF
authorWouter Verhelst <w@uter.be>
Fri, 7 Sep 2018 08:51:21 +0000 (10:51 +0200)
committerWouter Verhelst <w@uter.be>
Fri, 7 Sep 2018 08:51:21 +0000 (10:51 +0200)
When we reach EOF, that means the other end dropped connection on us,
for which the ECONNRESET errno value is appropriate. However, read()
won't set that by itself, so we need to do it.

This function is also called to read data from our backend export file;
but in that case we know what the size of the export file is and won't
even try to read beyond EOF, so don't worry about that fact.

Fixes: gh-83

cliserv.c

index 67137b8..46a790e 100644 (file)
--- a/cliserv.c
+++ b/cliserv.c
@@ -124,6 +124,7 @@ int readit(int f, void *buf, size_t len) {
                                return -1;
                        }
                } else {
+                       errno = ECONNRESET;
                        return -1;
                }
        }