]> git.ipfire.org Git - thirdparty/squid.git/blob - src/comm/ListenStateData.h
Better bug 2972 fix.
[thirdparty/squid.git] / src / comm / ListenStateData.h
1 #ifndef SQUID_LISTENERSTATEDATA_H
2 #define SQUID_LISTENERSTATEDATA_H
3
4 #include "config.h"
5 #include "base/AsyncCall.h"
6 #include "comm.h"
7 #if HAVE_MAP
8 #include <map>
9 #endif
10
11 class ConnectionDetail;
12
13 namespace Comm
14 {
15
16 class ListenStateData
17 {
18
19 public:
20 ListenStateData(int fd, AsyncCall::Pointer &call, bool accept_many);
21 ListenStateData(const ListenStateData &r); // not implemented.
22 ~ListenStateData();
23
24 void subscribe(AsyncCall::Pointer &call);
25 void acceptNext();
26 void notify(int newfd, comm_err_t, int xerrno, const ConnectionDetail &);
27
28 int fd;
29
30 /// errno code if any happened so far.
31 int errcode;
32
33 /// whether this socket is delayed and on the AcceptLimiter queue.
34 int32_t isLimited;
35
36 private:
37 /// Method to test if there are enough file escriptors to open a new client connection
38 /// if not the accept() will be postponed
39 static bool okToAccept();
40
41 /// Method callback for whenever an FD is ready to accept a client connection.
42 static void doAccept(int fd, void *data);
43
44 bool acceptOne();
45 int oldAccept(ConnectionDetail &details);
46
47 AsyncCall::Pointer theCallback;
48 bool mayAcceptMore;
49
50 void setListen();
51 };
52
53 }; // namespace Comm
54
55 #endif /* SQUID_LISTENERSTATEDATA_H */