[gmime/gmime-2-4] Force use of our own poll() on MacOS



commit 372cc80a441244f25272f719832261ae9c7cf870
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Wed Jun 8 11:41:11 2011 -0400

    Force use of our own poll() on MacOS
    
    2011-06-08  Jeffrey Stedfast  <fejj gnome org>
    
    	* gmime/gmime-gpg-context.c: If building on Apple, force the use
    	of our own implementation of poll() because Apple's poll() is
    	broken on some versions of MacOS.

 ChangeLog                 |    6 ++++++
 gmime/gmime-gpg-context.c |   19 +++++++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b9a2963..18c08d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-06-08  Jeffrey Stedfast  <fejj gnome org>
+
+	* gmime/gmime-gpg-context.c: If building on Apple, force the use
+	of our own implementation of poll() because Apple's poll() is
+	broken on some versions of MacOS.
+
 2011-03-26  Jeffrey Stedfast  <fejj novell com>
 
 	* README: Bumped version
diff --git a/gmime/gmime-gpg-context.c b/gmime/gmime-gpg-context.c
index 9f93151..ab55615 100644
--- a/gmime/gmime-gpg-context.c
+++ b/gmime/gmime-gpg-context.c
@@ -23,6 +23,11 @@
 #include <config.h>
 #endif
 
+#ifdef __APPLE__
+#undef HAVE_POLL_H
+#undef HAVE_POLL
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -1320,15 +1325,18 @@ poll (struct pollfd *pfds, nfds_t nfds, int timeout)
 	FD_ZERO (&xset);
 	
 	for (i = 0; i < nfds; i++) {
+		pfds[i].revents = 0;
+		if (pfds[i].fd < 0)
+			continue;
+		
 		if (pfds[i].events & POLLIN)
 			FD_SET (pfds[i].fd, &rset);
 		if (pfds[i].events & POLLOUT)
 			FD_SET (pfds[i].fd, &wset);
-		if (pfds[i].events & POLLPRI)
+		if (pfds[i].events != 0)
 			FD_SET (pfds[i].fd, &xset);
-		if (pfds[i].fd > maxfd && (pfds[i].events & (POLLIN | POLLOUT | POLLPRI)))
+		if (pfds[i].fd > maxfd)
 			maxfd = pfds[i].fd;
-		pfds[i].revents = 0;
 	}
 	
 	/* poll our fds... */
@@ -1336,12 +1344,15 @@ poll (struct pollfd *pfds, nfds_t nfds, int timeout)
 		ready = 0;
 		
 		for (i = 0; i < nfds; i++) {
+			if (pfds[i].fd < 0)
+				continue;
+			
 			if (FD_ISSET (pfds[i].fd, &rset))
 				pfds[i].revents |= POLLIN;
 			if (FD_ISSET (pfds[i].fd, &wset))
 				pfds[i].revents |= POLLOUT;
 			if (FD_ISSET (pfds[i].fd, &xset))
-				pfds[i].revents |= POLLPRI;
+				pfds[i].revents |= POLLERR | POLLHUP;
 			
 			if (pfds[i].revents != 0)
 				ready++;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]