store_swapin.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /* DEBUG: section 20 Storage Manager Swapin Functions */
10 
11 #include "squid.h"
12 #include "globals.h"
13 #include "StatCounters.h"
14 #include "Store.h"
15 #include "store_swapin.h"
16 #include "StoreClient.h"
17 
20 
21 void
23 {
24  StoreEntry *e = sc->entry;
25 
26  if (!EBIT_TEST(e->flags, ENTRY_VALIDATED)) {
27  /* We're still reloading and haven't validated this entry yet */
28  return;
29  }
30 
31  if (e->mem_status != NOT_IN_MEMORY)
32  debugs(20, 3, HERE << "already IN_MEMORY");
33 
34  debugs(20, 3, *e << " " << e->getMD5Text());
35 
36  if (!e->hasDisk()) {
37  debugs(20, DBG_IMPORTANT, "BUG: Attempt to swap in a not-stored entry " << *e << ". Salvaged.");
38  return;
39  }
40 
41  assert(e->mem_obj != NULL);
43 }
44 
45 static void
47 {
48  store_client *sc = (store_client *)data;
49  debugs(20, 3, "storeSwapInFileClosed: sio=" << sc->swapin_sio.getRaw() << ", errflag=" << errflag);
50  sc->swapin_sio = NULL;
51 
52  if (sc->_callback.pending()) {
53  assert (errflag <= 0);
54  sc->callback(0, errflag ? true : false);
55  }
56 
58 }
59 
60 static void
62 {
63  store_client *sc = (store_client *)data;
64  StoreEntry *e = sc->entry;
65 
66  debugs(1, 3, "storeSwapInFileNotify: changing " << e->swap_filen << "/" <<
67  e->swap_dirn << " to " << sc->swapin_sio->swap_filen << "/" <<
68  sc->swapin_sio->swap_dirn);
69 
70  assert(e->swap_filen < 0); // if this fails, call SwapDir::disconnect(e)
72  e->swap_dirn = sc->swapin_sio->swap_dirn;
73 }
74 
sdirno swap_dirn
Definition: Store.h:214
StatCounters statCounter
Definition: StatCounters.cc:12
#define assert(EX)
Definition: assert.h:17
static int sc[16]
Definition: smbdes.c:121
struct StatCounters::@138 swap
bool hasDisk(const sdirno dirn=-1, const sfileno filen=-1) const
Definition: store.cc:2014
sfileno swap_filen
unique ID inside a cache_dir for swapped out entries; -1 for others
Definition: Store.h:212
static StoreIOState::STIOCB storeSwapInFileClosed
Definition: store_swapin.cc:18
void const char HLPCB void * data
Definition: stub_helper.cc:16
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:124
#define DBG_IMPORTANT
Definition: Debug.h:46
mem_status_t mem_status
Definition: Store.h:216
void STFNCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:41
StoreIOState::Pointer swapin_sio
Definition: StoreClient.h:86
uint16_t flags
Definition: Store.h:208
StoreEntry * entry
Definition: StoreClient.h:85
MemObject * mem_obj
Definition: Store.h:197
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:153
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:51
virtual const char * getMD5Text() const
Definition: store.cc:183
StoreIOState::Pointer storeOpen(StoreEntry *e, StoreIOState::STFNCB *file_callback, StoreIOState::STIOCB *callback, void *callback_data)
Definition: store_io.cc:61
sdirno swap_dirn
Definition: StoreIOState.h:83
#define EBIT_TEST(flag, bit)
Definition: defines.h:107
void storeSwapInStart(store_client *sc)
Definition: store_swapin.cc:22
C * getRaw() const
Definition: RefCount.h:74
#define NULL
Definition: types.h:166
struct store_client::Callback _callback
void callback(ssize_t len, bool error=false)
static StoreIOState::STFNCB storeSwapInFileNotify
Definition: store_swapin.cc:19
sfileno swap_filen
Definition: StoreIOState.h:84

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors