From 6bc8e4ec1255da2d96a445a21782bc80b021e357 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Thu, 9 Feb 2006 03:54:28 +0000 Subject: [PATCH] The code now compiles if slp is disabled. --- slp.diff | 53 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/slp.diff b/slp.diff index 3a9e5ee..ae9c0ad 100644 --- a/slp.diff +++ b/slp.diff @@ -6,6 +6,9 @@ After applying this patch, run these commands for a successful build: ./configure --enable-slp make +TODO: the configure changes should abort if the user requests --enable-slp +and we can't honor that request. + --- old/Makefile.in +++ new/Makefile.in @@ -12,6 +12,8 @@ CFLAGS=@CFLAGS@ @@ -85,27 +88,33 @@ After applying this patch, run these commands for a successful build: #include --- old/loadparm.c +++ new/loadparm.c -@@ -105,6 +105,7 @@ typedef struct +@@ -105,6 +105,9 @@ typedef struct char *socket_options; int rsync_port; ++#ifdef HAVE_LIBSLP + int slp_refresh; ++#endif int syslog_facility; } global; -@@ -286,6 +287,7 @@ static struct parm_struct parm_table[] = +@@ -286,6 +289,9 @@ static struct parm_struct parm_table[] = {"motd file", P_STRING, P_GLOBAL,&Globals.motd_file, NULL,0}, {"pid file", P_STRING, P_GLOBAL,&Globals.pid_file, NULL,0}, {"port", P_INTEGER,P_GLOBAL,&Globals.rsync_port, NULL,0}, ++#ifdef HAVE_LIBSLP + {"slp refresh", P_INTEGER,P_GLOBAL,&Globals.slp_refresh, NULL,0}, ++#endif {"socket options", P_STRING, P_GLOBAL,&Globals.socket_options, NULL,0}, {"syslog facility", P_ENUM, P_GLOBAL,&Globals.syslog_facility,enum_facilities,0}, -@@ -379,6 +381,7 @@ FN_GLOBAL_STRING(lp_pid_file, &Globals.p +@@ -379,6 +385,9 @@ FN_GLOBAL_STRING(lp_pid_file, &Globals.p FN_GLOBAL_STRING(lp_socket_options, &Globals.socket_options) FN_GLOBAL_INTEGER(lp_rsync_port, &Globals.rsync_port) ++#ifdef HAVE_LIBSLP +FN_GLOBAL_INTEGER(lp_slp_refresh, &Globals.slp_refresh) ++#endif FN_GLOBAL_INTEGER(lp_syslog_facility, &Globals.syslog_facility) FN_LOCAL_STRING(lp_auth_users, auth_users) @@ -225,10 +234,11 @@ After applying this patch, run these commands for a successful build: path = /var/ftp/pub --- old/socket.c +++ new/socket.c -@@ -447,6 +447,14 @@ void start_accept_loop(int port, int (*f +@@ -447,6 +447,16 @@ void start_accept_loop(int port, int (*f { fd_set deffds; int *sp, maxfd, i; ++#ifdef HAVE_LIBSLP + time_t next_slp_refresh; + short slp_timeout = lp_slp_refresh(); + if (slp_timeout) { @@ -237,14 +247,17 @@ After applying this patch, run these commands for a successful build: + /* re-register before slp times out */ + slp_timeout -= 15; + } ++#endif #ifdef HAVE_SIGACTION sigact.sa_flags = SA_NOCLDSTOP; -@@ -475,14 +483,20 @@ void start_accept_loop(int port, int (*f +@@ -475,14 +485,25 @@ void start_accept_loop(int port, int (*f maxfd = sp[i]; } ++#ifdef HAVE_LIBSLP + next_slp_refresh = time(NULL) + slp_timeout; ++#endif + /* now accept incoming connections - forking a new process * for each incoming connection */ @@ -253,33 +266,41 @@ After applying this patch, run these commands for a successful build: pid_t pid; int fd; + int sel_ret; -+ struct timeval slp_tv; struct sockaddr_storage addr; socklen_t addrlen = sizeof addr; ++#ifdef HAVE_LIBSLP ++ struct timeval slp_tv; ++ + slp_tv.tv_sec = 10; + slp_tv.tv_usec = 0; ++#endif /* close log file before the potentially very long select so * file can be trimmed by another process instead of growing -@@ -494,8 +508,13 @@ void start_accept_loop(int port, int (*f +@@ -494,8 +515,18 @@ void start_accept_loop(int port, int (*f #else fds = deffds; #endif - - if (select(maxfd + 1, &fds, NULL, NULL, NULL) != 1) -+ sel_ret = select(maxfd + 1, &fds, NULL, NULL, slp_timeout ? &slp_tv: NULL); ++#ifdef HAVE_LIBSLP ++ sel_ret = select(maxfd + 1, &fds, NULL, NULL, ++ slp_timeout ? &slp_tv : NULL); + if (sel_ret == 0 && slp_timeout && time(NULL) > next_slp_refresh) { + rprintf(FINFO, "Service registration expired, refreshing it\n"); + register_services(); + next_slp_refresh = time(NULL) + slp_timeout; + } ++#else ++ sel_ret = select(maxfd + 1, &fds, NULL, NULL, NULL); ++#endif + if (sel_ret != 1) continue; for (i = 0, fd = -1; sp[i] >= 0; i++) { --- old/srvloc.c +++ new/srvloc.c -@@ -0,0 +1,105 @@ +@@ -0,0 +1,103 @@ +/* -*- c-file-style: "linux"; -*- + + Copyright (C) 2002 by Brad Hards @@ -319,9 +340,9 @@ After applying this patch, run these commands for a successful build: + char *cleanstr; + + if (errcode == SLP_OK) { -+ if (!strcmp(attrlist, "(comment=)")) { ++ if (!strcmp(attrlist, "(comment=)")) + rprintf(FINFO, "\t(No description)\n"); -+ } else { ++ else { + cleanstr = strrchr(attrlist, ')') ; + *cleanstr = ' '; /* remove last ')' */ + rprintf(FINFO, "\t%s\n", strchr(attrlist, '=') + 1); @@ -330,9 +351,9 @@ After applying this patch, run these commands for a successful build: + return SLP_FALSE; +} + -+SLPBoolean getSLPSrvURLCallback(UNUSED(SLPHandle hslp), const char *srvurl, -+ UNUSED(unsigned short lifetime), SLPError errcode, -+ void *cookie) ++static SLPBoolean getSLPSrvURLCallback(UNUSED(SLPHandle hslp), ++ const char *srvurl, UNUSED(unsigned short lifetime), ++ SLPError errcode, void *cookie) +{ + SLPError result; + SLPHandle attrhslp; @@ -352,10 +373,8 @@ After applying this patch, run these commands for a successful build: + SLPClose(attrhslp); + } + *(SLPError*)cookie = SLP_OK; -+ } else { ++ } else + *(SLPError*)cookie = errcode; -+ } -+ + + /* Return SLP_TRUE because we want to be called again + * if more services were found. */ -- 2.34.1