]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 1996-2018 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_READ_H | |
10 | #define _SQUID_COMM_READ_H | |
11 | ||
12 | #include "base/AsyncCall.h" | |
13 | #include "comm/forward.h" | |
14 | #include "CommCalls.h" | |
15 | #include "sbuf/forward.h" | |
16 | ||
17 | namespace Comm | |
18 | { | |
19 | ||
20 | /** | |
21 | * Start monitoring for read. | |
22 | * | |
23 | * callback is scheduled when the read is possible, | |
24 | * or on file descriptor close. | |
25 | */ | |
26 | void Read(const Comm::ConnectionPointer &conn, AsyncCall::Pointer &callback); | |
27 | ||
28 | /// whether the FD socket is being monitored for read | |
29 | bool MonitorsRead(int fd); | |
30 | ||
31 | /** | |
32 | * Perform a read(2) on a connection immediately. | |
33 | * | |
34 | * If params.size is non-zero will limit size of the read to either | |
35 | * the buffer free space or params.size, whichever is smallest. | |
36 | * | |
37 | * The returned flag is also placed in params.flag. | |
38 | * | |
39 | * \retval Comm::OK data has been read and placed in buf, amount in params.size | |
40 | * \retval Comm::COMM_ERROR an error occured, the code is placed in params.xerrno | |
41 | * \retval Comm::INPROGRESS unable to read at this time, or a minor error occured | |
42 | * \retval Comm::ENDFILE 0-byte read has occured. | |
43 | * Usually indicates the remote end has disconnected. | |
44 | */ | |
45 | Comm::Flag ReadNow(CommIoCbParams ¶ms, SBuf &buf); | |
46 | ||
47 | /// Cancel the read pending on FD. No action if none pending. | |
48 | void ReadCancel(int fd, AsyncCall::Pointer &callback); | |
49 | ||
50 | /// callback handler to process an FD which is available for reading | |
51 | extern PF HandleRead; | |
52 | ||
53 | } // namespace Comm | |
54 | ||
55 | // Legacy API to be removed | |
56 | void comm_read_base(const Comm::ConnectionPointer &conn, char *buf, int len, AsyncCall::Pointer &callback); | |
57 | inline void comm_read(const Comm::ConnectionPointer &conn, char *buf, int len, AsyncCall::Pointer &callback) | |
58 | { | |
59 | assert(buf != NULL); | |
60 | comm_read_base(conn, buf, len, callback); | |
61 | } | |
62 | void comm_read_cancel(int fd, IOCB *callback, void *data); | |
63 | ||
64 | #endif /* _SQUID_COMM_READ_H */ | |
65 |