Remove Linux kernel version ambiguity in comment added by previous commit.
[platform/upstream/glibc.git] / nscd / grpcache.c
index d25d8e9..5658792 100644 (file)
@@ -75,8 +75,8 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
             const void *key, struct group *grp, uid_t owner,
             struct hashentry *const he, struct datahead *dh, int errval)
 {
+  bool all_written = true;
   ssize_t total;
-  ssize_t written;
   time_t t = time (NULL);
 
   /* We allocate all data in one memory block: the iov vector,
@@ -105,7 +105,7 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
          /* Reload with the same time-to-live value.  */
          timeout = dh->timeout = t + db->postimeout;
 
-         written = total = 0;
+         total = 0;
        }
       else
        {
@@ -113,11 +113,10 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
             case.  */
          total = sizeof (notfound);
 
-         if (fd != -1)
-           written = TEMP_FAILURE_RETRY (send (fd, &notfound, total,
-                                               MSG_NOSIGNAL));
-         else
-           written = total;
+         if (fd != -1
+             && TEMP_FAILURE_RETRY (send (fd, &notfound, total,
+                                          MSG_NOSIGNAL)) != total)
+           all_written = false;
 
          /* If we have a transient error or cannot permanently store
             the result, so be it.  */
@@ -197,9 +196,9 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
          gr_mem_len_total += gr_mem_len[gr_mem_cnt];
        }
 
-      written = total = (offsetof (struct dataset, strdata)
-                        + gr_mem_cnt * sizeof (uint32_t)
-                        + gr_name_len + gr_passwd_len + gr_mem_len_total);
+      total = (offsetof (struct dataset, strdata)
+              + gr_mem_cnt * sizeof (uint32_t)
+              + gr_name_len + gr_passwd_len + gr_mem_len_total);
 
       /* If we refill the cache, first assume the reconrd did not
         change.  Allocate memory on the cache since it is likely
@@ -328,20 +327,27 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
                      <= (sizeof (struct database_pers_head)
                          + db->head->module * sizeof (ref_t)
                          + db->head->data_size));
-             written = sendfileall (fd, db->wr_fd,
-                                    (char *) &dataset->resp
-                                    - (char *) db->head, dataset->head.recsize);
+             ssize_t written = sendfileall (fd, db->wr_fd,
+                                            (char *) &dataset->resp
+                                            - (char *) db->head,
+                                            dataset->head.recsize);
+             if (written != dataset->head.recsize)
+               {
 # ifndef __ASSUME_SENDFILE
-             if (written == -1 && errno == ENOSYS)
-               goto use_write;
+                 if (written == -1 && errno == ENOSYS)
+                   goto use_write;
 # endif
+                 all_written = false;
+               }
            }
          else
 # ifndef __ASSUME_SENDFILE
          use_write:
 # endif
 #endif
-           written = writeall (fd, &dataset->resp, dataset->head.recsize);
+           if (writeall (fd, &dataset->resp, dataset->head.recsize)
+               != dataset->head.recsize)
+             all_written = false;
        }
 
       /* Add the record to the database.  But only if it has not been
@@ -401,7 +407,7 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
        }
     }
 
-  if (__builtin_expect (written != total, 0) && debug_level > 0)
+  if (__builtin_expect (!all_written, 0) && debug_level > 0)
     {
       char buf[256];
       dbg_log (_("short write in %s: %s"),  __FUNCTION__,