commit 975aac18ec7afa1a2d257b11e05f645e169aff71
parent 0165e125dc0697a43900260f4f4a9c66608d23c1
Author: Nihal Jere <nihal@nihaljere.xyz>
Date: Thu, 21 Oct 2021 20:11:41 -0500
npm-agent: close socket at the right time
We can only bind if we have a socket, so close the socket after we
unlink it.
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/npm-agent.c b/npm-agent.c
@@ -231,7 +231,7 @@ main()
if (bind(sock, (struct sockaddr *) &sockaddr, sizeof(sockaddr)) == -1) {
perror("failed to bind to socket");
- goto error;
+ goto error_socket;
}
if (listen(sock, 50) == -1) {
@@ -309,8 +309,8 @@ main()
}
error:
- close(sock);
-error_socket:
unlink(SOCKPATH);
+error_socket:
+ close(sock);
return 1;
}