From 1447cfd8e921a7c37f485767f4fd9bd6f64d8d45 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 30 Mar 2009 21:17:10 +0000 Subject: [PATCH] uis.c: don't infloop upon poll failure (e.g., ENOMEM) * lcr/uis.c (lcr_uis_server): Return NULL for any poll failure other than EINTR. This also avoids a warning. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1964 fd59a12c-fef9-0310-b244-a6a79926bd2f --- lcr/uis.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lcr/uis.c b/lcr/uis.c index b91312b9..c5d22a30 100755 --- a/lcr/uis.c +++ b/lcr/uis.c @@ -153,7 +153,6 @@ static void *lcr_uis_server (void *data) #ifdef COROSYNC_LINUX int on = 1; #endif - int res; /* * Main acceptance and dispatch loop @@ -163,7 +162,11 @@ static void *lcr_uis_server (void *data) ufds[0].events = POLLIN; ufds[1].events = POLLOUT; for (;;) { - res = poll (ufds, nfds, -1); + int res = poll (ufds, nfds, -1); + if (res == 0 || (res < 0 && errno == EINTR)) + continue; + if (res < 0) + return NULL; if (nfds == 1 && ufds[0].revents & POLLIN) { ufds[1].fd = accept (ufds[0].fd, (struct sockaddr *)&un_addr, &addrlen); @@ -177,9 +180,6 @@ static void *lcr_uis_server (void *data) lcr_uis_dispatch (ufds[1].fd); } } - - - return 0; } __attribute__ ((constructor)) static int lcr_uis_ctors (void)