Skip to contentSkip to conversation

credential-cache--daemon.c: unlink() a potentially stale unix socket

PATCH In review Ramsay Jones 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 credential-cache--daemon.c: unlink() a potentially stale unix socket

---
 credential-cache--daemon.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
credential-cache--daemon.c +1 -0
index ee2c15a..c5fb1b2 100644
@@ -230,6 +230,7 @@ static void serve_cache(const char *socket_path)
 {
 	int fd;
 
+	unlink(socket_path);
 	fd = unix_stream_listen(socket_path);
 	if (fd < 0)
 		die_errno("unable to bind to '%s'", socket_path);
Signature · 1 line
1.7.7
#1 lore raw

credential-cache--daemon.c static void serve_cache(const char *socket_path) · line 236

Quoted 12 lines · Ramsay Jones
credential-cache--daemon.c +1 -0
index ee2c15a..c5fb1b2 100644
@@ -230,6 +230,7 @@ static void serve_cache(const char *socket_path)
 {
 	int fd;
 
+	unlink(socket_path);
 	fd = unix_stream_listen(socket_path);
 	if (fd < 0)
 		die_errno("unable to bind to '%s'", socket_path);

I think this is a sane thing to do, if it's more portable. We can just get rid of the double-bind attempt in unix_stream_listen, now. I suspect this unlink should probably just go directly into unix_stream_listen, too.

-Peff