Server.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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 "log/forward.h"
21#include "Pipeline.h"
22#include "sbuf/SBuf.h"
23#include "servers/forward.h"
24
29class Server : virtual public AsyncJob, public BodyProducer
30{
31public:
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 != nullptr;}
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 != nullptr;}
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.
92public:
93
96
97 // Client TCP connection details from comm layer.
99
106
109
112
114
117
118protected:
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
#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:18
Definition: MemBuf.h:24
Definition: SBuf.h:94
Definition: Server.h:30
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:84
virtual ~Server()
Definition: Server.h:33
Pipeline pipeline
set of requests waiting to be serviced
Definition: Server.h:116
virtual bool doneAll() const
whether positive goal has been reached
Definition: Server.cc:37
AsyncCall::Pointer reader
set when we are reading
Definition: Server.h:125
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:77
AnyP::ProtocolVersion transferProtocol
Definition: Server.h:105
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:67
Comm::ConnectionPointer clientConnection
Definition: Server.h:98
void clientWriteDone(const CommIoCbParams &io)
Definition: Server.cc:193
bool receivedFirstByte_
true if at least one byte received on this connection
Definition: Server.h:113
AnyP::PortCfgPointer port
Squid listening port details where this connection arrived.
Definition: Server.h:108
virtual void start()
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:111
bool writing() const
whether Comm::Write() is scheduled
Definition: Server.h:87
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)
AsyncCall::Pointer writer
set when we are writing
Definition: Server.h:126
bool reading() const
whether Comm::Read() is scheduled
Definition: Server.h:58
virtual void swanSong()
Definition: Server.cc:51
void write(MemBuf *mb)
schedule some data for a Comm::Write()
Definition: Server.h:70
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