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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors