comm.h File Reference
#include "comm/IoCallback.h"
#include "CommCalls.h"
#include "StoreIOBuffer.h"
Include dependency graph for comm.h:

Go to the source code of this file.

Classes

class  CommSelectEngine
 

Namespaces

 Ip
 

Macros

#define comm_close(x)   (_comm_close((x), __FILE__, __LINE__))
 

Functions

bool comm_iocallbackpending (void)
 
int commSetNonBlocking (int fd)
 
int commUnsetNonBlocking (int fd)
 
void commSetCloseOnExec (int fd)
 
void commSetTcpKeepalive (int fd, int idle, int interval, int timeout)
 
void _comm_close (int fd, char const *file, int line)
 
void old_comm_reset_close (int fd)
 
void comm_reset_close (const Comm::ConnectionPointer &conn)
 
int comm_connect_addr (int sock, const Ip::Address &addr)
 
void comm_init (void)
 
void comm_exit (void)
 
int comm_open (int, int, Ip::Address &, int, const char *note)
 
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. More...
 
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 More...
 
int comm_open_listener (int sock_type, int proto, Ip::Address &addr, int flags, const char *note)
 
void comm_open_listener (int sock_type, int proto, Comm::ConnectionPointer &conn, const char *note)
 
int comm_openex (int, int, Ip::Address &, int, const char *)
 
unsigned short comm_local_port (int fd)
 
int comm_udp_sendto (int sock, const Ip::Address &to, const void *buf, int buflen)
 
void commCallCloseHandlers (int fd)
 
void commUnsetFdTimeout (int fd)
 clear a timeout handler by FD number More...
 
int commSetConnTimeout (const Comm::ConnectionPointer &conn, int seconds, AsyncCall::Pointer &callback)
 
int commUnsetConnTimeout (const Comm::ConnectionPointer &conn)
 
int ignoreErrno (int)
 
void commCloseAllSockets (void)
 
void checkTimeouts (void)
 
AsyncCall::Pointer comm_add_close_handler (int fd, CLCB *, void *)
 
void comm_add_close_handler (int fd, AsyncCall::Pointer &)
 
void comm_remove_close_handler (int fd, CLCB *, void *)
 
void comm_remove_close_handler (int fd, AsyncCall::Pointer &)
 
int comm_udp_recvfrom (int fd, void *buf, size_t len, int flags, Ip::Address &from)
 
int comm_udp_recv (int fd, void *buf, size_t len, int flags)
 
ssize_t comm_udp_send (int s, const void *buf, size_t len, int flags)
 
bool comm_has_incomplete_write (int)
 
void commStartHalfClosedMonitor (int fd)
 Start waiting for a possibly half-closed connection to close. More...
 
bool commHasHalfClosedMonitor (int fd)
 checks whether we are waiting for possibly half-closed connection to close More...
 
void commMarkHalfClosed (int fd)
 
bool commIsHalfClosed (int fd)
 

Macro Definition Documentation

◆ comm_close

#define comm_close (   x)    (_comm_close((x), __FILE__, __LINE__))

Definition at line 28 of file comm.h.

Function Documentation

◆ _comm_close()

◆ checkTimeouts()

◆ comm_add_close_handler() [1/2]

void comm_add_close_handler ( int  fd,
AsyncCall::Pointer  
)

Definition at line 943 of file comm.cc.

References debugs, and fd_table.

◆ comm_add_close_handler() [2/2]

◆ comm_connect_addr()

◆ comm_exit()

void comm_exit ( void  )

Definition at line 1204 of file comm.cc.

References Comm::CallbackTableDestruct(), NULL, and TheHalfClosed.

Referenced by SquidShutdown().

◆ comm_has_incomplete_write()

bool comm_has_incomplete_write ( int  )

Definition at line 148 of file comm.cc.

References assert, COMMIO_FD_WRITECB, isOpen(), and NULL.

Referenced by PconnPool::push().

◆ comm_import_opened()

void comm_import_opened ( const Comm::ConnectionPointer ,
const char *  note,
struct addrinfo AI 
)

◆ comm_init()

◆ comm_iocallbackpending()

bool comm_iocallbackpending ( void  )

◆ comm_local_port()

unsigned short comm_local_port ( int  fd)

Queue a write. handler/handler_data are called when the write fully completes, on error, or on file descriptor close.

Definition at line 161 of file comm.cc.

References addrinfo::ai_addr, addrinfo::ai_addrlen, DBG_IMPORTANT, debugs, F(), fd_table, Ip::Address::FreeAddr(), Ip::Address::InitAddr(), MYNAME, NULL, Ip::Address::port(), Ip::Address::setIPv4(), and xstrerr().

Referenced by comm_udp_sendto(), Dns::Init(), Ftp::Server::listenForDataConnection(), and Ftp::Client::sendEprt().

◆ comm_open()

int comm_open ( int  sock_type,
int  proto,
Ip::Address addr,
int  flags,
const char *  note 
)

Create a socket. Default is blocking, stream (TCP) socket. IO_TYPE is OR of flags specified in comm.h. Defaults TOS

Definition at line 223 of file comm.cc.

References comm_openex().

Referenced by accessLogInit(), comm_open_uds(), comm_openex(), ipc_thread_1(), ipcCreate(), and logfile_mod_udp_open().

◆ comm_open_listener() [1/2]

