comm.h
Go to the documentation of this file.
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 __COMM_H__
10 #define __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 void commSetCloseOnExec(int fd);
26 void _comm_close(int fd, char const *file, int line);
27 #define comm_close(x) (_comm_close((x), __FILE__, __LINE__))
28 void old_comm_reset_close(int fd);
30 
31 int comm_connect_addr(int sock, const Ip::Address &addr);
32 void comm_init(void);
33 void comm_exit(void);
34 
35 int comm_open(int, int, Ip::Address &, int, const char *note);
36 int comm_open_uds(int sock_type, int proto, struct sockaddr_un* addr, int flags);
38 void comm_import_opened(const Comm::ConnectionPointer &, const char *note, struct addrinfo *AI);
39 
55 int comm_open_listener(int sock_type, int proto, Ip::Address &addr, int flags, const char *note);
56 void comm_open_listener(int sock_type, int proto, Comm::ConnectionPointer &conn, const char *note);
57 
58 int comm_openex(int, int, Ip::Address &, int, const char *);
59 unsigned short comm_local_port(int fd);
60 
61 int comm_udp_sendto(int sock, const Ip::Address &to, const void *buf, int buflen);
62 void commCallCloseHandlers(int fd);
63 
65 void commUnsetFdTimeout(int fd);
66 
71 int commSetConnTimeout(const Comm::ConnectionPointer &conn, int seconds, AsyncCall::Pointer &callback);
73 
74 int ignoreErrno(int);
75 void commCloseAllSockets(void);
76 void checkTimeouts(void);
77 
80 void comm_remove_close_handler(int fd, CLCB *, void *);
82 
83 int comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, Ip::Address &from);
84 int comm_udp_recv(int fd, void *buf, size_t len, int flags);
85 ssize_t comm_udp_send(int s, const void *buf, size_t len, int flags);
87 
93 void commStartHalfClosedMonitor(int fd);
94 bool commHasHalfClosedMonitor(int fd);
95 // XXX: remove these wrappers which minimize client_side.cc changes in a commit
96 inline void commMarkHalfClosed(int fd) { commStartHalfClosedMonitor(fd); }
97 inline bool commIsHalfClosed(int fd) { return commHasHalfClosedMonitor(fd); }
98 
99 /* A comm engine that calls comm_select */
100 
102 {
103 
104 public:
105  virtual int checkEvents(int timeout);
106 };
107 
108 #endif
109 
int comm_open_listener(int sock_type, int proto, Ip::Address &addr, int flags, const char *note)
Definition: comm.cc:246
void comm_init(void)
Definition: comm.cc:1150
int comm_openex(int, int, Ip::Address &, int, const char *)
Definition: comm.cc:331
void _comm_close(int fd, char const *file, int line)
Definition: comm.cc:821
void checkTimeouts(void)
Definition: comm.cc:1511
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:1837
void commCloseAllSockets(void)
Definition: comm.cc:1454
bool commIsHalfClosed(int fd)
Definition: comm.h:97
void CLCB(const CommCloseCbParams &params)
Definition: CommCalls.h:42
void old_comm_reset_close(int fd)
Definition: comm.cc:775
bool comm_iocallbackpending(void)
void commStartHalfClosedMonitor(int fd)
Start waiting for a possibly half-closed connection to close.
Definition: comm.cc:1564
AsyncCall::Pointer comm_add_close_handler(int fd, CLCB *, void *)
Definition: comm.cc:935
int comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, Ip::Address &from)
Definition: comm.cc:122
void comm_reset_close(const Comm::ConnectionPointer &conn)
Definition: comm.cc:760
int commSetConnTimeout(const Comm::ConnectionPointer &conn, int seconds, AsyncCall::Pointer &callback)
Definition: comm.cc:567
int comm_open(int, int, Ip::Address &, int, const char *note)
Definition: comm.cc:223
void commUnsetFdTimeout(int fd)
clear a timeout handler by FD number
Definition: comm.cc:554
unsigned short comm_local_port(int fd)
Definition: comm.cc:161
int comm_udp_sendto(int sock, const Ip::Address &to, const void *buf, int buflen)
Definition: comm.cc:901
int conn
the current server connection FD
Definition: Transport.cc:26
int comm_connect_addr(int sock, const Ip::Address &addr)
Definition: comm.cc:606
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:514
void comm_remove_close_handler(int fd, CLCB *, void *)
Definition: comm.cc:962
int ignoreErrno(int)
Definition: comm.cc:1424
virtual int checkEvents(int timeout)
Definition: comm.cc:1804
Definition: client_db.h:23
void commSetCloseOnExec(int fd)
Definition: comm.cc:1111
int commUnsetConnTimeout(const Comm::ConnectionPointer &conn)
Definition: comm.cc:593
ssize_t comm_udp_send(int s, const void *buf, size_t len, int flags)
Definition: comm.cc:142
void comm_exit(void)
Definition: comm.cc:1173
void commCallCloseHandlers(int fd)
Definition: comm.cc:734
int commSetNonBlocking(int fd)
Definition: comm.cc:1050
int comm_udp_recv(int fd, void *buf, size_t len, int flags)
Definition: comm.cc:135
bool comm_has_incomplete_write(int)
Definition: comm.cc:148
int commUnsetNonBlocking(int fd)
Definition: comm.cc:1083
static StatHist s
bool commHasHalfClosedMonitor(int fd)
checks whether we are waiting for possibly half-closed connection to close
Definition: comm.cc:1614
void commMarkHalfClosed(int fd)
Definition: comm.h:96

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors