From: Francesco Chemolli Date: Thu, 30 Aug 2012 21:01:30 +0000 (+0200) Subject: Moved unlinkd-related prototypes to own header. X-Git-Tag: sourceformat-review-1~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b6b42084e6e466b1b15aef04e578abbebbbada99;p=thirdparty%2Fsquid.git Moved unlinkd-related prototypes to own header. Removed preprocessor conditionals from calling code. --- diff --git a/src/DiskIO/Blocking/BlockingIOStrategy.cc b/src/DiskIO/Blocking/BlockingIOStrategy.cc index de5d52fd13..d9329ce615 100644 --- a/src/DiskIO/Blocking/BlockingIOStrategy.cc +++ b/src/DiskIO/Blocking/BlockingIOStrategy.cc @@ -1,7 +1,4 @@ - /* - * $Id$ - * * DEBUG: section 47 Store Directory Routines * AUTHOR: Robert Collins * @@ -38,6 +35,7 @@ #include "BlockingIOStrategy.h" #include "BlockingFile.h" #include "protos.h" +#include "unlinkd.h" bool BlockingIOStrategy::shedLoad() @@ -67,9 +65,5 @@ BlockingIOStrategy::unlinkdUseful() const void BlockingIOStrategy::unlinkFile(char const *path) { -#if USE_UNLINKD unlinkdUnlink(path); -#else - ::unlink(path); -#endif } diff --git a/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc b/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc index 10b71cb41c..3ee7d0744d 100644 --- a/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc +++ b/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc @@ -1,6 +1,4 @@ /* - * $Id$ - * * DEBUG: section 79 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels * @@ -45,6 +43,7 @@ #include "Store.h" #include "StatCounters.h" #include "SquidTime.h" +#include "unlinkd.h" #include #include @@ -120,14 +119,7 @@ DiskdIOStrategy::unlinkFile(char const *path) if (shedLoad()) { /* Damn, we need to issue a sync unlink here :( */ debugs(79, 2, "storeDiskUnlink: Out of queue space, sync unlink"); -#if USE_UNLINKD - unlinkdUnlink(path); -#else - - unlink(path); -#endif - return; } diff --git a/src/DiskIO/IpcIo/IpcIoIOStrategy.cc b/src/DiskIO/IpcIo/IpcIoIOStrategy.cc index 9fded819dc..277fd52b84 100644 --- a/src/DiskIO/IpcIo/IpcIoIOStrategy.cc +++ b/src/DiskIO/IpcIo/IpcIoIOStrategy.cc @@ -1,7 +1,4 @@ - /* - * $Id$ - * * DEBUG: section 47 Store Directory Routines */ @@ -9,6 +6,7 @@ #include "IpcIoFile.h" #include "IpcIoIOStrategy.h" #include "protos.h" +#include "unlinkd.h" bool IpcIoIOStrategy::shedLoad() @@ -38,9 +36,5 @@ IpcIoIOStrategy::unlinkdUseful() const void IpcIoIOStrategy::unlinkFile(char const *path) { -#if USE_UNLINKD unlinkdUnlink(path); -#else - ::unlink(path); -#endif } diff --git a/src/DiskIO/Mmapped/MmappedIOStrategy.cc b/src/DiskIO/Mmapped/MmappedIOStrategy.cc index 41d4f679c3..66dfcb7d02 100644 --- a/src/DiskIO/Mmapped/MmappedIOStrategy.cc +++ b/src/DiskIO/Mmapped/MmappedIOStrategy.cc @@ -1,7 +1,4 @@ - /* - * $Id$ - * * DEBUG: section 47 Store Directory Routines */ @@ -9,6 +6,7 @@ #include "MmappedFile.h" #include "MmappedIOStrategy.h" #include "protos.h" +#include "unlinkd.h" bool MmappedIOStrategy::shedLoad() @@ -38,9 +36,5 @@ MmappedIOStrategy::unlinkdUseful() const void MmappedIOStrategy::unlinkFile(char const *path) { -#if USE_UNLINKD unlinkdUnlink(path); -#else - ::unlink(path); -#endif } diff --git a/src/Makefile.am b/src/Makefile.am index 52de8c3283..97d0690926 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -137,10 +137,10 @@ LEAKFINDERSOURCE = endif if ENABLE_UNLINKD -UNLINKDSOURCE = unlinkd.cc +UNLINKDSOURCE = unlinkd.h unlinkd.cc UNLINKD = unlinkd else -UNLINKDSOURCE = +UNLINKDSOURCE = unlinkd.h UNLINKD = endif diff --git a/src/main.cc b/src/main.cc index 5c11a4d7e9..20a16fdc9d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,4 @@ /* - * $Id$ - * * DEBUG: section 01 Startup and Main Loop * AUTHOR: Harvest Derived * @@ -91,6 +89,7 @@ #include "StoreFileSystem.h" #include "Store.h" #include "SwapDir.h" +#include "unlinkd.h" #include "URL.h" #include "wccp.h" #include "wccp2.h" @@ -871,10 +870,8 @@ mainReconfigureFinish(void *) mimeInit(Config.mimeTablePathname); -#if USE_UNLINKD if (unlinkdNeeded()) unlinkdInit(); -#endif #if USE_DELAY_POOLS Config.ClientDelay.finalize(); @@ -1078,10 +1075,8 @@ mainInitialize(void) #endif if (!configured_once) { -#if USE_UNLINKD if (unlinkdNeeded()) unlinkdInit(); -#endif urlInitialize(); statInit(); @@ -1889,10 +1884,8 @@ SquidShutdown() #endif Store::Root().sync(); /* Flush pending object writes/unlinks */ -#if USE_UNLINKD - unlinkdClose(); /* after sync/flush */ -#endif + unlinkdClose(); /* after sync/flush. NOP if !USE_UNLINKD */ storeDirWriteCleanLogs(0); PrintRusage(); diff --git a/src/protos.h b/src/protos.h index 4774015032..6b7f6e9c01 100644 --- a/src/protos.h +++ b/src/protos.h @@ -86,17 +86,9 @@ extern void shut_down(int); extern void rotate_logs(int); extern void reconfigure(int); -class store_client; - #include "fatal.h" -#if USE_UNLINKD -SQUIDCEXTERN bool unlinkdNeeded(void); -SQUIDCEXTERN void unlinkdInit(void); -SQUIDCEXTERN void unlinkdClose(void); -SQUIDCEXTERN void unlinkdUnlink(const char *); -#endif SQUIDCEXTERN peer_t parseNeighborType(const char *s); diff --git a/src/unlinkd.cc b/src/unlinkd.cc index 022831150d..b2e687a17d 100644 --- a/src/unlinkd.cc +++ b/src/unlinkd.cc @@ -1,7 +1,4 @@ - /* - * $Id$ - * * DEBUG: section 02 Unlink Daemon * AUTHOR: Duane Wessels * @@ -34,6 +31,8 @@ */ #include "squid.h" + +#if USE_UNLINKD #include "disk.h" #include "fd.h" #include "fde.h" @@ -273,3 +272,4 @@ unlinkdInit(void) #endif } +#endif /* USE_UNLINKD */ diff --git a/src/unlinkd.h b/src/unlinkd.h new file mode 100644 index 0000000000..e417a7a0fa --- /dev/null +++ b/src/unlinkd.h @@ -0,0 +1,51 @@ +#ifndef SQUID_UNLINKD_H_ +#define SQUID_UNLINKD_H_ +/* + * DEBUG: section 02 Unlink Daemon + * AUTHOR: Duane Wessels + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#if USE_UNLINKD +extern bool unlinkdNeeded(void); +extern void unlinkdInit(void); +extern void unlinkdClose(void); +extern void unlinkdUnlink(const char *); +#else /* USE_UNLINKD */ + +#if HAVE_UNISTD_H +#include +#endif +inline bool unlinkdNeeded(void) { return false; } +inline void unlinkdInit(void) { return; } +inline void unlinkdClose(void) { return; } +inline void unlinkdUnlink(const char * path) { ::unlink(path); } +#endif /* USE_UNLINKD */ + +#endif /* SQUID_UNLINKD_H_ */