On 16/03/17 10:09, Grazvydas Ignotas wrote:
Simplifies the write code a bit and handles EINTR.

Signed-off-by: Grazvydas Ignotas <nota...@gmail.com>
---
 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?

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to