]> git.ipfire.org Git - thirdparty/squid.git/blob - src/store_swapin.cc
merge from SslServerCertValidator r12332
[thirdparty/squid.git] / src / store_swapin.cc
1 /*
2 * DEBUG: section 20 Storage Manager Swapin Functions
3 * AUTHOR: Duane Wessels
4 *
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
7 *
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.
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.
21 *
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.
26 *
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
33 #include "squid.h"
34 #include "globals.h"
35 #include "StatCounters.h"
36 #include "StoreClient.h"
37 #include "Store.h"
38 #include "store_swapin.h"
39
40 static StoreIOState::STIOCB storeSwapInFileClosed;
41 static StoreIOState::STFNCB storeSwapInFileNotify;
42
43 void
44 storeSwapInStart(store_client * sc)
45 {
46 StoreEntry *e = sc->entry;
47
48 if (!EBIT_TEST(e->flags, ENTRY_VALIDATED)) {
49 /* We're still reloading and haven't validated this entry yet */
50 return;
51 }
52
53 if (e->mem_status != NOT_IN_MEMORY)
54 debugs(20, 3, HERE << "already IN_MEMORY");
55
56 debugs(20, 3, "storeSwapInStart: called for : " << e->swap_dirn << " " <<
57 std::hex << std::setw(8) << std::setfill('0') << std::uppercase <<
58 e->swap_filen << " " << e->getMD5Text());
59
60 if (e->swap_status != SWAPOUT_WRITING && e->swap_status != SWAPOUT_DONE) {
61 debugs(20, DBG_IMPORTANT, "storeSwapInStart: bad swap_status (" << swapStatusStr[e->swap_status] << ")");
62 return;
63 }
64
65 if (e->swap_filen < 0) {
66 debugs(20, DBG_IMPORTANT, "storeSwapInStart: swap_filen < 0");
67 return;
68 }
69
70 assert(e->mem_obj != NULL);
71 debugs(20, 3, "storeSwapInStart: Opening fileno " << std::hex << std::setw(8) << std::setfill('0') << std::uppercase << e->swap_filen);
72 sc->swapin_sio = storeOpen(e, storeSwapInFileNotify, storeSwapInFileClosed, sc);
73 }
74
75 static void
76 storeSwapInFileClosed(void *data, int errflag, StoreIOState::Pointer self)
77 {
78 store_client *sc = (store_client *)data;
79 debugs(20, 3, "storeSwapInFileClosed: sio=" << sc->swapin_sio.getRaw() << ", errflag=" << errflag);
80 sc->swapin_sio = NULL;
81
82 if (sc->_callback.pending()) {
83 assert (errflag <= 0);
84 sc->callback(0, errflag ? true : false);
85 }
86
87 ++statCounter.swap.ins;
88 }
89
90 static void
91 storeSwapInFileNotify(void *data, int errflag, StoreIOState::Pointer self)
92 {
93 store_client *sc = (store_client *)data;
94 StoreEntry *e = sc->entry;
95
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);
99
100 assert(e->swap_filen < 0); // if this fails, call SwapDir::disconnect(e)
101 e->swap_filen = sc->swapin_sio->swap_filen;
102 e->swap_dirn = sc->swapin_sio->swap_dirn;
103 }