only loop over the write it the write failed
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 26 Jun 2008 01:02:08 +0000 (11:02 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 26 Jun 2008 01:02:08 +0000 (11:02 +1000)
server/ctdb_freeze.c

index 4e9e8c11e22d243ab91084c60c5449fe79d1483c..a6a9ca29f6f4aed83036f4f475d6f3361b444dd4 100644 (file)
@@ -142,7 +142,6 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb)
 
        if (h->child == 0) {
                int ret;
-               int count = 0;
 
                /* in the child */
                close(fd[0]);
@@ -150,12 +149,13 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb)
                if (ret != 0) {
                        _exit(0);
                }
-               while (count++ < 30) {
-                       ret = write(fd[1], &ret, sizeof(ret));
-                       if (ret != sizeof(ret)) {
-                               DEBUG(DEBUG_ERR, (__location__ " Failed to write to socket from freeze child. ret:%d errno:%u\n", ret, errno));
-                       }
+
+try_again:
+               ret = write(fd[1], &ret, sizeof(ret));
+               if (ret != sizeof(ret)) {
+                       DEBUG(DEBUG_ERR, (__location__ " Failed to write to socket from freeze child. ret:%d errno:%u\n", ret, errno));
                        sleep (1);
+                       goto try_again;
                }
 
                /* the read here means we will die if the parent exits */