From: Jerome Flesch <[email protected]>

Backport

Signed-off-by: Jerome Flesch <[email protected]>
Reviewed-by: Jan Friesse<[email protected]>
---
 exec/coroipcs.c          |    2 +-
 exec/coropoll.c          |    8 ++++++--
 exec/main.c              |   17 ++++++++++++++---
 exec/totemconfig.c       |    2 +-
 exec/util.h              |    1 +
 tools/corosync-notifyd.c |    6 +++++-
 6 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/exec/coroipcs.c b/exec/coroipcs.c
index 5c9f938..80df360 100644
--- a/exec/coroipcs.c
+++ b/exec/coroipcs.c
@@ -1242,7 +1242,7 @@ static void memcpy_dwrap (struct conn_info *conn_info, 
void *msg, unsigned int l
        write_idx = conn_info->control_buffer->write;
 
        memcpy (&conn_info->dispatch_buffer[write_idx], msg, len);
-       conn_info->control_buffer->write = ((write_idx + len + 7) & 
0xFFFFFFFF8) % conn_info->dispatch_size;
+       conn_info->control_buffer->write = ((write_idx + len + 7) & 0xFFFFFFF8) 
% conn_info->dispatch_size;
 }
 
 static void msg_send (void *conn, const struct iovec *iov, unsigned int 
iov_len,
diff --git a/exec/coropoll.c b/exec/coropoll.c
index 95978df..4fc30a2 100644
--- a/exec/coropoll.c
+++ b/exec/coropoll.c
@@ -258,7 +258,9 @@ int poll_dispatch_modify (
                        poll_instance->poll_entries[i].dispatch_fn = 
dispatch_fn;
                        if (change_notify) {
                                char buf = 1;
-                               write (poll_instance->pipefds[1], &buf, 1);
+retry_write:
+                               if (write (poll_instance->pipefds[1], &buf, 1) 
< 0 && errno == EINTR )
+                                       goto retry_write;
                        }
 
                        goto error_put;
@@ -499,7 +501,9 @@ retry_poll:
 
                if (poll_instance->ufds[0].revents) {
                        char buf;
-                       read (poll_instance->ufds[0].fd, &buf, 1);
+retry_read:
+                       if (read (poll_instance->ufds[0].fd, &buf, 1) < 0 && 
errno == EINTR)
+                               goto retry_read;
                        goto rebuild_poll;
                }
                poll_entry_count = poll_instance->poll_entry_count;
diff --git a/exec/main.c b/exec/main.c
index 774d618..5f0edaa 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -489,6 +489,8 @@ static void priv_drop (void)
 
 static void corosync_tty_detach (void)
 {
+       FILE *r;
+
        /*
         * Disconnect from TTY if this is not a debug run
         */
@@ -513,9 +515,18 @@ static void corosync_tty_detach (void)
        /*
         * Map stdin/out/err to /dev/null.
         */
-       freopen("/dev/null", "r", stdin);
-       freopen("/dev/null", "a", stderr);
-       freopen("/dev/null", "a", stdout);
+       r = freopen("/dev/null", "r", stdin);
+       if (r == NULL) {
+               corosync_exit_error (AIS_DONE_STD_TO_NULL_REDIR);
+       }
+       r = freopen("/dev/null", "a", stderr);
+       if (r == NULL) {
+               corosync_exit_error (AIS_DONE_STD_TO_NULL_REDIR);
+       }
+       r = freopen("/dev/null", "a", stdout);
+       if (r == NULL) {
+               corosync_exit_error (AIS_DONE_STD_TO_NULL_REDIR);
+       }
 }
 
 static void corosync_mlockall (void)
diff --git a/exec/totemconfig.c b/exec/totemconfig.c
index c18c272..f6646e7 100644
--- a/exec/totemconfig.c
+++ b/exec/totemconfig.c
@@ -474,7 +474,7 @@ int totem_config_validate (
                        goto parse_error;
                }
 
-               if (totem_config->interfaces[i].ttl > 255 || 
totem_config->interfaces[i].ttl < 0) {
+               if (totem_config->interfaces[i].ttl > 255) {
                        error_reason = "Invalid TTL (should be 0..255)";
                        goto parse_error;
                }
diff --git a/exec/util.h b/exec/util.h
index b5f3abe..263919b 100644
--- a/exec/util.h
+++ b/exec/util.h
@@ -63,6 +63,7 @@ enum e_ais_done {
        AIS_DONE_DIR_NOT_PRESENT = 16,
        AIS_DONE_AQUIRE_LOCK = 17,
        AIS_DONE_ALREADY_RUNNING = 18,
+       AIS_DONE_STD_TO_NULL_REDIR = 19,
 };
 
 static inline cs_error_t hdb_error_to_cs (int res)             \
diff --git a/tools/corosync-notifyd.c b/tools/corosync-notifyd.c
index ee2f7a0..5ac2b83 100644
--- a/tools/corosync-notifyd.c
+++ b/tools/corosync-notifyd.c
@@ -1030,7 +1030,11 @@ main(int argc, char *argv[])
        _cs_check_config();
 
        if (!conf[CS_NTF_FG]) {
-               daemon(0, 0);
+               if (daemon(0, 0) < 0)
+               {
+                       perror("daemon() failed");
+                       return EXIT_FAILURE;
+               }
        }
 
        num_notifiers = 0;
-- 
1.7.1

_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to