IoCallback.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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_COMM_IOCALLBACK_H
10 #define _SQUID_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:
32  iocb_type type;
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 != NULL; }
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_COMM_IOCALLBACK_H */
84 
void finish(Comm::Flag code, int xerrn)
finish the IO operation imediately and schedule the callback with the current state.
Definition: IoCallback.cc:110
Abstraction layer for TCP, UDP, TLS, UDS and filedescriptor sockets.
Definition: AcceptLimiter.h:16
CbEntry * iocb_table
Definition: IoCallback.cc:19
AsyncCall::Pointer callback
Definition: IoCallback.h:34
void FREE(void *)
Definition: forward.h:36
void setCallback(iocb_type type, AsyncCall::Pointer &cb, char *buf, FREE *func, int sz)
Definition: IoCallback.cc:55
void CallbackTableInit()
Definition: IoCallback.cc:22
Comm::Flag errcode
Definition: IoCallback.h:39
void CallbackTableDestruct()
Definition: IoCallback.cc:34
iocb_type
Type of IO callbacks the Comm layer deals with.
Definition: IoCallback.h:22
Comm::ConnectionPointer conn
Definition: IoCallback.h:33
void cancel(const char *reason)
Actively cancel the given callback.
Definition: IoCallback.cc:82
void const char int sz
Definition: stub_cbdata.cc:16
IoCallback writecb
Definition: IoCallback.h:68
void selectOrQueueWrite()
called when fd needs to write but may need to wait in line for its quota
Definition: IoCallback.cc:69
unsigned char code
Definition: html_quote.c:20
unsigned int quotaQueueReserv
reservation ID from CommQuotaQueue
Definition: IoCallback.h:42
Flag
Definition: Flag.h:15
iocb_type type
Definition: IoCallback.h:32
void EVH * func
Definition: stub_event.cc:16
IoCallback readcb
Definition: IoCallback.h:67
bool active() const
Definition: IoCallback.h:45
#define NULL
Definition: types.h:166
Details about a particular Comm IO callback event.
Definition: IoCallback.h:29

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors