UdsOp.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2020 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 /* DEBUG: section 54 Interprocess Communication */
10 
11 #ifndef SQUID_IPC_ASYNCUDSOP_H
12 #define SQUID_IPC_ASYNCUDSOP_H
13 
14 #include "base/AsyncJob.h"
15 #include "base/forward.h"
16 #include "cbdata.h"
17 #include "comm/forward.h"
18 #include "ipc/FdNotes.h"
19 #include "ipc/TypedMsgHdr.h"
20 #include "SquidString.h"
21 
23 class CommIoCbParams;
24 
25 namespace Ipc
26 {
27 
30 class UdsOp: public AsyncJob
31 {
32 public:
33  UdsOp(const String &pathAddr);
34  virtual ~UdsOp();
35 
36 public:
38 
39 protected:
40  virtual void timedout() {}
41 
43 
45  void setTimeout(int seconds, const char *handlerName);
46  void clearTimeout();
47 
48  void setOptions(int newOptions);
49 
50 private:
52  void noteTimeout(const CommTimeoutCbParams &p);
53 
54 private:
55  int options;
57 
58 private:
59  UdsOp(const UdsOp &); // not implemented
60  UdsOp &operator= (const UdsOp &); // not implemented
61 };
62 
64 struct sockaddr_un PathToAddress(const String &pathAddr);
65 
66 // XXX: move UdsSender code to UdsSender.{cc,h}
68 class UdsSender: public UdsOp
69 {
71 
72 public:
73  UdsSender(const String& pathAddr, const TypedMsgHdr& aMessage);
74 
76 
77 protected:
78  virtual void swanSong(); // UdsOp (AsyncJob) API
79  virtual void start(); // UdsOp (AsyncJob) API
80  virtual bool doneAll() const; // UdsOp (AsyncJob) API
81  virtual void timedout(); // UdsOp API
82 
83 private:
84  void startSleep();
85  void cancelSleep();
86  static void DelayedRetry(void *data);
87  void delayedRetry();
88 
89  void write();
90  void wrote(const CommIoCbParams& params);
91 
92 private:
94  int retries;
95  int timeout;
96  bool sleeping;
97  bool writing;
98 
99 private:
100  UdsSender(const UdsSender&); // not implemented
101  UdsSender& operator= (const UdsSender&); // not implemented
102 };
103 
104 void SendMessage(const String& toAddress, const TypedMsgHdr& message);
106 const Comm::ConnectionPointer & ImportFdIntoComm(const Comm::ConnectionPointer &conn, int socktype, int protocol, FdNoteId noteId);
107 
108 }
109 
110 #endif /* SQUID_IPC_ASYNCUDSOP_H */
111 
int options
UDS options.
Definition: UdsOp.h:55
CodeContextPointer codeContext
Definition: UdsOp.h:75
void write()
schedule writing
Definition: UdsOp.cc:118
void delayedRetry()
make another sending attempt after a pause
Definition: UdsOp.cc:173
struct sockaddr_un address
UDS address from path; treat as read-only.
Definition: UdsOp.h:37
bool sleeping
whether we are waiting to retry a failed write
Definition: UdsOp.h:96
void setOptions(int newOptions)
changes socket options
Definition: UdsOp.cc:35
bool writing
whether Comm started and did not finish writing
Definition: UdsOp.h:97
UdsOp & operator=(const UdsOp &)
virtual void timedout()
Definition: UdsOp.cc:182
virtual void start()
called by AsyncStart; do not call directly
Definition: UdsOp.cc:105
virtual bool doneAll() const
whether positive goal has been reached
Definition: UdsOp.cc:113
int retries
how many times to try after a write error
Definition: UdsOp.h:94
void noteTimeout(const CommTimeoutCbParams &p)
Comm timeout callback; calls timedout()
Definition: UdsOp.cc:67
attempts to send an IPC message a few times, with a timeout
Definition: UdsOp.h:68
TypedMsgHdr message
what to send
Definition: UdsOp.h:93
void wrote(const CommIoCbParams &params)
done writing or error
Definition: UdsOp.cc:128
void setTimeout(int seconds, const char *handlerName)
call timedout() if no UDS messages in a given number of seconds
Definition: UdsOp.cc:54
FdNoteId
We cannot send char* FD notes to other processes. Pass int IDs and convert.
Definition: FdNotes.h:20
void const char HLPCB void * data
Definition: stub_helper.cc:16
void SendMessage(const String &toAddress, const TypedMsgHdr &message)
Definition: UdsOp.cc:188
int conn
the current server connection FD
Definition: Transport.cc:26
void startSleep()
pause for a while before resending the message
Definition: UdsOp.cc:140
virtual ~UdsOp()
Definition: UdsOp.cc:27
void clearTimeout()
remove previously set timeout, if any
Definition: UdsOp.cc:62
UdsSender(const String &pathAddr, const TypedMsgHdr &aMessage)
Definition: UdsOp.cc:84
virtual void swanSong()
Definition: UdsOp.cc:96
void cancelSleep()
stop sleeping (or do nothing if we were not)
Definition: UdsOp.cc:150
Comm::ConnectionPointer conn_
UDS descriptor.
Definition: UdsOp.h:56
UdsSender & operator=(const UdsSender &)
CBDATA_CLASS(UdsSender)
struct msghdr with a known type, fixed-size I/O and control buffers
Definition: TypedMsgHdr.h:31
const Comm::ConnectionPointer & ImportFdIntoComm(const Comm::ConnectionPointer &conn, int socktype, int protocol, FdNoteId noteId)
import socket fd from another strand into our Comm state
Definition: UdsOp.cc:194
struct sockaddr_un PathToAddress(const String &pathAddr)
converts human-readable filename path into UDS address
Definition: UdsOp.cc:73
int timeout
total time to send the message
Definition: UdsOp.h:95
UdsOp(const String &pathAddr)
Definition: UdsOp.cc:19
static void DelayedRetry(void *data)
legacy wrapper for Ipc::UdsSender::delayedRetry()
Definition: UdsOp.cc:160
Definition: IpcIoFile.h:23
Comm::ConnectionPointer & conn()
creates if needed and returns raw UDS socket descriptor
Definition: UdsOp.cc:41

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors