The branch, master has been updated via 3eee8df swrap: Delay addition of child socket_info_fd into socket_info list via 9278886 swrap: Remove redunant check in swrap_socket via 69b89aa swrap: Simplify swrap_remove_stale by early return from 44f7e09 Bump version to 1.1.7
https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 3eee8df6964fdca0d22967a5c8d65f934e935f34 Author: Anoop C S <anoo...@redhat.com> Date: Thu Aug 11 20:24:54 2016 +0530 swrap: Delay addition of child socket_info_fd into socket_info list In swrap_accept() we used to add new child socket_info_fd[child_fi] into newly created child socket_info struture[child_si] without considering the fact that we may return early in case of errors from subsequent calls to libc_getsockname() and sockaddr_convert_from_un() during which we free child_fi and child_si and return. So it is better to delay the addition of child_fi into child_si->fds until child_si is completely initialized. Signed-off-by: Anoop C S <anoo...@redhat.com> Reviewed-by: Michael Adam <ob...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit 92788865b636237f761ebd57d02fad0f3c9e03cd Author: Anoop C S <anoo...@redhat.com> Date: Thu Aug 11 20:20:17 2016 +0530 swrap: Remove redunant check in swrap_socket The very same check is also being made inside swrap_remove_stale(). So we can get rid of this early if condition. Pair-programmed-with: Michael Adam <ob...@samba.org> Signed-off-by: Anoop C S <anoo...@redhat.com> Signed-off-by: Michael Adam <ob...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit 69b89aa9d0847ba7238963c0dafef41d691c52cd Author: Anoop C S <anoo...@redhat.com> Date: Thu Aug 11 19:27:17 2016 +0530 swrap: Simplify swrap_remove_stale by early return Pair-programmed-with: Michael Adam <ob...@samba.org> Signed-off-by: Anoop C S <anoo...@redhat.com> Signed-off-by: Michael Adam <ob...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> ----------------------------------------------------------------------- Summary of changes: src/socket_wrapper.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) Changeset truncated at 500 lines: diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index ba289e6..00518c1 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -1469,23 +1469,25 @@ static void swrap_remove_stale(int fd) struct socket_info *si = find_socket_info(fd); struct socket_info_fd *fi; - if (si != NULL) { - for (fi = si->fds; fi; fi = fi->next) { - if (fi->fd == fd) { - SWRAP_LOG(SWRAP_LOG_TRACE, "remove stale wrapper for %d", fd); - SWRAP_DLIST_REMOVE(si->fds, fi); - free(fi); - break; - } + if (si == NULL) { + return; + } + + for (fi = si->fds; fi; fi = fi->next) { + if (fi->fd == fd) { + SWRAP_LOG(SWRAP_LOG_TRACE, "remove stale wrapper for %d", fd); + SWRAP_DLIST_REMOVE(si->fds, fi); + free(fi); + break; } + } - if (si->fds == NULL) { - SWRAP_DLIST_REMOVE(sockets, si); - if (si->un_addr.sun_path[0] != '\0') { - unlink(si->un_addr.sun_path); - } - free(si); + if (si->fds == NULL) { + SWRAP_DLIST_REMOVE(sockets, si); + if (si->un_addr.sun_path[0] != '\0') { + unlink(si->un_addr.sun_path); } + free(si); } } @@ -2456,10 +2458,7 @@ static int swrap_socket(int family, int type, int protocol) } /* Check if we have a stale fd and remove it */ - si = find_socket_info(fd); - if (si != NULL) { - swrap_remove_stale(fd); - } + swrap_remove_stale(fd); si = (struct socket_info *)calloc(1, sizeof(struct socket_info)); if (si == NULL) { @@ -2683,8 +2682,6 @@ static int swrap_accept(int s, child_fi->fd = fd; - SWRAP_DLIST_ADD(child_si->fds, child_fi); - child_si->family = parent_si->family; child_si->type = parent_si->type; child_si->protocol = parent_si->protocol; @@ -2737,6 +2734,7 @@ static int swrap_accept(int s, }; memcpy(&child_si->myname.sa.ss, &in_my_addr.sa.ss, in_my_addr.sa_socklen); + SWRAP_DLIST_ADD(child_si->fds, child_fi); SWRAP_DLIST_ADD(sockets, child_si); if (addr != NULL) { -- Socket Wrapper Repository