]> git.ipfire.org Git - thirdparty/squid.git/blame - src/comm/Read.h
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / comm / Read.h
CommitLineData
bbc27441 1/*
77b1029d 2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
bbc27441
AJ
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"
92e8f3ad 15#include "sbuf/forward.h"
7e66d5e2
AJ
16
17namespace 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 */
26void Read(const Comm::ConnectionPointer &conn, AsyncCall::Pointer &callback);
27
28/// whether the FD socket is being monitored for read
29bool MonitorsRead(int fd);
30
31/**
32 * Perform a read(2) on a connection immediately.
33 *
983de17b
AJ
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 *
7e66d5e2
AJ
37 * The returned flag is also placed in params.flag.
38 *
c8407295 39 * \retval Comm::OK data has been read and placed in buf, amount in params.size
61beade2
AJ
40 * \retval Comm::COMM_ERROR an error occurred, the code is placed in params.xerrno
41 * \retval Comm::INPROGRESS unable to read at this time, or a minor error occurred
42 * \retval Comm::ENDFILE 0-byte read has occurred.
3675f0ed 43 * Usually indicates the remote end has disconnected.
7e66d5e2 44 */
c8407295 45Comm::Flag ReadNow(CommIoCbParams &params, SBuf &buf);
7e66d5e2
AJ
46
47/// Cancel the read pending on FD. No action if none pending.
48void ReadCancel(int fd, AsyncCall::Pointer &callback);
49
50/// callback handler to process an FD which is available for reading
51extern PF HandleRead;
52
f5e17947
CT
53/// maximum read delay for readers with limited lifetime
54time_t MortalReadTimeout(const time_t startTime, const time_t lifetimeLimit);
7e66d5e2
AJ
55} // namespace Comm
56
57// Legacy API to be removed
58void comm_read_base(const Comm::ConnectionPointer &conn, char *buf, int len, AsyncCall::Pointer &callback);
59inline void comm_read(const Comm::ConnectionPointer &conn, char *buf, int len, AsyncCall::Pointer &callback)
60{
61 assert(buf != NULL);
62 comm_read_base(conn, buf, len, callback);
63}
64void comm_read_cancel(int fd, IOCB *callback, void *data);
7e66d5e2
AJ
65
66#endif /* _SQUID_COMM_READ_H */
f53969cc 67