*) delete no longer used unix domain sockets
*) fix unix domain socket comparison
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 80caa1b..a4e00b9 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -666,6 +666,24 @@
ngx_close_socket_n " listening socket on %V failed",
&ls[i].addr_text);
}
+
+#if (NGX_HAVE_UNIX_DOMAIN)
+
+ if (ls[i].sockaddr->sa_family == AF_UNIX) {
+ u_char *name;
+
+ name = ls[i].addr_text.data + sizeof("unix:") - 1;
+
+ ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
+ "deleting socket %s", name);
+
+ if (ngx_delete_file(name) == -1) {
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
+ ngx_delete_file_n " %s failed", name);
+ }
+ }
+
+#endif
}
@@ -835,6 +853,9 @@
#if (NGX_HAVE_INET6)
struct sockaddr_in6 *sin61, *sin62;
#endif
+#if (NGX_HAVE_UNIX_DOMAIN)
+ struct sockaddr_un *saun1, *saun2;
+#endif
if (sa1->sa_family != sa2->sa_family) {
return NGX_DECLINED;
@@ -858,6 +879,21 @@
break;
#endif
+#if (NGX_HAVE_UNIX_DOMAIN)
+ case AF_UNIX:
+ saun1 = (struct sockaddr_un *) sa1;
+ saun2 = (struct sockaddr_un *) sa2;
+
+ if (ngx_memcmp(&saun1->sun_path, &saun2->sun_path,
+ sizeof(saun1->sun_path))
+ != 0)
+ {
+ return NGX_DECLINED;
+ }
+
+ break;
+#endif
+
default: /* AF_INET */
sin1 = (struct sockaddr_in *) sa1;