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