diff --git a/Makefile.lib b/Makefile.lib index fc7a40a2..a064af6e 100644 --- a/Makefile.lib +++ b/Makefile.lib @@ -93,7 +93,8 @@ endif ############################################################################# # Internal build rules -# All files in $(OBJS) and any $(subdir)/lib.o are linked into lib.o +# All files in $(OBJS) and any $(subdir)/lib.o are linked into lib.o. +# Sort them to filter out duplicated and get uniform order. LIB_O_DEPS = \ $(sort $(filter-out $(LIB_O_NAME),$(OBJS))) \ $(foreach subdir,$(sort $(SUBDIRS)),$(wildcard $(subdir)/$(LIB_O_NAME))) diff --git a/src/protocol/Makefile b/src/protocol/Makefile index f4e83fdb..6f4af60e 100644 --- a/src/protocol/Makefile +++ b/src/protocol/Makefile @@ -13,6 +13,8 @@ SUBDIRS-$(CONFIG_URI_REWRITE) += rewrite SUBDIRS = auth file http OBJS-$(CONFIG_DATA) += data.o +OBJS-$(CONFIG_FSP) += common.o +OBJS-$(CONFIG_SMB) += common.o OBJS = about.o date.o header.o protocol.o proxy.o uri.o user.o diff --git a/src/protocol/fsp/fsp.c b/src/protocol/fsp/fsp.c index 6f1d3d3c..26aaa61b 100644 --- a/src/protocol/fsp/fsp.c +++ b/src/protocol/fsp/fsp.c @@ -13,13 +13,6 @@ #include #include #include -#ifdef HAVE_SYS_TIME_H -#include /* FreeBSD needs this before resource.h */ -#endif -#include /* FreeBSD needs this before resource.h */ -#ifdef HAVE_SYS_RESOURCE_H -#include -#endif #ifdef HAVE_FCNTL_H #include /* OS/2 needs this after sys/types.h */ #endif @@ -37,6 +30,7 @@ #include "network/connection.h" #include "network/socket.h" #include "osdep/osdep.h" +#include "protocol/common.h" #include "protocol/protocol.h" #include "protocol/fsp/fsp.h" #include "protocol/uri.h" @@ -265,22 +259,6 @@ fsp_got_data(struct socket *socket, struct read_buffer *rb) #undef READ_SIZE -/* Close all non-terminal file descriptors. */ -static void -close_all_non_term_fd(void) -{ - int n; - int max = 1024; -#ifdef RLIMIT_NOFILE - struct rlimit lim; - - if (!getrlimit(RLIMIT_NOFILE, &lim)) - max = lim.rlim_max; -#endif - for (n = 3; n < max; n++) - close(n); -} - void fsp_protocol_handler(struct connection *conn) { @@ -326,7 +304,7 @@ fsp_protocol_handler(struct connection *conn) close_all_non_term_fd(); do_fsp(conn); - + } else { conn->socket->fd = fsp_pipe[0]; close(fsp_pipe[1]); diff --git a/src/protocol/smb/smb.c b/src/protocol/smb/smb.c index 3d37af96..62550e31 100644 --- a/src/protocol/smb/smb.c +++ b/src/protocol/smb/smb.c @@ -12,13 +12,7 @@ #include #include #include -#ifdef HAVE_SYS_TIME_H -#include /* FreeBSD needs this before resource.h */ -#endif -#include /* FreeBSD needs this before resource.h */ -#ifdef HAVE_SYS_RESOURCE_H -#include -#endif +#include #ifdef HAVE_FCNTL_H #include /* OS/2 needs this after sys/types.h */ #endif @@ -36,6 +30,7 @@ #include "network/connection.h" #include "network/socket.h" #include "osdep/osdep.h" +#include "protocol/common.h" #include "protocol/protocol.h" #include "protocol/smb/smb.h" #include "protocol/uri.h" @@ -525,22 +520,6 @@ bye: } -/* Close all non-terminal file descriptors. */ -static void -close_all_non_term_fd(void) -{ - int n; - int max = 1024; -#ifdef RLIMIT_NOFILE - struct rlimit lim; - - if (!getrlimit(RLIMIT_NOFILE, &lim)) - max = lim.rlim_max; -#endif - for (n = 3; n < max; n++) - close(n); -} - void smb_protocol_handler(struct connection *conn) {