 src/socket_wrapper.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 0eff366..136b6d7 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -3193,26 +3193,6 @@ static int swrap_accept(int s,
 #endif
 	}
 
-
-	/*
-	 * prevent parent_si from being altered / closed
-	 * while we read it
-	 */
-	SWRAP_LOCK_SI(parent_si);
-
-	/*
-	 * assume out sockaddr have the same size as the in parent
-	 * socket family
-	 */
-	in_addr.sa_socklen = socket_length(parent_si->family);
-	if (in_addr.sa_socklen <= 0) {
-		SWRAP_UNLOCK_SI(parent_si);
-		errno = EINVAL;
-		return -1;
-	}
-
-	SWRAP_UNLOCK_SI(parent_si);
-
 #ifdef HAVE_ACCEPT4
 	ret = libc_accept4(s, &un_addr.sa.s, &un_addr.sa_socklen, flags);
 #else
@@ -3230,6 +3210,16 @@ static int swrap_accept(int s,
 	fd = ret;
 
 	SWRAP_LOCK_SI(parent_si);
+	/*
+	 * assume out sockaddr have the same size as the in parent
+	 * socket family
+	 */
+	in_addr.sa_socklen = socket_length(parent_si->family);
+	if (in_addr.sa_socklen <= 0) {
+		SWRAP_UNLOCK_SI(parent_si);
+		errno = EINVAL;
+		return -1;
+	}
 
 	ret = sockaddr_convert_from_un(parent_si,
 				       &un_addr.sa.un,
