Просмотр исходного кода

Corosync: Fix build when done with --enable-fatal-warnings

Signed-off-by: Jerome Flesch <jerome.flesch@netasq.com>
Reviewed-by: Jan Friesse<jfriesse@redhat.com>
(backported from commit fe51e703675232a69009245cd9e0523bb1858dd6)
Jerome Flesch 14 лет назад
Родитель
Сommit
e8884487fd
4 измененных файлов с 22 добавлено и 6 удалено
  1. 1 1
      exec/coroipcs.c
  2. 6 2
      exec/coropoll.c
  3. 14 3
      exec/main.c
  4. 1 0
      exec/util.h

+ 1 - 1
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;
 	write_idx = conn_info->control_buffer->write;
 
 
 	memcpy (&conn_info->dispatch_buffer[write_idx], msg, len);
 	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,
 static void msg_send (void *conn, const struct iovec *iov, unsigned int iov_len,

+ 6 - 2
exec/coropoll.c

@@ -258,7 +258,9 @@ int poll_dispatch_modify (
 			poll_instance->poll_entries[i].dispatch_fn = dispatch_fn;
 			poll_instance->poll_entries[i].dispatch_fn = dispatch_fn;
 			if (change_notify) {
 			if (change_notify) {
 				char buf = 1;
 				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;
 			goto error_put;
@@ -499,7 +501,9 @@ retry_poll:
 
 
 		if (poll_instance->ufds[0].revents) {
 		if (poll_instance->ufds[0].revents) {
 			char buf;
 			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;
 			goto rebuild_poll;
 		}
 		}
 		poll_entry_count = poll_instance->poll_entry_count;
 		poll_entry_count = poll_instance->poll_entry_count;

+ 14 - 3
exec/main.c

@@ -480,6 +480,8 @@ static void priv_drop (void)
 
 
 static void corosync_tty_detach (void)
 static void corosync_tty_detach (void)
 {
 {
+	FILE *r;
+
 	/*
 	/*
 	 * Disconnect from TTY if this is not a debug run
 	 * Disconnect from TTY if this is not a debug run
 	 */
 	 */
@@ -504,9 +506,18 @@ static void corosync_tty_detach (void)
 	/*
 	/*
 	 * Map stdin/out/err to /dev/null.
 	 * 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)
 static void corosync_mlockall (void)

+ 1 - 0
exec/util.h

@@ -63,6 +63,7 @@ enum e_ais_done {
 	AIS_DONE_DIR_NOT_PRESENT = 16,
 	AIS_DONE_DIR_NOT_PRESENT = 16,
 	AIS_DONE_AQUIRE_LOCK = 17,
 	AIS_DONE_AQUIRE_LOCK = 17,
 	AIS_DONE_ALREADY_RUNNING = 18,
 	AIS_DONE_ALREADY_RUNNING = 18,
+	AIS_DONE_STD_TO_NULL_REDIR = 19,
 };
 };
 
 
 static inline cs_error_t hdb_error_to_cs (int res)		\
 static inline cs_error_t hdb_error_to_cs (int res)		\