]> git.ipfire.org Git - thirdparty/squid.git/blob - src/store_swapin.cc
MODIO_1 commit. This change (including documentation) implements a more
[thirdparty/squid.git] / src / store_swapin.cc
1
2 /*
3 * $Id: store_swapin.cc,v 1.23 2000/05/03 17:15:44 adrian Exp $
4 *
5 * DEBUG: section 20 Storage Manager Swapin Functions
6 * AUTHOR: Duane Wessels
7 *
8 * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
9 * ----------------------------------------------------------
10 *
11 * Squid is the result of efforts by numerous individuals from the
12 * Internet community. Development is led by Duane Wessels of the
13 * National Laboratory for Applied Network Research and funded by the
14 * National Science Foundation. Squid is Copyrighted (C) 1998 by
15 * the Regents of the University of California. Please see the
16 * COPYRIGHT file for full details. Squid incorporates software
17 * developed and/or copyrighted by other sources. Please see the
18 * CREDITS file for full details.
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
36 #include "squid.h"
37
38 static STIOCB storeSwapInFileClosed;
39 static STFNCB storeSwapInFileNotify;
40
41 void
42 storeSwapInStart(store_client * sc)
43 {
44 StoreEntry *e = sc->entry;
45 assert(e->mem_status == NOT_IN_MEMORY);
46 if (!EBIT_TEST(e->flags, ENTRY_VALIDATED)) {
47 /* We're still reloading and haven't validated this entry yet */
48 return;
49 }
50 debug(20, 3) ("storeSwapInStart: called for %d %08X %s \n",
51 e->swap_dirn, e->swap_filen, storeKeyText(e->key));
52 if (e->swap_status != SWAPOUT_WRITING && e->swap_status != SWAPOUT_DONE) {
53 debug(20, 1) ("storeSwapInStart: bad swap_status (%s)\n",
54 swapStatusStr[e->swap_status]);
55 return;
56 }
57 if (e->swap_filen < 0) {
58 debug(20, 1) ("storeSwapInStart: swap_filen < 0\n");
59 return;
60 }
61 assert(e->mem_obj != NULL);
62 debug(20, 3) ("storeSwapInStart: Opening fileno %08X\n",
63 e->swap_filen);
64 sc->swapin_sio = storeOpen(e, storeSwapInFileNotify, storeSwapInFileClosed,
65 sc);
66 cbdataLock(sc->swapin_sio);
67 }
68
69 static void
70 storeSwapInFileClosed(void *data, int errflag, storeIOState * sio)
71 {
72 store_client *sc = data;
73 STCB *callback;
74 debug(20, 3) ("storeSwapInFileClosed: sio=%p, errflag=%d\n",
75 sio, errflag);
76 cbdataUnlock(sio);
77 sc->swapin_sio = NULL;
78 if ((callback = sc->callback)) {
79 assert(errflag <= 0);
80 sc->callback = NULL;
81 callback(sc->callback_data, sc->copy_buf, errflag);
82 }
83 }
84
85 static void
86 storeSwapInFileNotify(void *data, int errflag, storeIOState * sio)
87 {
88 store_client *sc = data;
89 StoreEntry *e = sc->entry;
90
91 debug(1, 3) ("storeSwapInFileNotify: changing %d/%d to %d/%d\n", e->swap_filen, e->swap_dirn, sio->swap_filen, sio->swap_dirn);
92
93 e->swap_filen = sio->swap_filen;
94 e->swap_dirn = sio->swap_dirn;
95 }