Squid Web Cache master
Loading...
Searching...
No Matches
IoCallback.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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
18namespace Comm
19{
20
27
30{
31public:
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
57private:
58 void reset();
59};
60
64{
65public:
66 int fd;
69};
70
73CbEntry &ioCallbacks(int fd);
74
75#define COMMIO_FD_READCB(fd) (&(Comm::ioCallbacks(fd).readcb))
76#define COMMIO_FD_WRITECB(fd) (&(Comm::ioCallbacks(fd).writecb))
77
78} // namespace Comm
79
80#endif /* SQUID_SRC_COMM_IOCALLBACK_H */
81
IoCallback writecb
Definition IoCallback.h:68
IoCallback readcb
Definition IoCallback.h:67
Details about a particular Comm IO callback event.
Definition IoCallback.h:30
void setCallback(iocb_type type, AsyncCall::Pointer &cb, char *buf, FREE *func, int sz)
Definition IoCallback.cc:60
bool active() const
Definition IoCallback.h:45
void selectOrQueueWrite()
called when fd needs to write but may need to wait in line for its quota
Definition IoCallback.cc:74
AsyncCall::Pointer callback
Definition IoCallback.h:34
void finish(Comm::Flag code, int xerrn)
finish the IO operation immediately and schedule the callback with the current state.
void cancel(const char *reason)
Actively cancel the given callback.
Definition IoCallback.cc:87
iocb_type type
Definition IoCallback.h:32
Comm::ConnectionPointer conn
Definition IoCallback.h:33
Comm::Flag errcode
Definition IoCallback.h:39
unsigned int quotaQueueReserv
reservation ID from CommQuotaQueue
Definition IoCallback.h:42
void FREE(void *)
Definition forward.h:37
Abstraction layer for TCP, UDP, TLS, UDS and filedescriptor sockets.
CbEntry & ioCallbacks(int fd)
Definition IoCallback.cc:42
iocb_type
Type of IO callbacks the Comm layer deals with.
Definition IoCallback.h:22
@ IOCB_NONE
Definition IoCallback.h:23
@ IOCB_WRITE
Definition IoCallback.h:25
@ IOCB_READ
Definition IoCallback.h:24
Flag
Definition Flag.h:15