]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/comm/IoCallback.h
1 #ifndef _SQUID_COMM_IOCALLBACK_H
2 #define _SQUID_COMM_IOCALLBACK_H
4 #include "base/AsyncCall.h"
5 #include "comm/forward.h"
6 #include "comm_err_t.h"
14 /// Type of IO callbacks the Comm layer deals with.
21 /// Details about a particular Comm IO callback event.
26 Comm::ConnectionPointer conn
;
27 AsyncCall::Pointer callback
;
29 /// Buffer to store read(2) into when set.
30 // This is a pointer to the Jobs buffer rather than an SBuf using
31 // the same store since we cannot know when or how the Job will
32 // alter its SBuf while we are reading.
35 // Legacy c-string buffers used when buf2 is unset.
43 unsigned int quotaQueueReserv
; ///< reservation ID from CommQuotaQueue
46 bool active() const { return callback
!= NULL
; }
47 void setCallback(iocb_type type
, AsyncCall::Pointer
&cb
, char *buf
, FREE
*func
, int sz
);
49 /// called when fd needs to write but may need to wait in line for its quota
50 void selectOrQueueWrite();
52 /// Actively cancel the given callback
53 void cancel(const char *reason
);
55 /// finish the IO operation imediately and schedule the callback with the current state.
56 void finish(comm_err_t code
, int xerrn
);
62 /// Entry nodes for the IO callback table: iocb_table
63 /// Keyed off the FD which the event applies to.
72 /// Table of scheduled IO events which have yet to be processed ??
73 /// Callbacks which might be scheduled in future are stored in fd_table.
74 extern CbEntry
*iocb_table
;
76 void CallbackTableInit();
77 void CallbackTableDestruct();
79 #define COMMIO_FD_READCB(fd) (&Comm::iocb_table[(fd)].readcb)
80 #define COMMIO_FD_WRITECB(fd) (&Comm::iocb_table[(fd)].writecb)
84 #endif /* _SQUID_COMM_IOCALLBACK_H */