Server.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 "Pipeline.h"
21 #include "sbuf/SBuf.h"
22 #include "servers/forward.h"
23 
28 class Server : virtual public AsyncJob, public BodyProducer
29 {
30 public:
31  Server(const MasterXactionPointer &xact);
32  virtual ~Server() {}
33 
34  /* AsyncJob API */
35  virtual void start();
36  virtual bool doneAll() const;
37  virtual void swanSong();
38 
40  virtual bool connFinishedWithConn(int size) = 0;
41 
43  void readSomeData();
44 
51  virtual bool handleReadData() = 0;
52 
54  virtual void afterClientRead() = 0;
55 
57  bool reading() const {return reader != NULL;}
58 
60  void stopReading();
61 
63  virtual void receivedFirstByte() = 0;
64 
66  virtual void writeSomeData() {}
67 
69  void write(MemBuf *mb) {
71  writer = JobCallback(33, 5, Dialer, this, Server::clientWriteDone);
73  }
74 
76  void write(char *buf, int len) {
78  writer = JobCallback(33, 5, Dialer, this, Server::clientWriteDone);
79  Comm::Write(clientConnection, buf, len, writer, nullptr);
80  }
81 
83  virtual void afterClientWrite(size_t) {}
84 
86  bool writing() const {return writer != NULL;}
87 
88 // XXX: should be 'protected:' for child access only,
89 // but all sorts of code likes to play directly
90 // with the I/O buffers and socket.
91 public:
92 
95 
96  // Client TCP connection details from comm layer.
98 
105 
108 
111 
113 
116 
117 protected:
118  void doClientRead(const CommIoCbParams &io);
119  void clientWriteDone(const CommIoCbParams &io);
120 
122  virtual void checkLogging() = 0;
123 
126 };
127 
128 #endif /* SQUID_SERVERS_SERVER_H */
129 
#define JobCallback(dbgSection, dbgLevel, Dialer, job, method)
Convenience macro to create a Dialer-based job callback.
Definition: AsyncJobCalls.h:68
Server(const MasterXactionPointer &xact)
Definition: Server.cc:24
Definition: Server.h:28
Definition: SBuf.h:87
void maybeMakeSpaceAvailable()
grows the available read buffer space (if possible)
Definition: Server.cc:70
virtual void swanSong()
Definition: Server.cc:47
virtual void afterClientRead()=0
processing to be done after a Comm::Read()
void doClientRead(const CommIoCbParams &io)
Definition: Server.cc:102
void stopReading()
cancels Comm::Read() if it is scheduled
Definition: Server.cc:56
void readSomeData()
maybe grow the inBuf and schedule Comm::Read()
Definition: Server.cc:85
virtual ~Server()
Definition: Server.h:32
AnyP::ProtocolVersion transferProtocol
Definition: Server.h:104
AsyncCall::Pointer reader
set when we are reading
Definition: Server.h:124
virtual void checkLogging()=0
Log the current [attempt at] transaction if nobody else will.
bool receivedFirstByte_
true if at least one byte received on this connection
Definition: Server.h:112
virtual void afterClientWrite(size_t)
processing to sync state after a Comm::Write()
Definition: Server.h:83
virtual bool handleReadData()=0
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
void const char * buf
Definition: stub_helper.cc:16
virtual void receivedFirstByte()=0
Update flags and timeout after the first byte received.
virtual bool doneAll() const
whether positive goal has been reached
Definition: Server.cc:33
void clientWriteDone(const CommIoCbParams &io)
Definition: Server.cc:186
bool writing() const
whether Comm::Write() is scheduled
Definition: Server.h:86
SBuf inBuf
read I/O buffer for the client connection
Definition: Server.h:110
Definition: MemBuf.h:23
Comm::ConnectionPointer clientConnection
Definition: Server.h:97
virtual void start()
called by AsyncStart; do not call directly
Definition: Server.cc:41
virtual void writeSomeData()
maybe find some data to send and schedule a Comm::Write()
Definition: Server.h:66
void write(char *buf, int len)
schedule some data for a Comm::Write()
Definition: Server.h:76
AsyncCall::Pointer writer
set when we are writing
Definition: Server.h:125
AnyP::PortCfgPointer port
Squid listening port details where this connection arrived.
Definition: Server.h:107
virtual bool connFinishedWithConn(int size)=0
??
#define NULL
Definition: types.h:166
int size
Definition: ModDevPoll.cc:77
bool reading() const
whether Comm::Read() is scheduled
Definition: Server.h:57
void Write(const Comm::ConnectionPointer &conn, const char *buf, int size, AsyncCall::Pointer &callback, FREE *free_func)
Definition: Write.cc:35
void write(MemBuf *mb)
schedule some data for a Comm::Write()
Definition: Server.h:69
Pipeline pipeline
set of requests waiting to be serviced
Definition: Server.h:115

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors