From 7b5c807ed023a43e0151c3edf12ad10cf6a864ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 4 Mar 2022 18:15:15 +0800 Subject: [PATCH] fix in linux --- server.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/server.c b/server.c index f610f39..cf19ae8 100644 --- a/server.c +++ b/server.c @@ -491,10 +491,23 @@ static int startupunix(char *path) { uname.sun_family = AF_UNIX; strncpy(uname.sun_path, path, sizeof(uname.sun_path)); uname.sun_path[sizeof(uname.sun_path)-1] = 0; // avoid overlap - uname.sun_len = strlen(path)+1; // including null + #if __APPLE__ + uname.sun_len = strlen(path)+1; // including null + #else + int sun_len = strlen(path)+1; // including null + #endif if(httpd < 0) error_die("unix socket"); unlink(path); // in case it already exists - if(bind(httpd, (struct sockaddr *)&uname, (void*)uname.sun_path-(void*)&uname+uname.sun_len) < 0) error_die("bind"); + if(bind( + httpd, + (struct sockaddr *)&uname, + (void*)uname.sun_path-(void*)&uname+ + #if __APPLE__ + uname.sun_len + #else + sun_len + #endif + ) < 0) error_die("bind"); if(listen(httpd, 5) < 0) error_die("listen"); return httpd; }