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

timer.c: don't infloop upon poll failure (e.g., ENOMEM)

* exec/timer.c (prioritized_timer_thread): Remove unreached
call to pthread_exit after infloop.
Return NULL for any poll failure other than EINTR.
Use "continue" rather than an equivalent "goto".
Return NULL upon failed pthread_setschedparam.
This also avoids a warning.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1916 fd59a12c-fef9-0310-b244-a6a79926bd2f
Jim Meyering 17 лет назад
Родитель
Сommit
767e64ff4d
1 измененных файлов с 8 добавлено и 10 удалено
  1. 8 10
      exec/timer.c

+ 8 - 10
exec/timer.c

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2002-2006 MontaVista Software, Inc.
- * Copyright (c) 2006-2008 Red Hat, Inc.
+ * Copyright (c) 2006-2009 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -109,19 +109,16 @@ static void *prioritized_timer_thread (void *data)
 	unsigned long long timeout;
 
 #if ! defined(TS_CLASS) && (defined(COROSYNC_BSD) || defined(COROSYNC_LINUX) || defined(COROSYNC_SOLARIS))
-	int res;
-
 	if (sched_priority != 0) {
 		struct sched_param sched_param;
 
 		sched_param.sched_priority = sched_priority;
-		res = pthread_setschedparam (expiry_thread, SCHED_RR, &sched_param);
+		pthread_setschedparam (expiry_thread, SCHED_RR, &sched_param);
 	}
 #endif
 
 	pthread_mutex_unlock (&timer_mutex);
 	for (;;) {
-retry_poll:
 		timer_serialize_lock_fn ();
 		timeout = timerlist_msec_duration_to_expire (&timers_timerlist);
 		if (timeout != -1 && timeout > 0xFFFFFFFF) {
@@ -129,19 +126,20 @@ retry_poll:
 		}
 		timer_serialize_unlock_fn ();
 		fds = poll (NULL, 0, timeout);
-		if (fds == -1) {
-			goto retry_poll;
+		if (fds == 0 || (fds < 0 && errno == EINTR)) {
+			continue;
+		}
+		if (fds < 0) {
+			return NULL;
 		}
 		pthread_mutex_lock (&timer_mutex);
 		timer_serialize_lock_fn ();
 
 		timerlist_expire (&timers_timerlist);
-		
+
 		timer_serialize_unlock_fn ();
 		pthread_mutex_unlock (&timer_mutex);
 	}
-
-	pthread_exit (0);
 }
 
 static void sigusr1_handler (int num) {