---
 exec/coroipcs.c          |    2 +-
 exec/coropoll.c          |    8 ++++++--
 exec/main.c              |   14 +++++++++++---
 exec/totemconfig.c       |    2 +-
 exec/tsafe.c             |    2 ++
 exec/util.h              |    1 +
 tools/corosync-notifyd.c |    6 +++++-
 7 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/exec/coroipcs.c b/exec/coroipcs.c
index a58c269..4c18c10 100644
--- a/exec/coroipcs.c
+++ b/exec/coroipcs.c
@@ -1241,7 +1241,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 c720128..42ecc24 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -526,6 +526,8 @@ static void priv_drop (void)
 
 static void corosync_tty_detach (void)
 {
+       FILE *r;
+
        /*
         * Disconnect from TTY if this is not a debug run
         */
@@ -550,9 +552,15 @@ 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 fa5ab9c..0074327 100644
--- a/exec/totemconfig.c
+++ b/exec/totemconfig.c
@@ -473,7 +473,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/tsafe.c b/exec/tsafe.c
index 20ce79a..8f3fe09 100644
--- a/exec/tsafe.c
+++ b/exec/tsafe.c
@@ -978,6 +978,7 @@ void setpwent(void)
        assert(0);
 }
 
+#ifdef HAVE_UTMPX_H
 void setutxent(void)
 {
        static void (*real_setutxent)(void) = NULL;
@@ -989,6 +990,7 @@ void setutxent(void)
        }
        assert(0);
 }
+#endif
 
 char *strerror(int errnum)
 {
diff --git a/exec/util.h b/exec/util.h
index a3bb47c..9e149e5 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 7f231fa..ec82c21 100644
--- a/tools/corosync-notifyd.c
+++ b/tools/corosync-notifyd.c
@@ -1033,7 +1033,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.4.4

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

Reply via email to