◆ comm_open_listener() [2/2]

int comm_open_listener ( int  sock_type,
int  proto,
Ip::Address addr,
int  flags,
const char *  note 
)

Open a port specially bound for listening or sending through a specific port. This is a wrapper providing IPv4/IPv6 failover around comm_openex(). Please use for all listening sockets and bind() outbound sockets.

It will open a socket bound for:

  • IPv4 if IPv6 is disabled or address is IPv4-native.
  • IPv6 if address is IPv6-native
  • IPv6 dual-stack mode if able to open [::]

When an open performs failover it update the given address to feedback the new IPv4-only status of the socket. Further displays of the IP (in debugs or cachemgr) will occur in Native IPv4 format. A reconfigure is needed to reset the stored IP in most cases and attempt a port re-open.

Definition at line 246 of file comm.cc.

References COMM_DOBIND, and comm_openex().

◆ comm_open_uds()

◆ comm_openex()

◆ comm_remove_close_handler() [1/2]

void comm_remove_close_handler ( int  fd,
AsyncCall::Pointer  
)

Definition at line 987 of file comm.cc.

References assert, debugs, fd_table, isOpen(), and NULL.

◆ comm_remove_close_handler() [2/2]

◆ comm_reset_close()

void comm_reset_close ( const Comm::ConnectionPointer conn)

enable linger with time of 0 so that when the socket is closed, TCP generates a RESET

Definition at line 756 of file comm.cc.

References conn, DBG_CRITICAL, debugs, and xstrerr().

Referenced by ConnStateData::abortChunkedRequestBody(), clientProcessRequestFinished(), Adaptation::Icap::ServiceRep::putConnection(), and ConnStateData::setAuth().

◆ comm_udp_recv()

int comm_udp_recv ( int  fd,
void *  buf,
size_t  len,
int  flags 
)

Definition at line 135 of file comm.cc.

References buf, comm_udp_recvfrom(), and len.

Referenced by ipcCreate(), and IcmpSquid::Recv().

◆ comm_udp_recvfrom()

int comm_udp_recvfrom ( int  fd,
void *  buf,
size_t  len,
int  flags,
Ip::Address from 
)

◆ comm_udp_send()

ssize_t comm_udp_send ( int  s,
const void *  buf,
size_t  len,
int  flags 
)

Definition at line 142 of file comm.cc.

References buf, and len.

Referenced by ipcCreate(), IcmpSquid::SendEcho(), wccpAssignBuckets(), and wccpHereIam().

◆ comm_udp_sendto()

◆ commCallCloseHandlers()

void commCallCloseHandlers ( int  fd)

Definition at line 734 of file comm.cc.

References debugs, F(), fd_table, NULL, and ScheduleCallHere.

Referenced by _comm_close(), and examine_select().

◆ commCloseAllSockets()

void commCloseAllSockets ( void  )

Definition at line 1485 of file comm.cc.

References Biggest_FD, callback, debugs, F(), FD_SOCKET, fd_table, NULL, old_comm_reset_close(), and ScheduleCallHere.

Referenced by SquidShutdown().

◆ commHasHalfClosedMonitor()

bool commHasHalfClosedMonitor ( int  fd)

◆ commIsHalfClosed()

bool commIsHalfClosed ( int  fd)
inline

◆ commMarkHalfClosed()

void commMarkHalfClosed ( int  fd)
inline

Definition at line 97 of file comm.h.

References commStartHalfClosedMonitor().

Referenced by Server::doClientRead().

◆ commSetCloseOnExec()

void commSetCloseOnExec ( int  fd)

◆ commSetConnTimeout()

◆ commSetNonBlocking()

◆ commSetTcpKeepalive()

void commSetTcpKeepalive ( int  fd,
int  idle,
int  interval,
int  timeout 
)

Definition at line 1146 of file comm.cc.

References DBG_IMPORTANT, debugs, MYNAME, and xstrerr().

Referenced by Ftp::Server::AcceptCtrlConnection(), httpAccept(), and httpsAccept().

◆ commStartHalfClosedMonitor()

void commStartHalfClosedMonitor ( int  fd)

The read channel has closed and the caller does not expect more data but needs to detect connection aborts. The current detection method uses 0-length reads: We read until the error occurs or the writer closes the connection. If there is a read error, we close the connection.

Definition at line 1595 of file comm.cc.

References DescriptorSet::add(), assert, commHasHalfClosedMonitor(), commPlanHalfClosedCheck(), CodeContext::Current(), debugs, fd_table, HERE(), isOpen(), and TheHalfClosed.

Referenced by commMarkHalfClosed().

◆ commUnsetConnTimeout()

◆ commUnsetFdTimeout()

void commUnsetFdTimeout ( int  fd)

Definition at line 554 of file comm.cc.

References assert, debugs, F(), fd_table, HERE(), NULL, and Squid_MaxFD.

Referenced by _comm_close(), DiskdIOStrategy::init(), ipcCreate(), IcmpSquid::Open(), and unlinkdInit().

◆ commUnsetNonBlocking()

int commUnsetNonBlocking ( int  fd)

◆ ignoreErrno()

◆ old_comm_reset_close()

void old_comm_reset_close ( int  fd)

Definition at line 771 of file comm.cc.

References comm_close, DBG_CRITICAL, debugs, and xstrerr().

Referenced by commCloseAllSockets().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors