]> git.ipfire.org Git - thirdparty/squid.git/blob - src/comm/Read.h
Cleanup: remove comm_read_cancel(AsyncCall) API
[thirdparty/squid.git] / src / comm / Read.h
1 #ifndef _SQUID_COMM_READ_H
2 #define _SQUID_COMM_READ_H
3
4 #include "base/AsyncCall.h"
5 #include "CommCalls.h"
6 #include "comm/forward.h"
7
8 class SBuf;
9
10 namespace Comm
11 {
12
13 /**
14 * Start monitoring for read.
15 *
16 * callback is scheduled when the read is possible,
17 * or on file descriptor close.
18 */
19 void Read(const Comm::ConnectionPointer &conn, AsyncCall::Pointer &callback);
20
21 /// whether the FD socket is being monitored for read
22 bool MonitorsRead(int fd);
23
24 /**
25 * Perform a read(2) on a connection immediately.
26 *
27 * The returned flag is also placed in params.flag.
28 *
29 * \retval COMM_OK data has been read and placed in buf, amount in params.size
30 * \retval COMM_ERROR an error occured, the code is placed in params.xerrno
31 * \retval COMM_INPROGRESS unable to read at this time, or a minor error occured
32 * \retval COMM_ERR_CLOSING 0-byte read has occured.
33 * Usually indicates the remote end has disconnected.
34 */
35 comm_err_t ReadNow(CommIoCbParams &params, SBuf &buf);
36
37 /// Cancel the read pending on FD. No action if none pending.
38 void ReadCancel(int fd, AsyncCall::Pointer &callback);
39
40 /// callback handler to process an FD which is available for reading
41 extern PF HandleRead;
42
43 } // namespace Comm
44
45 // Legacy API to be removed
46 void comm_read_base(const Comm::ConnectionPointer &conn, char *buf, int len, AsyncCall::Pointer &callback);
47 inline void comm_read(const Comm::ConnectionPointer &conn, char *buf, int len, AsyncCall::Pointer &callback)
48 {
49 assert(buf != NULL);
50 comm_read_base(conn, buf, len, callback);
51 }
52 void comm_read_cancel(int fd, IOCB *callback, void *data);
53
54 #endif /* _SQUID_COMM_READ_H */