]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/UdsOp.h
4 * DEBUG: section 54 Interprocess Communication
8 #ifndef SQUID_IPC_ASYNCUDSOP_H
9 #define SQUID_IPC_ASYNCUDSOP_H
11 #include "SquidString.h"
12 #include "base/AsyncJob.h"
14 #include "comm/forward.h"
15 #include "ipc/TypedMsgHdr.h"
16 #include "ipc/FdNotes.h"
18 class CommTimeoutCbParams
;
24 /// code shared by unix-domain socket senders (e.g., UdsSender or Coordinator)
25 /// and receivers (e.g. Port or Coordinator)
26 class UdsOp
: public AsyncJob
29 UdsOp(const String
&pathAddr
);
33 struct sockaddr_un address
; ///< UDS address from path; treat as read-only
36 virtual void timedout() {} ///< called after setTimeout() if timed out
38 Comm::ConnectionPointer
&conn(); ///< creates if needed and returns raw UDS socket descriptor
40 /// call timedout() if no UDS messages in a given number of seconds
41 void setTimeout(int seconds
, const char *handlerName
);
42 void clearTimeout(); ///< remove previously set timeout, if any
44 void setOptions(int newOptions
); ///< changes socket options
47 /// Comm timeout callback; calls timedout()
48 void noteTimeout(const CommTimeoutCbParams
&p
);
51 int options
; ///< UDS options
52 Comm::ConnectionPointer conn_
; ///< UDS descriptor
55 UdsOp(const UdsOp
&); // not implemented
56 UdsOp
&operator= (const UdsOp
&); // not implemented
59 /// converts human-readable filename path into UDS address
60 extern struct sockaddr_un
PathToAddress(const String
&pathAddr
);
62 // XXX: move UdsSender code to UdsSender.{cc,h}
63 /// attempts to send an IPC message a few times, with a timeout
64 class UdsSender
: public UdsOp
67 UdsSender(const String
& pathAddr
, const TypedMsgHdr
& aMessage
);
70 virtual void start(); // UdsOp (AsyncJob) API
71 virtual bool doneAll() const; // UdsOp (AsyncJob) API
72 virtual void timedout(); // UdsOp API
75 void write(); ///< schedule writing
76 void wrote(const CommIoCbParams
& params
); ///< done writing or error
79 TypedMsgHdr message
; ///< what to send
80 int retries
; ///< how many times to try after a write error
81 int timeout
; ///< total time to send the message
82 bool writing
; ///< whether Comm started and did not finish writing
85 UdsSender(const UdsSender
&); // not implemented
86 UdsSender
& operator= (const UdsSender
&); // not implemented
88 CBDATA_CLASS2(UdsSender
);
91 void SendMessage(const String
& toAddress
, const TypedMsgHdr
& message
);
92 /// import socket fd from another strand into our Comm state
93 const Comm::ConnectionPointer
& ImportFdIntoComm(const Comm::ConnectionPointer
&conn
, int socktype
, int protocol
, FdNoteId noteId
);
97 #endif /* SQUID_IPC_ASYNCUDSOP_H */