Re-name and fix documentation for ss_read().
authorDavin McCall <davmac@davmac.org>
Sat, 20 Oct 2018 11:19:31 +0000 (12:19 +0100)
committerDavin McCall <davmac@davmac.org>
Sat, 20 Oct 2018 11:19:31 +0000 (12:19 +0100)
The function actually reads until the complete requested amount is read
(or it hits end-of-file or another error).

src/includes/dinit-util.h
src/proc-service.cc

index caedbdd2c0d77dff4785dd213099f8afa111bdd8..da577099d44a702adde49e8f9e5cea53a9a46ccc 100644 (file)
@@ -7,9 +7,9 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-// Signal-safe read. Read and re-try if interrupted by signal (EINTR).
-// *May* affect errno even on a successful read (when the return is less than n).
-inline ssize_t ss_read(int fd, void * buf, size_t n)
+// Complete read - read the specified size until end-of-file or error; continue read if
+// interrupted by signal.
+inline ssize_t complete_read(int fd, void * buf, size_t n)
 {
     char * cbuf = static_cast<char *>(buf);
     ssize_t r = 0;
index d664142dd00b55bbc38bc50ba96608b3b356d688..e6ad098e09ba02160cf7340721a436afe4797ffa 100644 (file)
@@ -407,7 +407,7 @@ bgproc_service::read_pid_file(bp_sys::exit_status *exit_status) noexcept
     }
 
     char pidbuf[21]; // just enough to hold any 64-bit integer
-    int r = ss_read(fd, pidbuf, 20);
+    int r = complete_read(fd, pidbuf, 20);
     if (r < 0) {
         // Could not read from PID file
         log(loglevel_t::ERROR, get_name(), ": could not read from pidfile; ", strerror(errno));