]>
Commit | Line | Data |
---|---|---|
9cef6668 | 1 | |
2 | /* | |
528b2c61 | 3 | * $Id: store_swapin.cc,v 1.34 2003/01/23 00:37:27 robertc Exp $ |
9cef6668 | 4 | * |
5 | * DEBUG: section 20 Storage Manager Swapin Functions | |
6 | * AUTHOR: Duane Wessels | |
7 | * | |
2b6662ba | 8 | * SQUID Web Proxy Cache http://www.squid-cache.org/ |
9cef6668 | 9 | * ---------------------------------------------------------- |
10 | * | |
2b6662ba | 11 | * Squid is the result of efforts by numerous individuals from |
12 | * the Internet community; see the CONTRIBUTORS file for full | |
13 | * details. Many organizations have provided support for Squid's | |
14 | * development; see the SPONSORS file for full details. Squid is | |
15 | * Copyrighted (C) 2001 by the Regents of the University of | |
16 | * California; see the COPYRIGHT file for full details. Squid | |
17 | * incorporates software developed and/or copyrighted by other | |
18 | * sources; see the CREDITS file for full details. | |
9cef6668 | 19 | * |
20 | * This program is free software; you can redistribute it and/or modify | |
21 | * it under the terms of the GNU General Public License as published by | |
22 | * the Free Software Foundation; either version 2 of the License, or | |
23 | * (at your option) any later version. | |
24 | * | |
25 | * This program is distributed in the hope that it will be useful, | |
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
28 | * GNU General Public License for more details. | |
29 | * | |
30 | * You should have received a copy of the GNU General Public License | |
31 | * along with this program; if not, write to the Free Software | |
32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
33 | * | |
34 | */ | |
35 | ||
f09f5b26 | 36 | #include "squid.h" |
c8be6d7b | 37 | #include "StoreClient.h" |
e6ccf245 | 38 | #include "Store.h" |
f09f5b26 | 39 | |
2391a162 | 40 | static STIOCB storeSwapInFileClosed; |
cd748f27 | 41 | static STFNCB storeSwapInFileNotify; |
2391a162 | 42 | |
1f38f50a | 43 | void |
44 | storeSwapInStart(store_client * sc) | |
f09f5b26 | 45 | { |
1f38f50a | 46 | StoreEntry *e = sc->entry; |
f09f5b26 | 47 | assert(e->mem_status == NOT_IN_MEMORY); |
d46a87a8 | 48 | if (!EBIT_TEST(e->flags, ENTRY_VALIDATED)) { |
d9584b35 | 49 | /* We're still reloading and haven't validated this entry yet */ |
1f38f50a | 50 | return; |
f09f5b26 | 51 | } |
cd748f27 | 52 | debug(20, 3) ("storeSwapInStart: called for %d %08X %s \n", |
332dafa2 | 53 | e->swap_dirn, e->swap_filen, e->getMD5Text()); |
5bd1abac | 54 | if (e->swap_status != SWAPOUT_WRITING && e->swap_status != SWAPOUT_DONE) { |
55 | debug(20, 1) ("storeSwapInStart: bad swap_status (%s)\n", | |
56 | swapStatusStr[e->swap_status]); | |
1f38f50a | 57 | return; |
5bd1abac | 58 | } |
cd748f27 | 59 | if (e->swap_filen < 0) { |
60 | debug(20, 1) ("storeSwapInStart: swap_filen < 0\n"); | |
1f38f50a | 61 | return; |
5bd1abac | 62 | } |
f09f5b26 | 63 | assert(e->mem_obj != NULL); |
2391a162 | 64 | debug(20, 3) ("storeSwapInStart: Opening fileno %08X\n", |
cd748f27 | 65 | e->swap_filen); |
d3b3ab85 | 66 | sc->swapin_sio = storeOpen(e, storeSwapInFileNotify, storeSwapInFileClosed, sc); |
f09f5b26 | 67 | } |
68 | ||
2391a162 | 69 | static void |
70 | storeSwapInFileClosed(void *data, int errflag, storeIOState * sio) | |
f09f5b26 | 71 | { |
e6ccf245 | 72 | store_client *sc = (store_client *)data; |
2391a162 | 73 | debug(20, 3) ("storeSwapInFileClosed: sio=%p, errflag=%d\n", |
74 | sio, errflag); | |
d3b3ab85 | 75 | sc->swapin_sio = NULL; |
528b2c61 | 76 | /* why this assert */ |
77 | if (sc->callbackPending()) { | |
78 | assert (errflag <= 0); | |
79 | sc->callback(0, errflag ? true : false); | |
9bc73deb | 80 | } |
83704487 | 81 | statCounter.swap.ins++; |
f09f5b26 | 82 | } |
cd748f27 | 83 | |
84 | static void | |
85 | storeSwapInFileNotify(void *data, int errflag, storeIOState * sio) | |
86 | { | |
e6ccf245 | 87 | store_client *sc = (store_client *)data; |
a4b8110e | 88 | StoreEntry *e = sc->entry; |
89 | ||
90 | debug(1, 3) ("storeSwapInFileNotify: changing %d/%d to %d/%d\n", e->swap_filen, e->swap_dirn, sio->swap_filen, sio->swap_dirn); | |
cd748f27 | 91 | |
a4b8110e | 92 | e->swap_filen = sio->swap_filen; |
93 | e->swap_dirn = sio->swap_dirn; | |
cd748f27 | 94 | } |