]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/php/lib/Protocol/TBinaryProtocolAccelerated.php
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / php / lib / Protocol / TBinaryProtocolAccelerated.php
CommitLineData
f67539c2
TL
1<?php
2/*
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 * @package thrift.protocol
21 */
22
23namespace Thrift\Protocol;
24
25use Thrift\Transport\TBufferedTransport;
26
27/**
28 * Accelerated binary protocol: used in conjunction with the thrift_protocol
29 * extension for faster deserialization
30 */
31class TBinaryProtocolAccelerated extends TBinaryProtocol
32{
33 public function __construct($trans, $strictRead = false, $strictWrite = true)
34 {
35 // If the transport doesn't implement putBack, wrap it in a
36 // TBufferedTransport (which does)
37
38 // NOTE (t.heintz): This is very evil to do, because the TBufferedTransport may swallow bytes, which
39 // are then never written to the underlying transport. This happens precisely when a number of bytes
40 // less than the max buffer size (512 by default) is written to the transport and then flush() is NOT
41 // called. In that case the data stays in the writeBuffer of the transport, from where it can never be
42 // accessed again (for example through read()).
43 //
44 // Since the caller of this method does not know about the wrapping transport, this creates bugs which
45 // are very difficult to find. Hence the wrapping of a transport in a buffer should be left to the
46 // calling code. An interface could used to mandate the presence of the putBack() method in the transport.
47 //
48 // I am leaving this code in nonetheless, because there may be applications depending on this behavior.
49 //
50 // @see THRIFT-1579
51
52 if (!method_exists($trans, 'putBack')) {
53 $trans = new TBufferedTransport($trans);
54 }
55 parent::__construct($trans, $strictRead, $strictWrite);
56 }
57
58 public function isStrictRead()
59 {
60 return $this->strictRead_;
61 }
62
63 public function isStrictWrite()
64 {
65 return $this->strictWrite_;
66 }
67}