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