1 /*
2  * Copyright (C) 1996-2021 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_SRC_COMM_LOOPS_H
10 #define _SQUID_SRC_COMM_LOOPS_H
11 
12 #include "comm/Flag.h"
13 #include "comm/forward.h"
14 #include "defines.h"
15 
16 /* Comm layer select loops API.
17  *
18  * These API functions must be implemented by all FD IO loops used by Squid.
19  * Defines are provided short-term for legacy code. These will disappear soon.
20  */
21 
22 namespace Comm
23 {
24 
25 /// Initialize the module on Squid startup
26 void SelectLoopInit(void);
27 
28 /// Mark an FD to be watched for its IO status.
29 void SetSelect(int, unsigned int, PF *, void *, time_t);
30 
31 /// reset/undo/unregister the watch for an FD which was set by Comm::SetSelect()
32 inline void
ResetSelect(int fd)33 ResetSelect(int fd)
34 {
35     SetSelect(fd, COMM_SELECT_READ|COMM_SELECT_WRITE, nullptr, nullptr, 0);
36 }
37 
38 /** Perform a select() or equivalent call.
39  * This is used by the main select loop engine to check for FD with IO available.
40  */
41 Comm::Flag DoSelect(int);
42 
43 void QuickPollRequired(void);
44 
45 /**
46  * Max number of UDP messages to receive per call to the UDP receive poller.
47  * This is a per-port limit for ICP/HTCP ports.
48  * DNS has a separate limit.
49  */
50 #if _SQUID_WINDOWS_
51 #define INCOMING_UDP_MAX 1
52 #else
53 #define INCOMING_UDP_MAX 15
54 #endif
55 
56 /**
57  * Max number of DNS messages to receive per call to DNS read handler
58  */
59 #if _SQUID_WINDOWS_
60 #define INCOMING_DNS_MAX 1
61 #else
62 #define INCOMING_DNS_MAX 15
63 #endif
64 
65 /**
66  * Max number of new TCP connections to accept per call to the TCP listener poller.
67  * This is a per-port limit for HTTP/HTTPS ports.
68  */
69 #if _SQUID_WINDOWS_
70 #define INCOMING_TCP_MAX 1
71 #else
72 #define INCOMING_TCP_MAX 10
73 #endif
74 #define INCOMING_TOTAL_MAX (INCOMING_TCP_MAX+INCOMING_UDP_MAX+INCOMING_DNS_MAX)
75 
76 } // namespace Comm
77 
78 #endif /* _SQUID_SRC_COMM_LOOPS_H */
79 
80