Server.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 /* DEBUG: section 33 Client-side Routines */
10 
11 #ifndef SQUID_SERVERS_SERVER_H
12 #define SQUID_SERVERS_SERVER_H
13 
14 #include "anyp/forward.h"
15 #include "anyp/ProtocolVersion.h"
16 #include "base/AsyncJob.h"
17 #include "BodyPipe.h"
18 #include "comm/Write.h"
19 #include "CommCalls.h"
20 #include "log/forward.h"
21 #include "Pipeline.h"
22 #include "sbuf/SBuf.h"
23 #include "servers/forward.h"
24 
29 class Server : virtual public AsyncJob, public BodyProducer
30 {
31 public:
32  Server(const MasterXactionPointer &xact);
33  virtual ~Server() {}
34 
35  /* AsyncJob API */
36  virtual void start();
37  virtual bool doneAll() const;
38  virtual void swanSong();
39 
41  virtual bool shouldCloseOnEof() const = 0;
42 
44  void readSomeData();
45 
52  virtual bool handleReadData() = 0;
53 
55  virtual void afterClientRead() = 0;
56 
58  bool reading() const {return reader != NULL;}
59 
61  void stopReading();
62 
64  virtual void receivedFirstByte() = 0;
65 
67  virtual void writeSomeData() {}
68 
70  void write(MemBuf *mb) {
72  writer = JobCallback(33, 5, Dialer, this, Server::clientWriteDone);
74  }
75 
77  void write(char *buf, int len) {
79  writer = JobCallback(33, 5, Dialer, this, Server::clientWriteDone);
80  Comm::Write(clientConnection, buf, len, writer, nullptr);
81  }
82 
84  virtual void afterClientWrite(size_t) {}
85 
87  bool writing() const {return writer != NULL;}
88 
89 // XXX: should be 'protected:' for child access only,
90 // but all sorts of code likes to play directly
91 // with the I/O buffers and socket.
92 public:
93 
96 
97  // Client TCP connection details from comm layer.
99 
106 
109 
112 
114 
117 
118 protected:
120  virtual void terminateAll(const Error &, const LogTagsErrors &) = 0;
121 
122  void doClientRead(const CommIoCbParams &io);
123  void clientWriteDone(const CommIoCbParams &io);
124 
127 };
128 
129 #endif /* SQUID_SERVERS_SERVER_H */
130 
AnyP::ProtocolVersion transferProtocol
Definition: Server.h:105
virtual bool handleReadData()=0
SBuf inBuf
read I/O buffer for the client connection
Definition: Server.h:111
AsyncCall::Pointer reader
set when we are reading
Definition: Server.h:125
Definition: SBuf.h:87
virtual void receivedFirstByte()=0
Update flags and timeout after the first byte received.
virtual bool shouldCloseOnEof() const =0
whether to stop serving our client after reading EOF on its connection
Definition: Server.h:30
void write(MemBuf *mb)
schedule some data for a Comm::Write()
Definition: Server.h:70
void maybeMakeSpaceAvailable()
grows the available read buffer space (if possible)
Definition: Server.cc:74
void write(char *buf, int len)
schedule some data for a Comm::Write()
Definition: Server.h:77
virtual void terminateAll(const Error &, const LogTagsErrors &)=0
abort any pending transactions and prevent new ones (by closing)
Pipeline pipeline
set of requests waiting to be serviced
Definition: Server.h:116
virtual void afterClientWrite(size_t)
processing to sync state after a Comm::Write()
Definition: Server.h:84
a transaction problem
Definition: Error.h:18
virtual void swanSong()
Definition: Server.cc:51
#define NULL
Definition: types.h:166
Definition: MemBuf.h:24
virtual void start()
called by AsyncStart; do not call directly
Definition: Server.cc:45
virtual bool doneAll() const
whether positive goal has been reached
Definition: Server.cc:37
void readSomeData()
maybe grow the inBuf and schedule Comm::Read()
Definition: Server.cc:89
bool reading() const
whether Comm::Read() is scheduled
Definition: Server.h:58
#define JobCallback(dbgSection, dbgLevel, Dialer, job, method)
Convenience macro to create a Dialer-based job callback.
Definition: AsyncJobCalls.h:69
void Write(const Comm::ConnectionPointer &conn, const char *buf, int size, AsyncCall::Pointer &callback, FREE *free_func)
Definition: Write.cc:34
Comm::ConnectionPointer clientConnection
Definition: Server.h:98
bool writing() const
whether Comm::Write() is scheduled
Definition: Server.h:87
void doClientRead(const CommIoCbParams &io)
Definition: Server.cc:106
void stopReading()
cancels Comm::Read() if it is scheduled
Definition: Server.cc:60
virtual void afterClientRead()=0
processing to be done after a Comm::Read()
AnyP::PortCfgPointer port
Squid listening port details where this connection arrived.
Definition: Server.h:108
Server(const MasterXactionPointer &xact)
Definition: Server.cc:26
AsyncCall::Pointer writer
set when we are writing
Definition: Server.h:126
virtual ~Server()
Definition: Server.h:33
bool receivedFirstByte_
true if at least one byte received on this connection
Definition: Server.h:113
void clientWriteDone(const CommIoCbParams &io)
Definition: Server.cc:193
virtual void writeSomeData()
maybe find some data to send and schedule a Comm::Write()
Definition: Server.h:67

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors