libgnome r3765 - in trunk: . libgnome



Author: fejj
Date: Wed Jul 30 21:50:28 2008
New Revision: 3765
URL: http://svn.gnome.org/viewvc/libgnome?rev=3765&view=rev

Log:
2008-07-30  Jeffrey Stedfast  <fejj novell com>

	* libgnome/gnome-sound.c (send_all): More robustification.



Modified:
   trunk/ChangeLog
   trunk/libgnome/gnome-sound.c

Modified: trunk/libgnome/gnome-sound.c
==============================================================================
--- trunk/libgnome/gnome-sound.c	(original)
+++ trunk/libgnome/gnome-sound.c	Wed Jul 30 21:50:28 2008
@@ -440,23 +440,35 @@
 			rv = poll (pfd, 1, 100);
 		} while (rv == -1 && (errno == EINTR || errno == EAGAIN));
 		
-		if (pfd[0].revents & POLLOUT) {
-			/* socket is ready for writing */
-			do {
-				n = write (fd, buf + nwritten, buflen - nwritten);
-			} while (n == -1 && errno == EINTR);
+		if (rv == -1) {
+			if (errno != EBADF) {
+				rv = errno;
+				esd_close (fd);
+				errno = rv;
+			}
 			
-			if (n > 0)
-				nwritten += n;
-		} else if (pfd[0].revents & (POLLERR | POLLHUP)) {
-			/* we /just/ lost the esd connection */
-			esd_close (fd);
 			fd = -1;
 			break;
-		} else if (rv == -1 && errno == EBADF) {
-			/* socket is bad */
+		} else if (rv < 1 || (pfd[0].revents & (POLLERR | POLLHUP | POLLOUT)) != POLLOUT) {
+			/* we /just/ lost the esd connection */
+			esd_close (fd);
 			fd = -1;
 			break;
+		} else {
+			/* socket is ready for writing */
+			do {
+				n = write (fd, buf + nwritten, buflen - nwritten);
+			} while (n == -1 && errno == EINTR);
+			
+			if (n == -1) {
+				rv = errno;
+				esd_close (fd);
+				errno = rv;
+				fd = -1;
+				break;
+			}
+			
+			nwritten += n;
 		}
 	} while (nwritten < buflen);
 	



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