If the ring id file for the processor is less then 8 bytes, totemsrp would
assert.  Our speculation is that this condition happens during a fencing
operation or local filesystem corruption.

With this patch, Corosync will create fresh ring id file data when the
incorrect number of bytes are read from the ring id.

Signed-off-by: Steven Dake <[email protected]>
---
 exec/totemsrp.c |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/exec/totemsrp.c b/exec/totemsrp.c
index d007fe7..3fdc3fe 100644
--- a/exec/totemsrp.c
+++ b/exec/totemsrp.c
@@ -3094,35 +3094,40 @@ static void memb_ring_id_create_or_load (
        struct memb_ring_id *memb_ring_id)
 {
        int fd;
-       int res;
+       int res = 0;
        char filename[256];
        char error_str[100];
 
        snprintf (filename, sizeof(filename), "%s/ringid_%s",
                rundir, totemip_print (&instance->my_id.addr[0]));
        fd = open (filename, O_RDONLY, 0700);
-       if (fd > 0) {
-               res = read (fd, &memb_ring_id->seq, sizeof (unsigned long 
long));
-               assert (res == sizeof (unsigned long long));
+       /*
+        * If file can be opened and read, read the ring id
+        */
+       if (fd != -1) {
+               res = read (fd, &memb_ring_id->seq, sizeof (uint64_t));
                close (fd);
-       } else
-       if (fd == -1 && errno == ENOENT) {
+       }
+       /*
+        * If file could not be opened or read, create a new ring id
+        */
+       if ((fd == -1) || (res != sizeof (uint64_t))) {
                memb_ring_id->seq = 0;
                umask(0);
                fd = open (filename, O_CREAT|O_RDWR, 0700);
-               if (fd >= 0) {
-                       res = write (fd, &memb_ring_id->seq, sizeof (unsigned 
long long));
-                       assert (res == sizeof (unsigned long long));
+               if (fd != -1) {
+                       res = write (fd, &memb_ring_id->seq, sizeof (uint64_t));
                        close (fd);
+                       if (res == -1) {
+                               strerror_r (errno, error_str, 100);
+                               log_printf 
(instance->totemsrp_log_level_warning,
+                                       "Couldn't write ringid file '%s' %s\n", 
filename, error_str);
+                       }
                } else {
                        strerror_r (errno, error_str, 100);
                        log_printf (instance->totemsrp_log_level_warning,
-                               "Couldn't create %s %s\n", filename, error_str);
+                               "Couldn't create ringid file '%s' %s\n", 
filename, error_str);
                }
-       } else {
-               strerror_r (errno, error_str, 100);
-               log_printf (instance->totemsrp_log_level_warning,
-                       "Couldn't open %s %s\n", filename, error_str);
        }
 
        totemip_copy(&memb_ring_id->rep, &instance->my_id.addr[0]);
-- 
1.7.4

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

Reply via email to