On 16/03/17 23:53, Grazvydas Ignotas wrote:
On Thu, Mar 16, 2017 at 3:00 AM, Timothy Arceri <[email protected]> wrote:
On 16/03/17 10:09, Grazvydas Ignotas wrote:
Simplifies the write code a bit and handles EINTR.
Signed-off-by: Grazvydas Ignotas <[email protected]>
---
src/util/disk_cache.c | 40 ++++++++++++++++++++++++++--------------
1 file changed, 26 insertions(+), 14 deletions(-)
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 904aa66..ad591be 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -650,6 +650,24 @@ disk_cache_remove(struct disk_cache *cache, const
cache_key key)
p_atomic_add(cache->size, - (uint64_t)sb.st_size);
}
+static ssize_t
+write_all(int fd, const void *buf, size_t count)
+{
+ const char *out = buf;
+ ssize_t written;
+ size_t done;
+
+ for (done = 0; done < count; done += written) {
+ written = write(fd, out + done, count - done);
+ if (written == -1) {
+ if (errno != EINTR)
+ return -1;
+ written = 0;
I considered doing this but it didn't seem worth it. Also should you add a
retry limit? It's probably unlikely but I guess we could get stuck in a loop
here in theory?
After this series there are 3 users which is enough I'd say. As for
looping check, it wasn't there before so I've not bothered, on resend
I can add it.
The helper is fine, I meant it didn't seem worth retrying on EINTR.
There was no loop check before because we just exited when write()
returned -1.
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev