IoCallback.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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 #ifndef SQUID_SRC_COMM_IOCALLBACK_H
10 #define SQUID_SRC_COMM_IOCALLBACK_H
11 
12 #include "base/AsyncCall.h"
13 #include "comm/Flag.h"
14 #include "comm/forward.h"
15 #include "mem/forward.h"
16 #include "sbuf/forward.h"
17 
18 namespace Comm
19 {
20 
22 typedef enum {
26 } iocb_type;
27 
30 {
31 public:
35  char *buf;
37  int size;
38  int offset;
40  int xerrno;
41 #if USE_DELAY_POOLS
42  unsigned int quotaQueueReserv;
43 #endif
44 
45  bool active() const { return callback != nullptr; }
46  void setCallback(iocb_type type, AsyncCall::Pointer &cb, char *buf, FREE *func, int sz);
47 
49  void selectOrQueueWrite();
50 
52  void cancel(const char *reason);
53 
55  void finish(Comm::Flag code, int xerrn);
56 
57 private:
58  void reset();
59 };
60 
63 class CbEntry
64 {
65 public:
66  int fd;
69 };
70 
73 extern CbEntry *iocb_table;
74 
75 void CallbackTableInit();
77 
78 #define COMMIO_FD_READCB(fd) (&Comm::iocb_table[(fd)].readcb)
79 #define COMMIO_FD_WRITECB(fd) (&Comm::iocb_table[(fd)].writecb)
80 
81 } // namespace Comm
82 
83 #endif /* SQUID_SRC_COMM_IOCALLBACK_H */
84 
IoCallback readcb
Definition: IoCallback.h:67
void FREE(void *)
Definition: forward.h:37
@ IOCB_READ
Definition: IoCallback.h:24
bool active() const
Definition: IoCallback.h:45
Abstraction layer for TCP, UDP, TLS, UDS and filedescriptor sockets.
Definition: AcceptLimiter.h:16
void setCallback(iocb_type type, AsyncCall::Pointer &cb, char *buf, FREE *func, int sz)
Definition: IoCallback.cc:55
@ IOCB_NONE
Definition: IoCallback.h:23
IoCallback writecb
Definition: IoCallback.h:68
AsyncCall::Pointer callback
Definition: IoCallback.h:34
Comm::ConnectionPointer conn
Definition: IoCallback.h:33
Details about a particular Comm IO callback event.
Definition: IoCallback.h:29
@ IOCB_WRITE
Definition: IoCallback.h:25
void cancel(const char *reason)
Actively cancel the given callback.
Definition: IoCallback.cc:82
iocb_type
Type of IO callbacks the Comm layer deals with.
Definition: IoCallback.h:22
void selectOrQueueWrite()
called when fd needs to write but may need to wait in line for its quota
Definition: IoCallback.cc:69
int code
Definition: smb-errors.c:145
Flag
Definition: Flag.h:15
Comm::Flag errcode
Definition: IoCallback.h:39
unsigned int quotaQueueReserv
reservation ID from CommQuotaQueue
Definition: IoCallback.h:42
void finish(Comm::Flag code, int xerrn)
finish the IO operation immediately and schedule the callback with the current state.
Definition: IoCallback.cc:110
iocb_type type
Definition: IoCallback.h:32
void CallbackTableDestruct()
Definition: IoCallback.cc:34
void CallbackTableInit()
Definition: IoCallback.cc:22
CbEntry * iocb_table
Definition: IoCallback.cc:19

 

Introduction

Documentation

Support

Miscellaneous