aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2014-04-04 14:58:33 -0400
committerGreg Hudson <ghudson@mit.edu>2014-04-05 17:50:08 -0400
commit82aa5f56acee4d63800a1a69794a2d7bc4f104fc (patch)
treea44979ecfe6d8a5b472779784391d71e4a8341ed
parent8d735931e2a93fab31d68772e8881faa6b030a10 (diff)
downloadkrb5-82aa5f56acee4d63800a1a69794a2d7bc4f104fc.zip
krb5-82aa5f56acee4d63800a1a69794a2d7bc4f104fc.tar.gz
krb5-82aa5f56acee4d63800a1a69794a2d7bc4f104fc.tar.bz2
Fix sendto_kdc.c on OS X after cm refactoring
Treat POLLHUP without POLLIN or POLLOUT as an exception in the poll version of cm_get_ssflags, to correctly handle TCP connection errors on OS X.
-rw-r--r--src/lib/krb5/os/sendto_kdc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/lib/krb5/os/sendto_kdc.c b/src/lib/krb5/os/sendto_kdc.c
index e773a0a..67e2a60 100644
--- a/src/lib/krb5/os/sendto_kdc.c
+++ b/src/lib/krb5/os/sendto_kdc.c
@@ -179,6 +179,15 @@ cm_get_ssflags(struct select_state *selstate, int fd)
{
struct pollfd *pfd = find_pollfd(selstate, fd);
+ /*
+ * OS X sets POLLHUP without POLLOUT on connection error. Catch this as
+ * well as other error events such as POLLNVAL, but only if POLLIN and
+ * POLLOUT aren't set, as we can get POLLHUP along with POLLIN with TCP
+ * data still to be read.
+ */
+ if (pfd->revents != 0 && !(pfd->revents & (POLLIN | POLLOUT)))
+ return SSF_EXCEPTION;
+
return ((pfd->revents & POLLIN) ? SSF_READ : 0) |
((pfd->revents & POLLOUT) ? SSF_WRITE : 0) |
((pfd->revents & POLLERR) ? SSF_EXCEPTION : 0);