--------------------- PatchSet 8052 Date: 2006/05/27 16:17:26 Author: serassio Branch: nt Tag: (none) Log: Backport from 3.0 of refactoring of SwapDir creation Members: src/store_dir.c:1.21.8.2->1.21.8.3 Index: squid/src/store_dir.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_dir.c,v retrieving revision 1.21.8.2 retrieving revision 1.21.8.3 diff -u -r1.21.8.2 -r1.21.8.3 --- squid/src/store_dir.c 18 May 2006 18:34:20 -0000 1.21.8.2 +++ squid/src/store_dir.c 27 May 2006 16:17:26 -0000 1.21.8.3 @@ -1,6 +1,6 @@ /* - * $Id: store_dir.c,v 1.21.8.2 2006/05/18 18:34:20 serassio Exp $ + * $Id: store_dir.c,v 1.21.8.3 2006/05/27 16:17:26 serassio Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -48,6 +48,7 @@ static int storeDirValidSwapDirSize(int, squid_off_t); static STDIRSELECT storeDirSelectSwapDirRoundRobin; static STDIRSELECT storeDirSelectSwapDirLeastLoad; +static void startOneSwapDirCreation(SwapDir *); /* * This function pointer is set according to 'store_dir_select_algorithm' @@ -74,35 +75,45 @@ } void +startOneSwapDirCreation(SwapDir * sd) +{ + /* + * 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_ + if (fork()) + return; +#endif + if (NULL != sd->newfs) + sd->newfs(sd); +#ifndef _SQUID_MSWIN_ + exit(0); +#endif +} + +void storeCreateSwapDirectories(void) { int i; - SwapDir *sd; #ifndef _SQUID_MSWIN_ pid_t pid; int status; #endif + for (i = 0; i < Config.cacheSwap.n_configured; i++) { + startOneSwapDirCreation(&Config.cacheSwap.swapDirs[i]); #ifndef _SQUID_MSWIN_ - if (fork()) - continue; -#endif - sd = &Config.cacheSwap.swapDirs[i]; - if (NULL != sd->newfs) - sd->newfs(sd); -#ifndef _SQUID_MSWIN_ - exit(0); - } - do { + do { #ifdef _SQUID_NEXT_ - pid = wait3(&status, WNOHANG, NULL); + pid = wait3(&status, WNOHANG, NULL); #else - pid = waitpid(-1, &status, 0); + pid = waitpid(-1, &status, 0); #endif - } while (pid > 0 || (pid < 0 && errno == EINTR)); -#else + } while (pid > 0 || (pid < 0 && errno == EINTR)); +#endif /* _SQUID_MSWIN_ */ } -#endif } /*