proxygen
TransportFilter.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
11 
12 
13 
14 using namespace folly;
15 
16 namespace proxygen {
17 
18 // AsyncTransportWrapper::ReadCallback methods
19 void PassThroughTransportFilter::getReadBuffer(void** bufReturn,
20  size_t* lenReturn) {
21  callback_->getReadBuffer(bufReturn, lenReturn);
22 }
23 
24 void PassThroughTransportFilter::readDataAvailable(size_t len) noexcept {
25  callback_->readDataAvailable(len);
26 }
27 
28 void PassThroughTransportFilter::readEOF() noexcept {
29  callback_->readEOF();
30  destroy();
31 }
32 
33 void PassThroughTransportFilter::readErr(
34  const AsyncSocketException& ex) noexcept {
35  callback_->readErr(ex);
36  destroy();
37 }
38 
39 // AsyncTransport methods
40 
41 void PassThroughTransportFilter::setReadCB(
43  // Important! The filter must call setCallbackInternal in its base class and
44  // it must not forward the call.
45  setCallbackInternal(callback);
46 }
47 
49 PassThroughTransportFilter::getReadCallback() const {
50  return call_->getReadCallback();
51 }
52 
55  const void* buf, size_t bytes, WriteFlags flags) {
56  call_->write(callback, buf, bytes, flags);
57 }
58 
59 void PassThroughTransportFilter::writev(
60  AsyncTransportWrapper::WriteCallback* callback, const iovec* vec, size_t count,
61  WriteFlags flags) {
62  call_->writev(callback, vec, count, flags);
63 }
64 
65 void PassThroughTransportFilter::writeChain(
67  std::unique_ptr<folly::IOBuf>&& iob, WriteFlags flags) {
68  call_->writeChain(callback, std::move(iob), flags);
69 }
70 
72  call_->close();
73  // wait for readEOF() to call destroy()
74 }
75 
76 void PassThroughTransportFilter::closeNow() {
77  call_->closeNow();
78  // wait for readEOF() to call destroy()
79 }
80 
81 void PassThroughTransportFilter::closeWithReset() {
82  call_->closeWithReset();
83  // wait for readEOF() to call destroy()
84 }
85 
86 void PassThroughTransportFilter::shutdownWrite() {
87  call_->shutdownWrite();
88 }
89 
90 void PassThroughTransportFilter::shutdownWriteNow() {
91  call_->shutdownWriteNow();
92 }
93 
94 bool PassThroughTransportFilter::good() const {
95  return call_->good();
96 }
97 
98 bool PassThroughTransportFilter::readable() const {
99  return call_->readable();
100 }
101 
102 bool PassThroughTransportFilter::connecting() const {
103  return call_->connecting();
104 }
105 
107  return call_->error();
108 }
109 
110 void PassThroughTransportFilter::attachEventBase(EventBase* eventBase) {
111  call_->attachEventBase(eventBase);
112 }
113 
114 void PassThroughTransportFilter::detachEventBase() {
115  call_->detachEventBase();
116 }
117 
118 bool PassThroughTransportFilter::isDetachable() const {
119  return call_->isDetachable();
120 }
121 
123  return call_->getEventBase();
124 }
125 
126 void PassThroughTransportFilter::setSendTimeout(uint32_t milliseconds) {
127  call_->setSendTimeout(milliseconds);
128 }
129 
130 uint32_t PassThroughTransportFilter::getSendTimeout() const {
131  return call_->getSendTimeout();
132 }
133 
134 void PassThroughTransportFilter::getLocalAddress(
135  folly::SocketAddress* address) const {
136  call_->getLocalAddress(address);
137 }
138 
139 void PassThroughTransportFilter::getPeerAddress(
140  folly::SocketAddress* address) const {
141  call_->getPeerAddress(address);
142 }
143 
144 void PassThroughTransportFilter::setEorTracking(bool track) {
145  call_->setEorTracking(track);
146 }
147 
148 size_t PassThroughTransportFilter::getAppBytesWritten() const {
149  return call_->getAppBytesWritten();
150 }
151 size_t PassThroughTransportFilter::getRawBytesWritten() const {
152  return call_->getRawBytesWritten();
153 }
154 size_t PassThroughTransportFilter::getAppBytesReceived() const {
155  return call_->getAppBytesReceived();
156 }
157 size_t PassThroughTransportFilter::getRawBytesReceived() const {
158  //new PassThroughTransportFilter();
159  return call_->getRawBytesReceived();
160 }
161 
162 }
flags
Definition: http_parser.h:127
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
EventBase * getEventBase()
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
requires E e noexcept(noexcept(s.error(std::move(e))))
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
static void destroy()
EventBase * getEventBase() override
Implements the IOExecutor interface.
Definition: EventBase.cpp:776
Definition: Traits.h:588
int * count
folly::Function< void()> callback_
int close(NetworkSocket s)
Definition: NetOps.cpp:90