1 /*
2  * Copyright (C) 1996-2021 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    Swap Dir base object */
10 
11 #include "squid.h"
12 #include "Debug.h"
13 #include "defines.h"
14 #include "Store.h"
15 #include "StoreIOState.h"
16 
17 void *
operator new(size_t)18 StoreIOState::operator new (size_t)
19 {
20     assert(0);
21     return (void *)1;
22 }
23 
24 void
operator delete(void *)25 StoreIOState::operator delete (void *)
26 {
27     assert(0);
28 }
29 
StoreIOState(StoreIOState::STFNCB * cbFile,StoreIOState::STIOCB * cbIo,void * data)30 StoreIOState::StoreIOState(StoreIOState::STFNCB *cbFile, StoreIOState::STIOCB *cbIo, void *data) :
31     swap_dirn(-1),
32     swap_filen(-1),
33     e(NULL),
34     mode(O_BINARY),
35     offset_(0),
36     file_callback(cbFile),
37     callback(cbIo),
38     callback_data(cbdataReference(data))
39 {
40     read.callback = NULL;
41     read.callback_data = NULL;
42     flags.closing = false;
43 }
44 
~StoreIOState()45 StoreIOState::~StoreIOState()
46 {
47     debugs(20,3, "StoreIOState::~StoreIOState: " << this);
48 
49     if (read.callback_data)
50         cbdataReferenceDone(read.callback_data);
51 
52     if (callback_data)
53         cbdataReferenceDone(callback_data);
54 }
55 
touchingStoreEntry() const56 bool StoreIOState::touchingStoreEntry() const
57 {
58     return e && e->swap_filen == swap_filen;
59 }
60 
61