From 154c7949b092db6040cbb94255ecf6a02035b13c Mon Sep 17 00:00:00 2001 From: robertc <> Date: Wed, 5 Feb 2003 05:09:03 +0000 Subject: [PATCH] Summary: Refactor Guidos store creation change. Keywords: Refactor Guidos store creation change to make the behaviour easier to read, and easier to adapt for other OS's (i.e. OS/2). --- src/store_dir.cc | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/store_dir.cc b/src/store_dir.cc index 038a1016e6..6b153795d0 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir.cc,v 1.142 2003/02/04 21:57:15 robertc Exp $ + * $Id: store_dir.cc,v 1.143 2003/02/04 22:09:03 robertc Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -51,6 +51,7 @@ static int storeDirValidSwapDirSize(int, ssize_t); static STDIRSELECT storeDirSelectSwapDirRoundRobin; static STDIRSELECT storeDirSelectSwapDirLeastLoad; +static void startOneStoreCreation(SwapDir &swapDir); /* * This function pointer is set according to 'store_dir_select_algorithm' @@ -74,36 +75,38 @@ storeDirInit(void) } void -storeCreateSwapDirectories(void) +startOneStoreCreation(SwapDir &swapDir) { - int i; -/* - * On Windows, fork() is not available. - * The following is a workaround for create store directories sequentially - * when running on native Windows port. - */ + /* + * On Windows, fork() is not available. + * The following is a workaround for create store directories sequentially + * when running on native Windows port. + */ #ifndef _SQUID_MSWIN_ - pid_t pid; - int status; + if (fork()) + return; #endif - for (i = 0; i < Config.cacheSwap.n_configured; i++) { + swapDir.newFileSystem(); #ifndef _SQUID_MSWIN_ - if (fork()) - continue; + exit(0); #endif - INDEXSD(i)->newFileSystem(); +} + +void +storeCreateSwapDirectories(void) +{ + for (int i = 0; i < Config.cacheSwap.n_configured; i++) + startOneStoreCreation(*INDEXSD(i)); #ifndef _SQUID_MSWIN_ - exit(0); - } do { + pid_t pid; + int status; #ifdef _SQUID_NEXT_ pid = wait3(&status, WNOHANG, NULL); #else pid = waitpid(-1, &status, 0); #endif } while (pid > 0 || (pid < 0 && errno == EINTR)); -#else - } #endif } -- 2.47.2