This is an automated email from the git hooks/post-receive script.
rharwood pushed a change to branch master in repository gssproxy.
from 03788ef Add call to verto_cleanup() new ec808ee Simplify setting NONBLOCK on socket new b8f5b2f Fix handling of non-EPOLLIN/EPOLLOUT events new f2530fc Fix error handling in gpm_send_buffer/gpm_recv_buffer
The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference.
Summary of changes: proxy/src/client/gpm_common.c | 82 ++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 40 deletions(-)
This is an automated email from the git hooks/post-receive script.
rharwood pushed a commit to branch master in repository gssproxy.
commit ec808ee6a5e6746ed35acc865f253425701be352 Author: Alexander Scheel alexander.m.scheel@gmail.com Date: Thu Sep 14 10:57:12 2017 -0500
Simplify setting NONBLOCK on socket
Signed-off-by: Alexander Scheel alexander.m.scheel@gmail.com Reviewed-by: Simo Sorce simo@redhat.com Reviewed-by: Robbie Harwood rharwood@redhat.com Merges: #213 [rharwood@redhat.com: fixup commit message] --- proxy/src/client/gpm_common.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/proxy/src/client/gpm_common.c b/proxy/src/client/gpm_common.c index 6103d71..a79371c 100644 --- a/proxy/src/client/gpm_common.c +++ b/proxy/src/client/gpm_common.c @@ -80,7 +80,6 @@ static int gpm_open_socket(struct gpm_ctx *gpmctx) struct sockaddr_un addr = {0}; char name[PATH_MAX]; int ret; - unsigned flags; int fd = -1;
ret = get_pipe_name(name); @@ -92,24 +91,12 @@ static int gpm_open_socket(struct gpm_ctx *gpmctx) strncpy(addr.sun_path, name, sizeof(addr.sun_path)-1); addr.sun_path[sizeof(addr.sun_path)-1] = '\0';
- fd = socket(AF_UNIX, SOCK_STREAM, 0); + fd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0); if (fd == -1) { ret = errno; goto done; }
- ret = fcntl(fd, F_GETFD, &flags); - if (ret != 0) { - ret = errno; - goto done; - } - - ret = fcntl(fd, F_SETFD, flags | O_NONBLOCK); - if (ret != 0) { - ret = errno; - goto done; - } - ret = connect(fd, (struct sockaddr *)&addr, sizeof(addr)); if (ret == -1) { ret = errno;
This is an automated email from the git hooks/post-receive script.
rharwood pushed a commit to branch master in repository gssproxy.
commit b8f5b2f75612a11753cf742ee0477b98df8e6b02 Author: Alexander Scheel alexander.m.scheel@gmail.com Date: Thu Sep 14 11:16:42 2017 -0500
Fix handling of non-EPOLLIN/EPOLLOUT events
Signed-off-by: Alexander Scheel alexander.m.scheel@gmail.com Reviewed-by: Robbie Harwood rharwood@redhat.com Merges: #213 --- proxy/src/client/gpm_common.c | 49 ++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 14 deletions(-)
diff --git a/proxy/src/client/gpm_common.c b/proxy/src/client/gpm_common.c index a79371c..6d93a55 100644 --- a/proxy/src/client/gpm_common.c +++ b/proxy/src/client/gpm_common.c @@ -287,26 +287,47 @@ static int gpm_epoll_wait(struct gpm_ctx *gpmctx, uint32_t event_flags) gpm_epoll_close(gpmctx); } else if (epoll_ret == 1 && events[0].data.fd == gpmctx->timerfd) { /* Got an event which is only our timer */ - ret = read(gpmctx->timerfd, &timer_read, sizeof(uint64_t)); - if (ret == -1 && errno != EAGAIN && errno != EWOULDBLOCK) { - /* In the case when reading from the timer failed, don't hide the - * timer error behind ETIMEDOUT such that it isn't retried */ - ret = errno; + if ((events[0].events & EPOLLIN) == 0) { + /* We got an event which was not EPOLLIN; assume this is an error, + * and exit with EBADF: epoll_wait said timerfd had an event, + * but that event is not an EPOLIN event. */ + ret = EBADF; } else { - /* If ret == 0, then we definitely timed out. Else, if ret == -1 - * and errno == EAGAIN or errno == EWOULDBLOCK, we're in a weird - * edge case where epoll thinks the timer can be read, but it - * is blocking more; treat it like a TIMEOUT and retry, as - * nothing around us would handle EAGAIN from timer and retry - * it. */ - ret = ETIMEDOUT; + ret = read(gpmctx->timerfd, &timer_read, sizeof(uint64_t)); + if (ret == -1 && errno != EAGAIN && errno != EWOULDBLOCK) { + /* In the case when reading from the timer failed, don't hide the + * timer error behind ETIMEDOUT such that it isn't retried */ + ret = errno; + } else { + /* If ret == 0, then we definitely timed out. Else, if ret == -1 + * and errno == EAGAIN or errno == EWOULDBLOCK, we're in a weird + * edge case where epoll thinks the timer can be read, but it + * is blocking more; treat it like a TIMEOUT and retry, as + * nothing around us would handle EAGAIN from timer and retry + * it. */ + ret = ETIMEDOUT; + } } gpm_epoll_close(gpmctx); } else { /* If ret == 2, then we ignore the timerfd; that way if the next * operation cannot be performed immediately, we timeout and retry. - * If ret == 1 and data.fd == gpmctx->fd, return 0. */ - ret = 0; + * Always check the returned event of the socket fd. */ + int fd_index = 0; + if (epoll_ret == 2 && events[fd_index].data.fd != gpmctx->fd) { + fd_index = 1; + } + + if ((events[fd_index].events & event_flags) == 0) { + /* We cannot call EPOLLIN/EPOLLOUT at this time; assume that this + * is a fatal error; return with EBADFD to distinguish from + * EBADF in timer_fd case. */ + ret = EBADFD; + gpm_epoll_close(gpmctx); + } else { + /* We definintely got a EPOLLIN/EPOLLOUT event; return success. */ + ret = 0; + } }
epoll_ret = epoll_ctl(gpmctx->epollfd, EPOLL_CTL_DEL, gpmctx->fd, NULL);
This is an automated email from the git hooks/post-receive script.
rharwood pushed a commit to branch master in repository gssproxy.
commit f2530fc280dd84e6abc0f5475e261aa0d2ee2a21 Author: Alexander Scheel alexander.m.scheel@gmail.com Date: Thu Sep 14 11:24:39 2017 -0500
Fix error handling in gpm_send_buffer/gpm_recv_buffer
Signed-off-by: Alexander Scheel alexander.m.scheel@gmail.com Reviewed-by: Robbie Harwood rharwood@redhat.com Merges: #213 [rharwood@redhat.com: commit message formatting, copyright update] --- proxy/src/client/gpm_common.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/proxy/src/client/gpm_common.c b/proxy/src/client/gpm_common.c index 6d93a55..75c64d7 100644 --- a/proxy/src/client/gpm_common.c +++ b/proxy/src/client/gpm_common.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 the GSS-PROXY contributors, see COPYING for license */ +/* Copyright (C) 2011,2017 the GSS-PROXY contributors, see COPYING for license */
#include "gssapi_gpm.h" #include <sys/types.h> @@ -419,10 +419,7 @@ static int gpm_send_buffer(struct gpm_ctx *gpmctx, ret = 0;
done: - if (ret) { - /* on errors we can only close the fd and return */ - gpm_close_socket(gpmctx); - } + /* we only need to return as gpm_retry_socket closes the socket */ return ret; }
@@ -492,9 +489,10 @@ static int gpm_recv_buffer(struct gpm_ctx *gpmctx,
done: if (ret) { - /* on errors we can only close the fd and return */ - gpm_close_socket(gpmctx); - gpm_epoll_close(gpmctx); + /* on errors, free the buffer to prevent calling + * xdr_destroy(&xdr_reply_ctx); */ + free(*buffer); + *buffer = NULL; } return ret; } @@ -569,10 +567,6 @@ static int gpm_send_recv_loop(struct gpm_ctx *gpmctx, char *send_buffer, /* Close and reopen socket before trying again */ ret = gpm_retry_socket(gpmctx);
- /* Free buffer and set it to NULL to prevent free(xdr_reply_ctx) */ - free(*recv_buffer); - *recv_buffer = NULL; - if (ret != 0) return ret; ret = ETIMEDOUT;
gss-proxy@lists.fedorahosted.org