Changeset: 800531013dc2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=800531013dc2
Modified Files:
        tools/merovingian/daemon/controlrunner.c
Branch: Oct2020
Log Message:

Simplify code.


diffs (43 lines):

diff --git a/tools/merovingian/daemon/controlrunner.c 
b/tools/merovingian/daemon/controlrunner.c
--- a/tools/merovingian/daemon/controlrunner.c
+++ b/tools/merovingian/daemon/controlrunner.c
@@ -489,30 +489,19 @@ static void ctl_handle_client(
                                                } else if (child > 0) {
                                                        /* this is the parent 
process */
                                                        close(pipes[0]);
-                                                       if (write(pipes[1], p, 
strlen(p)) < 0 || write(pipes[1], "\n", 1) < 0) {
-                                                               close(pipes[1]);
+                                                       bool err = 
write(pipes[1], p, strlen(p)) < 0 || write(pipes[1], "\n", 1) < 0;
+                                                       close(pipes[1]);
+                                                       /* wait for the child 
to finish */
+                                                       int status;
+                                                       waitpid(child, &status, 
0);
+                                                       if (err || 
!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
                                                                
Mfprintf(_mero_ctlerr,
-                                                                               
 "%s: initial communication with database '%s' failed: %s\n",
-                                                                               
 origin, q, strerror(errno));
+                                                                               
 "%s: initialization of database '%s' failed\n",
+                                                                               
 origin, q);
                                                                len = 
snprintf(buf2, sizeof(buf2),
-                                                                               
"initial communication with database '%s' failed: %s\n",
-                                                                               
q, strerror(errno));
+                                                                               
           "initialization of database '%s' failed\n", q);
                                                                
send_client("!");
                                                                continue;
-                                                       } else {
-                                                               close(pipes[1]);
-                                                               /* wait for the 
child to finish */
-                                                               int status;
-                                                               waitpid(child, 
&status, 0);
-                                                               if 
(!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
-                                                                       
Mfprintf(_mero_ctlerr,
-                                                                               
        "%s: initialization of database '%s' failed\n",
-                                                                               
        origin, q);
-                                                                       len = 
snprintf(buf2, sizeof(buf2),
-                                                                               
        "initialization of database '%s' failed\n", q);
-                                                                       
send_client("!");
-                                                                       
continue;
-                                                               }
                                                        }
                                                } else {
                                                        close(pipes[0]);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to