comm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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_H
10 #define SQUID_SRC_COMM_H
11 
12 #include "comm/IoCallback.h"
13 #include "CommCalls.h"
14 #include "StoreIOBuffer.h"
15 
16 namespace Ip
17 {
18 class Address;
19 }
20 
21 bool comm_iocallbackpending(void); /* inline candidate */
22 
23 int commSetNonBlocking(int fd);
24 int commUnsetNonBlocking(int fd);
25 
33 void commSetCloseOnExec(int fd);
34 
35 void _comm_close(int fd, char const *file, int line);
36 #define comm_close(x) (_comm_close((x), __FILE__, __LINE__))
37 void old_comm_reset_close(int fd);
39 
40 int comm_connect_addr(int sock, const Ip::Address &addr);
41 void comm_init(void);
42 void comm_exit(void);
43 
44 int comm_open(int, int, Ip::Address &, int, const char *note);
45 int comm_open_uds(int sock_type, int proto, struct sockaddr_un* addr, int flags);
47 void comm_import_opened(const Comm::ConnectionPointer &, const char *note, struct addrinfo *AI);
48 
63 int comm_open_listener(int sock_type, int proto, Ip::Address &addr, int flags, const char *note);
64 void comm_open_listener(int sock_type, int proto, Comm::ConnectionPointer &conn, const char *note);
65 
66 unsigned short comm_local_port(int fd);
67 
68 int comm_udp_sendto(int sock, const Ip::Address &to, const void *buf, int buflen);
69 void commCallCloseHandlers(int fd);
70 
72 void commUnsetFdTimeout(int fd);
73 
78 void commSetConnTimeout(const Comm::ConnectionPointer &, time_t seconds, AsyncCall::Pointer &);
80 
81 int ignoreErrno(int);
82 void commCloseAllSockets(void);
83 void checkTimeouts(void);
84 
87 void comm_remove_close_handler(int fd, CLCB *, void *);
89 
90 int comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, Ip::Address &from);
91 int comm_udp_recv(int fd, void *buf, size_t len, int flags);
92 ssize_t comm_udp_send(int s, const void *buf, size_t len, int flags);
94 
100 void commStartHalfClosedMonitor(int fd);
101 bool commHasHalfClosedMonitor(int fd);
102 // XXX: remove these wrappers which minimize client_side.cc changes in a commit
103 inline void commMarkHalfClosed(int fd) { commStartHalfClosedMonitor(fd); }
104 inline bool commIsHalfClosed(int fd) { return commHasHalfClosedMonitor(fd); }
105 
106 /* A comm engine that calls comm_select */
107 
109 {
110 
111 public:
112  int checkEvents(int timeout) override;
113 };
114 
115 #endif /* SQUID_SRC_COMM_H */
116 
int comm_open_listener(int sock_type, int proto, Ip::Address &addr, int flags, const char *note)
Definition: comm.cc:270
void comm_init(void)
Definition: comm.cc:1151
void _comm_close(int fd, char const *file, int line)
Definition: comm.cc:849
void checkTimeouts(void)
Definition: comm.cc:1509
int comm_open_uds(int sock_type, int proto, struct sockaddr_un *addr, int flags)
Create a unix-domain socket (UDS) that only supports FD_MSGHDR I/O.
Definition: comm.cc:1692
void commCloseAllSockets(void)
Definition: comm.cc:1452
bool commIsHalfClosed(int fd)
Definition: comm.h:104
void CLCB(const CommCloseCbParams &params)
Definition: CommCalls.h:40
void old_comm_reset_close(int fd)
Definition: comm.cc:808
bool comm_iocallbackpending(void)
void commStartHalfClosedMonitor(int fd)
Start waiting for a possibly half-closed connection to close.
Definition: comm.cc:1562
AsyncCall::Pointer comm_add_close_handler(int fd, CLCB *, void *)
Definition: comm.cc:952
int comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, Ip::Address &from)
Definition: comm.cc:126
void comm_reset_close(const Comm::ConnectionPointer &conn)
Definition: comm.cc:797
int checkEvents(int timeout) override
Definition: comm.cc:1659
int comm_open(int, int, Ip::Address &, int, const char *note)
Definition: comm.cc:243
void commUnsetFdTimeout(int fd)
clear a timeout handler by FD number
Definition: comm.cc:579
unsigned short comm_local_port(int fd)
Definition: comm.cc:165
int comm_udp_sendto(int sock, const Ip::Address &to, const void *buf, int buflen)
Definition: comm.cc:921
int comm_connect_addr(int sock, const Ip::Address &addr)
Definition: comm.cc:629
void comm_import_opened(const Comm::ConnectionPointer &, const char *note, struct addrinfo *AI)
update Comm state after getting a comm_open() FD from another process
Definition: comm.cc:549
void comm_remove_close_handler(int fd, CLCB *, void *)
Definition: comm.cc:981
int ignoreErrno(int)
Definition: comm.cc:1422
void commSetConnTimeout(const Comm::ConnectionPointer &, time_t seconds, AsyncCall::Pointer &)
Definition: comm.cc:592
Definition: Xaction.cc:137
void commSetCloseOnExec(int fd)
Definition: minimal.cc:27
ssize_t comm_udp_send(int s, const void *buf, size_t len, int flags)
Definition: comm.cc:146
void comm_exit(void)
Definition: comm.cc:1171
void commCallCloseHandlers(int fd)
Definition: comm.cc:754
int commSetNonBlocking(int fd)
Definition: comm.cc:1054
int comm_udp_recv(int fd, void *buf, size_t len, int flags)
Definition: comm.cc:139
bool comm_has_incomplete_write(int)
Definition: comm.cc:152
void commUnsetConnTimeout(const Comm::ConnectionPointer &)
Definition: comm.cc:616
int commUnsetNonBlocking(int fd)
Definition: comm.cc:1087
bool commHasHalfClosedMonitor(int fd)
checks whether we are waiting for possibly half-closed connection to close
Definition: comm.cc:1612
void commMarkHalfClosed(int fd)
Definition: comm.h:103

 

Introduction

Documentation

Support

Miscellaneous