Merge lp:~mzanetti/reminders-app/update-thrift into lp:reminders-app
- update-thrift
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Riccardo Padovani |
Approved revision: | 351 |
Merged at revision: | 352 |
Proposed branch: | lp:~mzanetti/reminders-app/update-thrift |
Merge into: | lp:reminders-app |
Diff against target: |
13599 lines (+6935/-1852) 133 files modified
3rdParty/libthrift/README (+0/-77) 3rdParty/libthrift/TApplicationException.h (+17/-8) 3rdParty/libthrift/TDispatchProcessor.h (+142/-0) 3rdParty/libthrift/TLogging.h (+5/-11) 3rdParty/libthrift/TReflectionLocal.h (+1/-1) 3rdParty/libthrift/TToString.h (+89/-0) 3rdParty/libthrift/Thrift.cpp (+32/-0) 3rdParty/libthrift/Thrift.h (+9/-16) 3rdParty/libthrift/VirtualProfiling.cpp (+2/-2) 3rdParty/libthrift/async/TAsyncBufferProcessor.h (+3/-3) 3rdParty/libthrift/async/TAsyncChannel.cpp (+3/-3) 3rdParty/libthrift/async/TAsyncChannel.h (+2/-2) 3rdParty/libthrift/async/TAsyncDispatchProcessor.h (+149/-0) 3rdParty/libthrift/async/TAsyncProcessor.h (+3/-3) 3rdParty/libthrift/async/TAsyncProtocolProcessor.cpp (+5/-5) 3rdParty/libthrift/async/TAsyncProtocolProcessor.h (+5/-5) 3rdParty/libthrift/async/TEvhttpClientChannel.cpp (+4/-4) 3rdParty/libthrift/async/TEvhttpClientChannel.h (+1/-1) 3rdParty/libthrift/async/TEvhttpServer.cpp (+6/-6) 3rdParty/libthrift/concurrency/BoostMonitor.cpp (+47/-34) 3rdParty/libthrift/concurrency/BoostMutex.cpp (+10/-11) 3rdParty/libthrift/concurrency/BoostThreadFactory.cpp (+24/-22) 3rdParty/libthrift/concurrency/BoostThreadFactory.h (+1/-1) 3rdParty/libthrift/concurrency/FunctionRunner.h (+34/-15) 3rdParty/libthrift/concurrency/Monitor.cpp (+24/-11) 3rdParty/libthrift/concurrency/Monitor.h (+13/-7) 3rdParty/libthrift/concurrency/Mutex.cpp (+53/-63) 3rdParty/libthrift/concurrency/Mutex.h (+19/-9) 3rdParty/libthrift/concurrency/PlatformThreadFactory.h (+11/-6) 3rdParty/libthrift/concurrency/PosixThreadFactory.cpp (+5/-12) 3rdParty/libthrift/concurrency/PosixThreadFactory.h (+1/-1) 3rdParty/libthrift/concurrency/StdMonitor.cpp (+217/-0) 3rdParty/libthrift/concurrency/StdMutex.cpp (+55/-0) 3rdParty/libthrift/concurrency/StdThreadFactory.cpp (+175/-0) 3rdParty/libthrift/concurrency/StdThreadFactory.h (+72/-0) 3rdParty/libthrift/concurrency/Thread.h (+17/-11) 3rdParty/libthrift/concurrency/ThreadManager.cpp (+10/-14) 3rdParty/libthrift/concurrency/ThreadManager.h (+3/-4) 3rdParty/libthrift/concurrency/TimerManager.cpp (+40/-19) 3rdParty/libthrift/concurrency/TimerManager.h (+12/-4) 3rdParty/libthrift/concurrency/Util.cpp (+9/-22) 3rdParty/libthrift/concurrency/Util.h (+18/-16) 3rdParty/libthrift/config.h (+1/-1) 3rdParty/libthrift/cxxfunctional.h (+126/-0) 3rdParty/libthrift/jni/Android.mk (+0/-98) 3rdParty/libthrift/jni/Application.mk (+0/-7) 3rdParty/libthrift/jni/shared.mk (+0/-17) 3rdParty/libthrift/jni/static.mk (+0/-17) 3rdParty/libthrift/processor/PeekProcessor.cpp (+2/-2) 3rdParty/libthrift/processor/PeekProcessor.h (+4/-4) 3rdParty/libthrift/processor/StatsProcessor.h (+3/-3) 3rdParty/libthrift/processor/TMultiplexedProcessor.h (+218/-0) 3rdParty/libthrift/protocol/TBase64Utils.cpp (+23/-23) 3rdParty/libthrift/protocol/TBinaryProtocol.h (+9/-6) 3rdParty/libthrift/protocol/TBinaryProtocol.tcc (+12/-16) 3rdParty/libthrift/protocol/TCompactProtocol.h (+7/-6) 3rdParty/libthrift/protocol/TCompactProtocol.tcc (+37/-24) 3rdParty/libthrift/protocol/TDebugProtocol.cpp (+16/-6) 3rdParty/libthrift/protocol/TDebugProtocol.h (+2/-2) 3rdParty/libthrift/protocol/TDenseProtocol.cpp (+8/-6) 3rdParty/libthrift/protocol/TDenseProtocol.h (+1/-1) 3rdParty/libthrift/protocol/TJSONProtocol.cpp (+33/-15) 3rdParty/libthrift/protocol/TJSONProtocol.h (+2/-2) 3rdParty/libthrift/protocol/TMultiplexedProtocol.cpp (+47/-0) 3rdParty/libthrift/protocol/TMultiplexedProtocol.h (+103/-0) 3rdParty/libthrift/protocol/TProtocol.h (+29/-11) 3rdParty/libthrift/protocol/TProtocolDecorator.h (+133/-0) 3rdParty/libthrift/protocol/TProtocolException.h (+1/-0) 3rdParty/libthrift/protocol/TProtocolTap.h (+1/-1) 3rdParty/libthrift/qt/TQIODeviceTransport.cpp (+179/-0) 3rdParty/libthrift/qt/TQIODeviceTransport.h (+64/-0) 3rdParty/libthrift/qt/TQTcpServer.cpp (+157/-0) 3rdParty/libthrift/qt/TQTcpServer.h (+72/-0) 3rdParty/libthrift/qt/moc_TQTcpServer.cpp (+99/-0) 3rdParty/libthrift/server/TNonblockingServer.cpp (+564/-261) 3rdParty/libthrift/server/TNonblockingServer.h (+282/-100) 3rdParty/libthrift/server/TServer.cpp (+4/-4) 3rdParty/libthrift/server/TServer.h (+8/-7) 3rdParty/libthrift/server/TSimpleServer.cpp (+15/-15) 3rdParty/libthrift/server/TSimpleServer.h (+2/-2) 3rdParty/libthrift/server/TThreadPoolServer.cpp (+28/-22) 3rdParty/libthrift/server/TThreadPoolServer.h (+18/-8) 3rdParty/libthrift/server/TThreadedServer.cpp (+16/-16) 3rdParty/libthrift/server/TThreadedServer.h (+6/-6) 3rdParty/libthrift/thrift-config.h (+24/-0) 3rdParty/libthrift/transport/PlatformSocket.h (+120/-0) 3rdParty/libthrift/transport/TBufferTransports.cpp (+38/-15) 3rdParty/libthrift/transport/TBufferTransports.h (+25/-6) 3rdParty/libthrift/transport/TFDTransport.cpp (+14/-9) 3rdParty/libthrift/transport/TFDTransport.h (+8/-3) 3rdParty/libthrift/transport/TFileTransport.cpp (+79/-141) 3rdParty/libthrift/transport/TFileTransport.h (+20/-24) 3rdParty/libthrift/transport/THttpClient.cpp (+5/-2) 3rdParty/libthrift/transport/THttpServer.cpp (+34/-2) 3rdParty/libthrift/transport/THttpTransport.cpp (+13/-1) 3rdParty/libthrift/transport/THttpTransport.h (+4/-1) 3rdParty/libthrift/transport/TPipe.cpp (+413/-0) 3rdParty/libthrift/transport/TPipe.h (+104/-0) 3rdParty/libthrift/transport/TPipeServer.cpp (+450/-0) 3rdParty/libthrift/transport/TPipeServer.h (+99/-0) 3rdParty/libthrift/transport/TSSLServerSocket.cpp (+6/-8) 3rdParty/libthrift/transport/TSSLServerSocket.h (+3/-3) 3rdParty/libthrift/transport/TSSLSocket.cpp (+150/-116) 3rdParty/libthrift/transport/TSSLSocket.h (+39/-9) 3rdParty/libthrift/transport/TServerSocket.cpp (+159/-116) 3rdParty/libthrift/transport/TServerSocket.h (+31/-6) 3rdParty/libthrift/transport/TServerTransport.h (+3/-3) 3rdParty/libthrift/transport/TShortReadTransport.h (+2/-2) 3rdParty/libthrift/transport/TSimpleFileTransport.cpp (+4/-5) 3rdParty/libthrift/transport/TSimpleFileTransport.h (+1/-1) 3rdParty/libthrift/transport/TSocket.cpp (+174/-149) 3rdParty/libthrift/transport/TSocket.h (+27/-14) 3rdParty/libthrift/transport/TSocketPool.cpp (+10/-12) 3rdParty/libthrift/transport/TSocketPool.h (+4/-4) 3rdParty/libthrift/transport/TTransport.h (+12/-0) 3rdParty/libthrift/transport/TTransportException.cpp (+20/-4) 3rdParty/libthrift/transport/TTransportException.h (+1/-17) 3rdParty/libthrift/transport/TZlibTransport.cpp (+2/-3) 3rdParty/libthrift/transport/TZlibTransport.h (+9/-36) 3rdParty/libthrift/windows/GetTimeOfDay.cpp (+112/-0) 3rdParty/libthrift/windows/GetTimeOfDay.h (+43/-0) 3rdParty/libthrift/windows/Operators.h (+40/-0) 3rdParty/libthrift/windows/OverlappedSubmissionThread.cpp (+156/-0) 3rdParty/libthrift/windows/OverlappedSubmissionThread.h (+129/-0) 3rdParty/libthrift/windows/SocketPair.cpp (+102/-0) 3rdParty/libthrift/windows/SocketPair.h (+37/-0) 3rdParty/libthrift/windows/Sync.h (+102/-0) 3rdParty/libthrift/windows/TWinsockSingleton.cpp (+73/-0) 3rdParty/libthrift/windows/TWinsockSingleton.h (+88/-0) 3rdParty/libthrift/windows/WinFcntl.cpp (+110/-0) 3rdParty/libthrift/windows/WinFcntl.h (+56/-0) 3rdParty/libthrift/windows/config.h (+98/-0) src/libqtevernote/evernoteconnection.cpp (+2/-2) |
To merge this branch: | bzr merge lp:~mzanetti/reminders-app/update-thrift |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Riccardo Padovani | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Review via email: mp+251027@code.launchpad.net |
Commit message
update libthrift to 0.9.2
Description of the change
I hoped this would increase the connection stability, but I'm afraid it doesn't. In any case, this is probably still good to have at it seems to have some security related fixes too.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:351
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Riccardo Padovani (rpadovani) wrote : | # |
I see you dropped the edit you did in Washington to 3rdParty/
Is something you want or you just forgot about it?
Michael Zanetti (mzanetti) wrote : | # |
> I see you dropped the edit you did in Washington to
> 3rdParty/
>
> Is something you want or you just forgot about it?
Yeah, I think that's not needed any more. I couldn't reproduce the issue any more.
Riccardo Padovani (rpadovani) wrote : | # |
Then looks good :-)
Preview Diff
1 | === removed file '3rdParty/libthrift/README' |
2 | --- 3rdParty/libthrift/README 2013-11-21 23:30:15 +0000 |
3 | +++ 3rdParty/libthrift/README 1970-01-01 00:00:00 +0000 |
4 | @@ -1,77 +0,0 @@ |
5 | -Apache Thrift |
6 | - |
7 | -Last Modified: 2012-May-30 |
8 | - |
9 | -License |
10 | -======= |
11 | - |
12 | -Licensed to the Apache Software Foundation (ASF) under one |
13 | -or more contributor license agreements. See the NOTICE file |
14 | -distributed with this work for additional information |
15 | -regarding copyright ownership. The ASF licenses this file |
16 | -to you under the Apache License, Version 2.0 (the |
17 | -"License"); you may not use this file except in compliance |
18 | -with the License. You may obtain a copy of the License at |
19 | - |
20 | - http://www.apache.org/licenses/LICENSE-2.0 |
21 | - |
22 | -Unless required by applicable law or agreed to in writing, |
23 | -software distributed under the License is distributed on an |
24 | -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
25 | -KIND, either express or implied. See the License for the |
26 | -specific language governing permissions and limitations |
27 | -under the License. |
28 | - |
29 | -Introduction |
30 | -============ |
31 | - |
32 | -Thrift is a lightweight, language-independent software stack with an |
33 | -associated code generation mechanism for RPC. Thrift provides clean |
34 | -abstractions for data transport, data serialization, and application |
35 | -level processing. The code generation system takes a simple definition |
36 | -language as its input and generates code across programming languages that |
37 | -uses the abstracted stack to build interoperable RPC clients and servers. |
38 | - |
39 | -Thrift is specifically designed to support non-atomic version changes |
40 | -across client and server code. |
41 | - |
42 | -For more details on Thrift's design and implementation, take a gander at |
43 | -the Thrift whitepaper included in this distribution or at the README files |
44 | -in your particular subdirectory of interest. |
45 | - |
46 | -Changes |
47 | -======= |
48 | - |
49 | -This repo builds up a small subset of the original Thrift C++ library. |
50 | -Source ready to compile on Linux, Android (at least android-5 platform with |
51 | -exceptions and rtti enabled) and iOS. |
52 | - |
53 | -Hierarchy |
54 | -========= |
55 | - |
56 | -thrift/ |
57 | - |
58 | - lib/ |
59 | - Contains the Thrift software library implementation, subdivided by |
60 | - language of implementation. |
61 | - |
62 | - cpp/ |
63 | - |
64 | -Requirements |
65 | -============ |
66 | - |
67 | - - LibC |
68 | - - Boost (1.47 recommended) |
69 | - |
70 | -Resources |
71 | -========= |
72 | - |
73 | -More information about Thrift can be obtained on the Thrift webpage at: |
74 | - |
75 | - http://thrift.apache.org |
76 | - |
77 | -Acknowledgments |
78 | -=============== |
79 | - |
80 | -Thrift was inspired by pillar, a lightweight RPC tool written by Adam D'Angelo, |
81 | -and also by Google's protocol buffers. |
82 | |
83 | === modified file '3rdParty/libthrift/TApplicationException.h' |
84 | --- 3rdParty/libthrift/TApplicationException.h 2013-11-21 23:30:15 +0000 |
85 | +++ 3rdParty/libthrift/TApplicationException.h 2015-02-26 01:00:39 +0000 |
86 | @@ -22,6 +22,7 @@ |
87 | |
88 | #include <Thrift.h> |
89 | |
90 | + |
91 | namespace apache { namespace thrift { |
92 | |
93 | namespace protocol { |
94 | @@ -42,7 +43,10 @@ |
95 | BAD_SEQUENCE_ID = 4, |
96 | MISSING_RESULT = 5, |
97 | INTERNAL_ERROR = 6, |
98 | - PROTOCOL_ERROR = 7 |
99 | + PROTOCOL_ERROR = 7, |
100 | + INVALID_TRANSFORM = 8, |
101 | + INVALID_PROTOCOL = 9, |
102 | + UNSUPPORTED_CLIENT_TYPE = 10 |
103 | }; |
104 | |
105 | TApplicationException() : |
106 | @@ -77,13 +81,18 @@ |
107 | virtual const char* what() const throw() { |
108 | if (message_.empty()) { |
109 | switch (type_) { |
110 | - case UNKNOWN : return "TApplicationException: Unknown application exception"; |
111 | - case UNKNOWN_METHOD : return "TApplicationException: Unknown method"; |
112 | - case INVALID_MESSAGE_TYPE : return "TApplicationException: Invalid message type"; |
113 | - case WRONG_METHOD_NAME : return "TApplicationException: Wrong method name"; |
114 | - case BAD_SEQUENCE_ID : return "TApplicationException: Bad sequence identifier"; |
115 | - case MISSING_RESULT : return "TApplicationException: Missing result"; |
116 | - default : return "TApplicationException: (Invalid exception type)"; |
117 | + case UNKNOWN : return "TApplicationException: Unknown application exception"; |
118 | + case UNKNOWN_METHOD : return "TApplicationException: Unknown method"; |
119 | + case INVALID_MESSAGE_TYPE : return "TApplicationException: Invalid message type"; |
120 | + case WRONG_METHOD_NAME : return "TApplicationException: Wrong method name"; |
121 | + case BAD_SEQUENCE_ID : return "TApplicationException: Bad sequence identifier"; |
122 | + case MISSING_RESULT : return "TApplicationException: Missing result"; |
123 | + case INTERNAL_ERROR : return "TApplicationException: Internal error"; |
124 | + case PROTOCOL_ERROR : return "TApplicationException: Protocol error"; |
125 | + case INVALID_TRANSFORM : return "TApplicationException: Invalid transform"; |
126 | + case INVALID_PROTOCOL : return "TApplicationException: Invalid protocol"; |
127 | + case UNSUPPORTED_CLIENT_TYPE : return "TApplicationException: Unsupported client type"; |
128 | + default : return "TApplicationException: (Invalid exception type)"; |
129 | }; |
130 | } else { |
131 | return message_.c_str(); |
132 | |
133 | === added file '3rdParty/libthrift/TDispatchProcessor.h' |
134 | --- 3rdParty/libthrift/TDispatchProcessor.h 1970-01-01 00:00:00 +0000 |
135 | +++ 3rdParty/libthrift/TDispatchProcessor.h 2015-02-26 01:00:39 +0000 |
136 | @@ -0,0 +1,142 @@ |
137 | +/* |
138 | + * Licensed to the Apache Software Foundation (ASF) under one |
139 | + * or more contributor license agreements. See the NOTICE file |
140 | + * distributed with this work for additional information |
141 | + * regarding copyright ownership. The ASF licenses this file |
142 | + * to you under the Apache License, Version 2.0 (the |
143 | + * "License"); you may not use this file except in compliance |
144 | + * with the License. You may obtain a copy of the License at |
145 | + * |
146 | + * http://www.apache.org/licenses/LICENSE-2.0 |
147 | + * |
148 | + * Unless required by applicable law or agreed to in writing, |
149 | + * software distributed under the License is distributed on an |
150 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
151 | + * KIND, either express or implied. See the License for the |
152 | + * specific language governing permissions and limitations |
153 | + * under the License. |
154 | + */ |
155 | +#ifndef _THRIFT_TDISPATCHPROCESSOR_H_ |
156 | +#define _THRIFT_TDISPATCHPROCESSOR_H_ 1 |
157 | + |
158 | +#include <thrift/TProcessor.h> |
159 | + |
160 | +namespace apache { namespace thrift { |
161 | + |
162 | +/** |
163 | + * TDispatchProcessor is a helper class to parse the message header then call |
164 | + * another function to dispatch based on the function name. |
165 | + * |
166 | + * Subclasses must implement dispatchCall() to dispatch on the function name. |
167 | + */ |
168 | +template <class Protocol_> |
169 | +class TDispatchProcessorT : public TProcessor { |
170 | + public: |
171 | + virtual bool process(boost::shared_ptr<protocol::TProtocol> in, |
172 | + boost::shared_ptr<protocol::TProtocol> out, |
173 | + void* connectionContext) { |
174 | + protocol::TProtocol* inRaw = in.get(); |
175 | + protocol::TProtocol* outRaw = out.get(); |
176 | + |
177 | + // Try to dynamic cast to the template protocol type |
178 | + Protocol_* specificIn = dynamic_cast<Protocol_*>(inRaw); |
179 | + Protocol_* specificOut = dynamic_cast<Protocol_*>(outRaw); |
180 | + if (specificIn && specificOut) { |
181 | + return processFast(specificIn, specificOut, connectionContext); |
182 | + } |
183 | + |
184 | + // Log the fact that we have to use the slow path |
185 | + T_GENERIC_PROTOCOL(this, inRaw, specificIn); |
186 | + T_GENERIC_PROTOCOL(this, outRaw, specificOut); |
187 | + |
188 | + std::string fname; |
189 | + protocol::TMessageType mtype; |
190 | + int32_t seqid; |
191 | + inRaw->readMessageBegin(fname, mtype, seqid); |
192 | + |
193 | + // If this doesn't look like a valid call, log an error and return false so |
194 | + // that the server will close the connection. |
195 | + // |
196 | + // (The old generated processor code used to try to skip a T_STRUCT and |
197 | + // continue. However, that seems unsafe.) |
198 | + if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) { |
199 | + GlobalOutput.printf("received invalid message type %d from client", |
200 | + mtype); |
201 | + return false; |
202 | + } |
203 | + |
204 | + return this->dispatchCall(inRaw, outRaw, fname, seqid, connectionContext); |
205 | + } |
206 | + |
207 | + protected: |
208 | + bool processFast(Protocol_* in, Protocol_* out, void* connectionContext) { |
209 | + std::string fname; |
210 | + protocol::TMessageType mtype; |
211 | + int32_t seqid; |
212 | + in->readMessageBegin(fname, mtype, seqid); |
213 | + |
214 | + if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) { |
215 | + GlobalOutput.printf("received invalid message type %d from client", |
216 | + mtype); |
217 | + return false; |
218 | + } |
219 | + |
220 | + return this->dispatchCallTemplated(in, out, fname, |
221 | + seqid, connectionContext); |
222 | + } |
223 | + |
224 | + /** |
225 | + * dispatchCall() methods must be implemented by subclasses |
226 | + */ |
227 | + virtual bool dispatchCall(apache::thrift::protocol::TProtocol* in, |
228 | + apache::thrift::protocol::TProtocol* out, |
229 | + const std::string& fname, int32_t seqid, |
230 | + void* callContext) = 0; |
231 | + |
232 | + virtual bool dispatchCallTemplated(Protocol_* in, Protocol_* out, |
233 | + const std::string& fname, int32_t seqid, |
234 | + void* callContext) = 0; |
235 | +}; |
236 | + |
237 | +/** |
238 | + * Non-templatized version of TDispatchProcessor, that doesn't bother trying to |
239 | + * perform a dynamic_cast. |
240 | + */ |
241 | +class TDispatchProcessor : public TProcessor { |
242 | + public: |
243 | + virtual bool process(boost::shared_ptr<protocol::TProtocol> in, |
244 | + boost::shared_ptr<protocol::TProtocol> out, |
245 | + void* connectionContext) { |
246 | + std::string fname; |
247 | + protocol::TMessageType mtype; |
248 | + int32_t seqid; |
249 | + in->readMessageBegin(fname, mtype, seqid); |
250 | + |
251 | + if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) { |
252 | + GlobalOutput.printf("received invalid message type %d from client", |
253 | + mtype); |
254 | + return false; |
255 | + } |
256 | + |
257 | + return dispatchCall(in.get(), out.get(), fname, seqid, connectionContext); |
258 | + } |
259 | + |
260 | + protected: |
261 | + virtual bool dispatchCall(apache::thrift::protocol::TProtocol* in, |
262 | + apache::thrift::protocol::TProtocol* out, |
263 | + const std::string& fname, int32_t seqid, |
264 | + void* callContext) = 0; |
265 | +}; |
266 | + |
267 | +// Specialize TDispatchProcessorT for TProtocol and TDummyProtocol just to use |
268 | +// the generic TDispatchProcessor. |
269 | +template <> |
270 | +class TDispatchProcessorT<protocol::TDummyProtocol> : |
271 | + public TDispatchProcessor {}; |
272 | +template <> |
273 | +class TDispatchProcessorT<protocol::TProtocol> : |
274 | + public TDispatchProcessor {}; |
275 | + |
276 | +}} // apache::thrift |
277 | + |
278 | +#endif // _THRIFT_TDISPATCHPROCESSOR_H_ |
279 | |
280 | === modified file '3rdParty/libthrift/TLogging.h' |
281 | --- 3rdParty/libthrift/TLogging.h 2013-11-21 23:30:15 +0000 |
282 | +++ 3rdParty/libthrift/TLogging.h 2015-02-26 01:00:39 +0000 |
283 | @@ -20,20 +20,14 @@ |
284 | #ifndef _THRIFT_TLOGGING_H_ |
285 | #define _THRIFT_TLOGGING_H_ 1 |
286 | |
287 | -#ifdef HAVE_CONFIG_H |
288 | -#include "config.h" |
289 | -#endif |
290 | +#include <thrift-config.h> |
291 | |
292 | /** |
293 | * Contains utility macros for debugging and logging. |
294 | * |
295 | */ |
296 | |
297 | -#ifndef HAVE_CLOCK_GETTIME |
298 | #include <time.h> |
299 | -#else |
300 | -#include <sys/time.h> |
301 | -#endif |
302 | |
303 | #ifdef HAVE_STDINT_H |
304 | #include <stdint.h> |
305 | @@ -82,7 +76,7 @@ |
306 | time_t now; \ |
307 | char dbgtime[26] ; \ |
308 | time(&now); \ |
309 | - ctime_r(&now, dbgtime); \ |
310 | + THRIFT_CTIME_R(&now, dbgtime); \ |
311 | dbgtime[24] = '\0'; \ |
312 | fprintf(stderr,"[%s,%d] [%s] " format_string " \n", __FILE__, __LINE__,dbgtime,##__VA_ARGS__); \ |
313 | } \ |
314 | @@ -115,7 +109,7 @@ |
315 | time_t now; \ |
316 | char dbgtime[26] ; \ |
317 | time(&now); \ |
318 | - ctime_r(&now, dbgtime); \ |
319 | + THRIFT_CTIME_R(&now, dbgtime); \ |
320 | dbgtime[24] = '\0'; \ |
321 | fprintf(stderr,"[%s,%d] [%s] ERROR: " format_string " \n", __FILE__, __LINE__,dbgtime,##__VA_ARGS__); \ |
322 | } |
323 | @@ -132,7 +126,7 @@ |
324 | time_t now; \ |
325 | char dbgtime[26] ; \ |
326 | time(&now); \ |
327 | - ctime_r(&now, dbgtime); \ |
328 | + THRIFT_CTIME_R(&now, dbgtime); \ |
329 | dbgtime[24] = '\0'; \ |
330 | fprintf(stderr,"[%s,%d] [%s] ERROR: Going to abort " format_string " \n", __FILE__, __LINE__,dbgtime,##__VA_ARGS__); \ |
331 | exit(1); \ |
332 | @@ -151,7 +145,7 @@ |
333 | time_t now; \ |
334 | char dbgtime[26] ; \ |
335 | time(&now); \ |
336 | - ctime_r(&now, dbgtime); \ |
337 | + THRIFT_CTIME_R(&now, dbgtime); \ |
338 | dbgtime[24] = '\0'; \ |
339 | fprintf(stderr,"[%s] " format_string " \n", dbgtime,##__VA_ARGS__); \ |
340 | } \ |
341 | |
342 | === modified file '3rdParty/libthrift/TReflectionLocal.h' |
343 | --- 3rdParty/libthrift/TReflectionLocal.h 2013-11-21 23:30:15 +0000 |
344 | +++ 3rdParty/libthrift/TReflectionLocal.h 2015-02-26 01:00:39 +0000 |
345 | @@ -22,7 +22,7 @@ |
346 | |
347 | #include <stdint.h> |
348 | #include <cstring> |
349 | -#include <protocol/TProtocol.h> |
350 | +#include <thrift/protocol/TProtocol.h> |
351 | |
352 | /** |
353 | * Local Reflection is a blanket term referring to the the structure |
354 | |
355 | === added file '3rdParty/libthrift/TToString.h' |
356 | --- 3rdParty/libthrift/TToString.h 1970-01-01 00:00:00 +0000 |
357 | +++ 3rdParty/libthrift/TToString.h 2015-02-26 01:00:39 +0000 |
358 | @@ -0,0 +1,89 @@ |
359 | +/* |
360 | + * Licensed to the Apache Software Foundation (ASF) under one |
361 | + * or more contributor license agreements. See the NOTICE file |
362 | + * distributed with this work for additional information |
363 | + * regarding copyright ownership. The ASF licenses this file |
364 | + * to you under the Apache License, Version 2.0 (the |
365 | + * "License"); you may not use this file except in compliance |
366 | + * with the License. You may obtain a copy of the License at |
367 | + * |
368 | + * http://www.apache.org/licenses/LICENSE-2.0 |
369 | + * |
370 | + * Unless required by applicable law or agreed to in writing, |
371 | + * software distributed under the License is distributed on an |
372 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
373 | + * KIND, either express or implied. See the License for the |
374 | + * specific language governing permissions and limitations |
375 | + * under the License. |
376 | + */ |
377 | + |
378 | +#ifndef _THRIFT_TOSTRING_H_ |
379 | +#define _THRIFT_TOSTRING_H_ 1 |
380 | + |
381 | +#include <boost/lexical_cast.hpp> |
382 | + |
383 | +#include <vector> |
384 | +#include <map> |
385 | +#include <set> |
386 | +#include <string> |
387 | +#include <sstream> |
388 | + |
389 | +namespace apache { namespace thrift { |
390 | + |
391 | +template <typename T> |
392 | +std::string to_string(const T& t) { |
393 | + return boost::lexical_cast<std::string>(t); |
394 | +} |
395 | + |
396 | +template <typename K, typename V> |
397 | +std::string to_string(const std::map<K, V>& m); |
398 | + |
399 | +template <typename T> |
400 | +std::string to_string(const std::set<T>& s); |
401 | + |
402 | +template <typename T> |
403 | +std::string to_string(const std::vector<T>& t); |
404 | + |
405 | +template <typename K, typename V> |
406 | +std::string to_string(const typename std::pair<K, V>& v) { |
407 | + std::ostringstream o; |
408 | + o << to_string(v.first) << ": " << to_string(v.second); |
409 | + return o.str(); |
410 | +} |
411 | + |
412 | +template <typename T> |
413 | +std::string to_string(const T& beg, const T& end) |
414 | +{ |
415 | + std::ostringstream o; |
416 | + for (T it = beg; it != end; ++it) { |
417 | + if (it != beg) |
418 | + o << ", "; |
419 | + o << to_string(*it); |
420 | + } |
421 | + return o.str(); |
422 | +} |
423 | + |
424 | +template <typename T> |
425 | +std::string to_string(const std::vector<T>& t) { |
426 | + std::ostringstream o; |
427 | + o << "[" << to_string(t.begin(), t.end()) << "]"; |
428 | + return o.str(); |
429 | +} |
430 | + |
431 | +template <typename K, typename V> |
432 | +std::string to_string(const std::map<K, V>& m) { |
433 | + std::ostringstream o; |
434 | + o << "{" << to_string(m.begin(), m.end()) << "}"; |
435 | + return o.str(); |
436 | +} |
437 | + |
438 | +template <typename T> |
439 | +std::string to_string(const std::set<T>& s) { |
440 | + std::ostringstream o; |
441 | + o << "{" << to_string(s.begin(), s.end()) << "}"; |
442 | + return o.str(); |
443 | +} |
444 | + |
445 | +}} // apache::thrift |
446 | + |
447 | +#endif // _THRIFT_TOSTRING_H_ |
448 | |
449 | === modified file '3rdParty/libthrift/Thrift.cpp' |
450 | --- 3rdParty/libthrift/Thrift.cpp 2013-11-21 23:30:15 +0000 |
451 | +++ 3rdParty/libthrift/Thrift.cpp 2015-02-26 01:00:39 +0000 |
452 | @@ -29,11 +29,25 @@ |
453 | TOutput GlobalOutput; |
454 | |
455 | void TOutput::printf(const char *message, ...) { |
456 | +#ifndef THRIFT_SQUELCH_CONSOLE_OUTPUT |
457 | // Try to reduce heap usage, even if printf is called rarely. |
458 | static const int STACK_BUF_SIZE = 256; |
459 | char stack_buf[STACK_BUF_SIZE]; |
460 | va_list ap; |
461 | |
462 | +#ifdef _MSC_VER |
463 | + va_start(ap, message); |
464 | + int need = _vscprintf(message, ap); |
465 | + va_end(ap); |
466 | + |
467 | + if (need < STACK_BUF_SIZE) { |
468 | + va_start(ap, message); |
469 | + vsnprintf_s(stack_buf, STACK_BUF_SIZE, _TRUNCATE, message, ap); |
470 | + va_end(ap); |
471 | + f_(stack_buf); |
472 | + return; |
473 | + } |
474 | +#else |
475 | va_start(ap, message); |
476 | int need = vsnprintf(stack_buf, STACK_BUF_SIZE, message, ap); |
477 | va_end(ap); |
478 | @@ -42,9 +56,15 @@ |
479 | f_(stack_buf); |
480 | return; |
481 | } |
482 | +#endif |
483 | |
484 | char *heap_buf = (char*)malloc((need+1) * sizeof(char)); |
485 | if (heap_buf == NULL) { |
486 | +#ifdef _MSC_VER |
487 | + va_start(ap, message); |
488 | + vsnprintf_s(stack_buf, STACK_BUF_SIZE, _TRUNCATE, message, ap); |
489 | + va_end(ap); |
490 | +#endif |
491 | // Malloc failed. We might as well print the stack buffer. |
492 | f_(stack_buf); |
493 | return; |
494 | @@ -58,6 +78,18 @@ |
495 | f_(heap_buf); |
496 | } |
497 | free(heap_buf); |
498 | +#endif |
499 | +} |
500 | + |
501 | +void TOutput::errorTimeWrapper(const char* msg) { |
502 | +#ifndef THRIFT_SQUELCH_CONSOLE_OUTPUT |
503 | + time_t now; |
504 | + char dbgtime[26]; |
505 | + time(&now); |
506 | + THRIFT_CTIME_R(&now, dbgtime); |
507 | + dbgtime[24] = 0; |
508 | + fprintf(stderr, "Thrift: %s %s\n", dbgtime, msg); |
509 | +#endif |
510 | } |
511 | |
512 | void TOutput::perror(const char *message, int errno_copy) { |
513 | |
514 | === modified file '3rdParty/libthrift/Thrift.h' |
515 | --- 3rdParty/libthrift/Thrift.h 2013-11-21 23:30:15 +0000 |
516 | +++ 3rdParty/libthrift/Thrift.h 2015-02-26 01:00:39 +0000 |
517 | @@ -20,13 +20,10 @@ |
518 | #ifndef _THRIFT_THRIFT_H_ |
519 | #define _THRIFT_THRIFT_H_ 1 |
520 | |
521 | -#ifdef _WIN32 |
522 | -#include "windows/config.h" |
523 | -#endif |
524 | - |
525 | -#ifdef HAVE_CONFIG_H |
526 | -#include "config.h" |
527 | -#endif |
528 | +#include <transport/PlatformSocket.h> |
529 | + |
530 | +#include <thrift-config.h> |
531 | + |
532 | #include <stdio.h> |
533 | #include <assert.h> |
534 | |
535 | @@ -48,7 +45,7 @@ |
536 | #include <boost/utility/enable_if.hpp> |
537 | #include <boost/type_traits/is_convertible.hpp> |
538 | |
539 | -#include "TLogging.h" |
540 | +#include <TLogging.h> |
541 | |
542 | /** |
543 | * Helper macros to allow function overloading even when using |
544 | @@ -72,6 +69,8 @@ |
545 | #define THRIFT_OVERLOAD_IF(T, Y) \ |
546 | THRIFT_OVERLOAD_IF_DEFN(T, Y) = NULL |
547 | |
548 | +#define THRIFT_UNUSED_VARIABLE(x) ((void)(x)) |
549 | + |
550 | namespace apache { namespace thrift { |
551 | |
552 | class TEnumIterator : public std::iterator<std::forward_iterator_tag, std::pair<int, const char*> > { |
553 | @@ -87,6 +86,7 @@ |
554 | } |
555 | |
556 | bool operator !=(const TEnumIterator& end) { |
557 | + (void)end; // avoid "unused" warning with NDEBUG |
558 | assert(end.n_ == -1); |
559 | return (ii_ != n_); |
560 | } |
561 | @@ -125,14 +125,7 @@ |
562 | |
563 | void printf(const char *message, ...); |
564 | |
565 | - inline static void errorTimeWrapper(const char* msg) { |
566 | - time_t now; |
567 | - char dbgtime[26]; |
568 | - time(&now); |
569 | - ctime_r(&now, dbgtime); |
570 | - dbgtime[24] = 0; |
571 | - fprintf(stderr, "Thrift: %s %s\n", dbgtime, msg); |
572 | - } |
573 | + static void errorTimeWrapper(const char* msg); |
574 | |
575 | /** Just like strerror_r but returns a C++ string object. */ |
576 | static std::string strerror_s(int errno_copy); |
577 | |
578 | === modified file '3rdParty/libthrift/VirtualProfiling.cpp' |
579 | --- 3rdParty/libthrift/VirtualProfiling.cpp 2013-11-21 23:30:15 +0000 |
580 | +++ 3rdParty/libthrift/VirtualProfiling.cpp 2015-02-26 01:00:39 +0000 |
581 | @@ -17,7 +17,7 @@ |
582 | * under the License. |
583 | */ |
584 | |
585 | -#include <Thrift.h> |
586 | +#include <thrift/Thrift.h> |
587 | |
588 | // Do nothing if virtual call profiling is not enabled |
589 | #if T_GLOBAL_DEBUG_VIRTUAL > 1 |
590 | @@ -36,7 +36,7 @@ |
591 | #endif // !__GLIBC__ |
592 | |
593 | |
594 | -#include <concurrency/Mutex.h> |
595 | +#include <thrift/concurrency/Mutex.h> |
596 | |
597 | #include <ext/hash_map> |
598 | #include <execinfo.h> |
599 | |
600 | === modified file '3rdParty/libthrift/async/TAsyncBufferProcessor.h' |
601 | --- 3rdParty/libthrift/async/TAsyncBufferProcessor.h 2013-11-21 23:30:15 +0000 |
602 | +++ 3rdParty/libthrift/async/TAsyncBufferProcessor.h 2015-02-26 01:00:39 +0000 |
603 | @@ -20,10 +20,10 @@ |
604 | #ifndef _THRIFT_TASYNC_BUFFER_PROCESSOR_H_ |
605 | #define _THRIFT_TASYNC_BUFFER_PROCESSOR_H_ 1 |
606 | |
607 | -#include <tr1/functional> |
608 | +#include <cxxfunctional.h> |
609 | #include <boost/shared_ptr.hpp> |
610 | |
611 | -#include "transport/TBufferTransports.h" |
612 | +#include <transport/TBufferTransports.h> |
613 | |
614 | namespace apache { namespace thrift { namespace async { |
615 | |
616 | @@ -35,7 +35,7 @@ |
617 | // "in" and "out" should be TMemoryBuffer or similar, |
618 | // not a wrapper around a socket. |
619 | virtual void process( |
620 | - std::tr1::function<void(bool healthy)> _return, |
621 | + apache::thrift::stdcxx::function<void(bool healthy)> _return, |
622 | boost::shared_ptr<apache::thrift::transport::TBufferBase> ibuf, |
623 | boost::shared_ptr<apache::thrift::transport::TBufferBase> obuf) = 0; |
624 | virtual ~TAsyncBufferProcessor() {} |
625 | |
626 | === modified file '3rdParty/libthrift/async/TAsyncChannel.cpp' |
627 | --- 3rdParty/libthrift/async/TAsyncChannel.cpp 2013-11-21 23:30:15 +0000 |
628 | +++ 3rdParty/libthrift/async/TAsyncChannel.cpp 2015-02-26 01:00:39 +0000 |
629 | @@ -18,15 +18,15 @@ |
630 | */ |
631 | |
632 | #include <async/TAsyncChannel.h> |
633 | -#include <tr1/functional> |
634 | +#include <cxxfunctional.h> |
635 | |
636 | namespace apache { namespace thrift { namespace async { |
637 | |
638 | void TAsyncChannel::sendAndRecvMessage(const VoidCallback& cob, |
639 | TMemoryBuffer* sendBuf, |
640 | TMemoryBuffer* recvBuf) { |
641 | - std::tr1::function<void()> send_done = |
642 | - std::tr1::bind(&TAsyncChannel::recvMessage, this, cob, recvBuf); |
643 | + apache::thrift::stdcxx::function<void()> send_done = |
644 | + apache::thrift::stdcxx::bind(&TAsyncChannel::recvMessage, this, cob, recvBuf); |
645 | |
646 | sendMessage(send_done, sendBuf); |
647 | } |
648 | |
649 | === modified file '3rdParty/libthrift/async/TAsyncChannel.h' |
650 | --- 3rdParty/libthrift/async/TAsyncChannel.h 2013-11-21 23:30:15 +0000 |
651 | +++ 3rdParty/libthrift/async/TAsyncChannel.h 2015-02-26 01:00:39 +0000 |
652 | @@ -20,7 +20,7 @@ |
653 | #ifndef _THRIFT_ASYNC_TASYNCCHANNEL_H_ |
654 | #define _THRIFT_ASYNC_TASYNCCHANNEL_H_ 1 |
655 | |
656 | -#include <tr1/functional> |
657 | +#include <cxxfunctional.h> |
658 | #include <Thrift.h> |
659 | |
660 | namespace apache { namespace thrift { namespace transport { |
661 | @@ -32,7 +32,7 @@ |
662 | |
663 | class TAsyncChannel { |
664 | public: |
665 | - typedef std::tr1::function<void()> VoidCallback; |
666 | + typedef apache::thrift::stdcxx::function<void()> VoidCallback; |
667 | |
668 | virtual ~TAsyncChannel() {} |
669 | |
670 | |
671 | === added file '3rdParty/libthrift/async/TAsyncDispatchProcessor.h' |
672 | --- 3rdParty/libthrift/async/TAsyncDispatchProcessor.h 1970-01-01 00:00:00 +0000 |
673 | +++ 3rdParty/libthrift/async/TAsyncDispatchProcessor.h 2015-02-26 01:00:39 +0000 |
674 | @@ -0,0 +1,149 @@ |
675 | +/* |
676 | + * Licensed to the Apache Software Foundation (ASF) under one |
677 | + * or more contributor license agreements. See the NOTICE file |
678 | + * distributed with this work for additional information |
679 | + * regarding copyright ownership. The ASF licenses this file |
680 | + * to you under the Apache License, Version 2.0 (the |
681 | + * "License"); you may not use this file except in compliance |
682 | + * with the License. You may obtain a copy of the License at |
683 | + * |
684 | + * http://www.apache.org/licenses/LICENSE-2.0 |
685 | + * |
686 | + * Unless required by applicable law or agreed to in writing, |
687 | + * software distributed under the License is distributed on an |
688 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
689 | + * KIND, either express or implied. See the License for the |
690 | + * specific language governing permissions and limitations |
691 | + * under the License. |
692 | + */ |
693 | +#ifndef _THRIFT_ASYNC_TASYNCDISPATCHPROCESSOR_H_ |
694 | +#define _THRIFT_ASYNC_TASYNCDISPATCHPROCESSOR_H_ 1 |
695 | + |
696 | +#include <thrift/async/TAsyncProcessor.h> |
697 | + |
698 | +namespace apache { namespace thrift { namespace async { |
699 | + |
700 | +/** |
701 | + * TAsyncDispatchProcessor is a helper class to parse the message header then |
702 | + * call another function to dispatch based on the function name. |
703 | + * |
704 | + * Subclasses must implement dispatchCall() to dispatch on the function name. |
705 | + */ |
706 | +template <class Protocol_> |
707 | +class TAsyncDispatchProcessorT : public TAsyncProcessor { |
708 | + public: |
709 | + virtual void process(apache::thrift::stdcxx::function<void(bool success)> _return, |
710 | + boost::shared_ptr<protocol::TProtocol> in, |
711 | + boost::shared_ptr<protocol::TProtocol> out) { |
712 | + protocol::TProtocol* inRaw = in.get(); |
713 | + protocol::TProtocol* outRaw = out.get(); |
714 | + |
715 | + // Try to dynamic cast to the template protocol type |
716 | + Protocol_* specificIn = dynamic_cast<Protocol_*>(inRaw); |
717 | + Protocol_* specificOut = dynamic_cast<Protocol_*>(outRaw); |
718 | + if (specificIn && specificOut) { |
719 | + return processFast(_return, specificIn, specificOut); |
720 | + } |
721 | + |
722 | + // Log the fact that we have to use the slow path |
723 | + T_GENERIC_PROTOCOL(this, inRaw, specificIn); |
724 | + T_GENERIC_PROTOCOL(this, outRaw, specificOut); |
725 | + |
726 | + std::string fname; |
727 | + protocol::TMessageType mtype; |
728 | + int32_t seqid; |
729 | + inRaw->readMessageBegin(fname, mtype, seqid); |
730 | + |
731 | + // If this doesn't look like a valid call, log an error and return false so |
732 | + // that the server will close the connection. |
733 | + // |
734 | + // (The old generated processor code used to try to skip a T_STRUCT and |
735 | + // continue. However, that seems unsafe.) |
736 | + if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) { |
737 | + GlobalOutput.printf("received invalid message type %d from client", |
738 | + mtype); |
739 | + _return(false); |
740 | + return; |
741 | + } |
742 | + |
743 | + return this->dispatchCall(_return, inRaw, outRaw, fname, seqid); |
744 | + } |
745 | + |
746 | + void processFast(apache::thrift::stdcxx::function<void(bool success)> _return, |
747 | + Protocol_* in, Protocol_* out) { |
748 | + std::string fname; |
749 | + protocol::TMessageType mtype; |
750 | + int32_t seqid; |
751 | + in->readMessageBegin(fname, mtype, seqid); |
752 | + |
753 | + if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) { |
754 | + GlobalOutput.printf("received invalid message type %d from client", |
755 | + mtype); |
756 | + _return(false); |
757 | + return; |
758 | + } |
759 | + |
760 | + return this->dispatchCallTemplated(_return, in, out, fname, seqid); |
761 | + } |
762 | + |
763 | + virtual void dispatchCall(apache::thrift::stdcxx::function<void(bool ok)> _return, |
764 | + apache::thrift::protocol::TProtocol* in, |
765 | + apache::thrift::protocol::TProtocol* out, |
766 | + const std::string& fname, int32_t seqid) = 0; |
767 | + |
768 | + virtual void dispatchCallTemplated(apache::thrift::stdcxx::function<void(bool ok)> _return, |
769 | + Protocol_* in, Protocol_* out, |
770 | + const std::string& fname, |
771 | + int32_t seqid) = 0; |
772 | +}; |
773 | + |
774 | +/** |
775 | + * Non-templatized version of TAsyncDispatchProcessor, |
776 | + * that doesn't bother trying to perform a dynamic_cast. |
777 | + */ |
778 | +class TAsyncDispatchProcessor : public TAsyncProcessor { |
779 | + public: |
780 | + virtual void process(apache::thrift::stdcxx::function<void(bool success)> _return, |
781 | + boost::shared_ptr<protocol::TProtocol> in, |
782 | + boost::shared_ptr<protocol::TProtocol> out) { |
783 | + protocol::TProtocol* inRaw = in.get(); |
784 | + protocol::TProtocol* outRaw = out.get(); |
785 | + |
786 | + std::string fname; |
787 | + protocol::TMessageType mtype; |
788 | + int32_t seqid; |
789 | + inRaw->readMessageBegin(fname, mtype, seqid); |
790 | + |
791 | + // If this doesn't look like a valid call, log an error and return false so |
792 | + // that the server will close the connection. |
793 | + // |
794 | + // (The old generated processor code used to try to skip a T_STRUCT and |
795 | + // continue. However, that seems unsafe.) |
796 | + if (mtype != protocol::T_CALL && mtype != protocol::T_ONEWAY) { |
797 | + GlobalOutput.printf("received invalid message type %d from client", |
798 | + mtype); |
799 | + _return(false); |
800 | + return; |
801 | + } |
802 | + |
803 | + return dispatchCall(_return, inRaw, outRaw, fname, seqid); |
804 | + } |
805 | + |
806 | + virtual void dispatchCall(apache::thrift::stdcxx::function<void(bool ok)> _return, |
807 | + apache::thrift::protocol::TProtocol* in, |
808 | + apache::thrift::protocol::TProtocol* out, |
809 | + const std::string& fname, int32_t seqid) = 0; |
810 | +}; |
811 | + |
812 | +// Specialize TAsyncDispatchProcessorT for TProtocol and TDummyProtocol just to |
813 | +// use the generic TDispatchProcessor. |
814 | +template <> |
815 | +class TAsyncDispatchProcessorT<protocol::TDummyProtocol> : |
816 | + public TAsyncDispatchProcessor {}; |
817 | +template <> |
818 | +class TAsyncDispatchProcessorT<protocol::TProtocol> : |
819 | + public TAsyncDispatchProcessor {}; |
820 | + |
821 | +}}} // apache::thrift::async |
822 | + |
823 | +#endif // _THRIFT_ASYNC_TASYNCDISPATCHPROCESSOR_H_ |
824 | |
825 | === modified file '3rdParty/libthrift/async/TAsyncProcessor.h' |
826 | --- 3rdParty/libthrift/async/TAsyncProcessor.h 2013-11-21 23:30:15 +0000 |
827 | +++ 3rdParty/libthrift/async/TAsyncProcessor.h 2015-02-26 01:00:39 +0000 |
828 | @@ -20,7 +20,7 @@ |
829 | #ifndef _THRIFT_TASYNCPROCESSOR_H_ |
830 | #define _THRIFT_TASYNCPROCESSOR_H_ 1 |
831 | |
832 | -#include <tr1/functional> |
833 | +#include <cxxfunctional.h> |
834 | #include <boost/shared_ptr.hpp> |
835 | #include <protocol/TProtocol.h> |
836 | #include <TProcessor.h> |
837 | @@ -38,11 +38,11 @@ |
838 | public: |
839 | virtual ~TAsyncProcessor() {} |
840 | |
841 | - virtual void process(std::tr1::function<void(bool success)> _return, |
842 | + virtual void process(apache::thrift::stdcxx::function<void(bool success)> _return, |
843 | boost::shared_ptr<protocol::TProtocol> in, |
844 | boost::shared_ptr<protocol::TProtocol> out) = 0; |
845 | |
846 | - void process(std::tr1::function<void(bool success)> _return, |
847 | + void process(apache::thrift::stdcxx::function<void(bool success)> _return, |
848 | boost::shared_ptr<apache::thrift::protocol::TProtocol> io) { |
849 | return process(_return, io, io); |
850 | } |
851 | |
852 | === modified file '3rdParty/libthrift/async/TAsyncProtocolProcessor.cpp' |
853 | --- 3rdParty/libthrift/async/TAsyncProtocolProcessor.cpp 2013-11-21 23:30:15 +0000 |
854 | +++ 3rdParty/libthrift/async/TAsyncProtocolProcessor.cpp 2015-02-26 01:00:39 +0000 |
855 | @@ -17,7 +17,7 @@ |
856 | * under the License. |
857 | */ |
858 | |
859 | -#include "TAsyncProtocolProcessor.h" |
860 | +#include <async/TAsyncProtocolProcessor.h> |
861 | |
862 | using apache::thrift::transport::TBufferBase; |
863 | using apache::thrift::protocol::TProtocol; |
864 | @@ -25,22 +25,22 @@ |
865 | namespace apache { namespace thrift { namespace async { |
866 | |
867 | void TAsyncProtocolProcessor::process( |
868 | - std::tr1::function<void(bool healthy)> _return, |
869 | + apache::thrift::stdcxx::function<void(bool healthy)> _return, |
870 | boost::shared_ptr<TBufferBase> ibuf, |
871 | boost::shared_ptr<TBufferBase> obuf) { |
872 | boost::shared_ptr<TProtocol> iprot(pfact_->getProtocol(ibuf)); |
873 | boost::shared_ptr<TProtocol> oprot(pfact_->getProtocol(obuf)); |
874 | return underlying_->process( |
875 | - std::tr1::bind( |
876 | + apache::thrift::stdcxx::bind( |
877 | &TAsyncProtocolProcessor::finish, |
878 | _return, |
879 | oprot, |
880 | - std::tr1::placeholders::_1), |
881 | + apache::thrift::stdcxx::placeholders::_1), |
882 | iprot, oprot); |
883 | } |
884 | |
885 | /* static */ void TAsyncProtocolProcessor::finish( |
886 | - std::tr1::function<void(bool healthy)> _return, |
887 | + apache::thrift::stdcxx::function<void(bool healthy)> _return, |
888 | boost::shared_ptr<TProtocol> oprot, |
889 | bool healthy) { |
890 | (void) oprot; |
891 | |
892 | === modified file '3rdParty/libthrift/async/TAsyncProtocolProcessor.h' |
893 | --- 3rdParty/libthrift/async/TAsyncProtocolProcessor.h 2013-11-21 23:30:15 +0000 |
894 | +++ 3rdParty/libthrift/async/TAsyncProtocolProcessor.h 2015-02-26 01:00:39 +0000 |
895 | @@ -20,9 +20,9 @@ |
896 | #ifndef _THRIFT_TNAME_ME_H_ |
897 | #define _THRIFT_TNAME_ME_H_ 1 |
898 | |
899 | -#include "TAsyncProcessor.h" |
900 | -#include "TAsyncBufferProcessor.h" |
901 | -#include "protocol/TProtocol.h" |
902 | +#include <async/TAsyncProcessor.h> |
903 | +#include <async/TAsyncBufferProcessor.h> |
904 | +#include <protocol/TProtocol.h> |
905 | |
906 | namespace apache { namespace thrift { namespace async { |
907 | |
908 | @@ -36,7 +36,7 @@ |
909 | {} |
910 | |
911 | virtual void process( |
912 | - std::tr1::function<void(bool healthy)> _return, |
913 | + apache::thrift::stdcxx::function<void(bool healthy)> _return, |
914 | boost::shared_ptr<apache::thrift::transport::TBufferBase> ibuf, |
915 | boost::shared_ptr<apache::thrift::transport::TBufferBase> obuf); |
916 | |
917 | @@ -44,7 +44,7 @@ |
918 | |
919 | private: |
920 | static void finish( |
921 | - std::tr1::function<void(bool healthy)> _return, |
922 | + apache::thrift::stdcxx::function<void(bool healthy)> _return, |
923 | boost::shared_ptr<apache::thrift::protocol::TProtocol> oprot, |
924 | bool healthy); |
925 | |
926 | |
927 | === modified file '3rdParty/libthrift/async/TEvhttpClientChannel.cpp' (properties changed: +x to -x) |
928 | --- 3rdParty/libthrift/async/TEvhttpClientChannel.cpp 2013-11-21 23:30:15 +0000 |
929 | +++ 3rdParty/libthrift/async/TEvhttpClientChannel.cpp 2015-02-26 01:00:39 +0000 |
930 | @@ -17,10 +17,10 @@ |
931 | * under the License. |
932 | */ |
933 | |
934 | -#include "TEvhttpClientChannel.h" |
935 | +#include <thrift/async/TEvhttpClientChannel.h> |
936 | #include <evhttp.h> |
937 | -#include "transport/TBufferTransports.h" |
938 | -#include <protocol/TProtocolException.h> |
939 | +#include <thrift/transport/TBufferTransports.h> |
940 | +#include <thrift/protocol/TProtocolException.h> |
941 | |
942 | #include <iostream> |
943 | #include <sstream> |
944 | @@ -142,7 +142,7 @@ |
945 | } |
946 | recvBuf_->resetBuffer( |
947 | EVBUFFER_DATA(req->input_buffer), |
948 | - EVBUFFER_LENGTH(req->input_buffer)); |
949 | + static_cast<uint32_t>(EVBUFFER_LENGTH(req->input_buffer))); |
950 | cob_(); |
951 | return; |
952 | } |
953 | |
954 | === modified file '3rdParty/libthrift/async/TEvhttpClientChannel.h' |
955 | --- 3rdParty/libthrift/async/TEvhttpClientChannel.h 2013-11-21 23:30:15 +0000 |
956 | +++ 3rdParty/libthrift/async/TEvhttpClientChannel.h 2015-02-26 01:00:39 +0000 |
957 | @@ -22,7 +22,7 @@ |
958 | |
959 | #include <string> |
960 | #include <boost/shared_ptr.hpp> |
961 | -#include "TAsyncChannel.h" |
962 | +#include <thrift/async/TAsyncChannel.h> |
963 | |
964 | struct event_base; |
965 | struct evhttp_connection; |
966 | |
967 | === modified file '3rdParty/libthrift/async/TEvhttpServer.cpp' (properties changed: +x to -x) |
968 | --- 3rdParty/libthrift/async/TEvhttpServer.cpp 2013-11-21 23:30:15 +0000 |
969 | +++ 3rdParty/libthrift/async/TEvhttpServer.cpp 2015-02-26 01:00:39 +0000 |
970 | @@ -17,9 +17,9 @@ |
971 | * under the License. |
972 | */ |
973 | |
974 | -#include "TEvhttpServer.h" |
975 | -#include "TAsyncBufferProcessor.h" |
976 | -#include "transport/TBufferTransports.h" |
977 | +#include <thrift/async/TEvhttpServer.h> |
978 | +#include <thrift/async/TAsyncBufferProcessor.h> |
979 | +#include <thrift/transport/TBufferTransports.h> |
980 | #include <evhttp.h> |
981 | |
982 | #include <iostream> |
983 | @@ -99,7 +99,7 @@ |
984 | |
985 | |
986 | TEvhttpServer::RequestContext::RequestContext(struct evhttp_request* req) : req(req) |
987 | - , ibuf(new TMemoryBuffer(EVBUFFER_DATA(req->input_buffer), EVBUFFER_LENGTH(req->input_buffer))) |
988 | + , ibuf(new TMemoryBuffer(EVBUFFER_DATA(req->input_buffer), static_cast<uint32_t>(EVBUFFER_LENGTH(req->input_buffer)))) |
989 | , obuf(new TMemoryBuffer()) |
990 | {} |
991 | |
992 | @@ -116,11 +116,11 @@ |
993 | void TEvhttpServer::process(struct evhttp_request* req) { |
994 | RequestContext* ctx = new RequestContext(req); |
995 | return processor_->process( |
996 | - std::tr1::bind( |
997 | + apache::thrift::stdcxx::bind( |
998 | &TEvhttpServer::complete, |
999 | this, |
1000 | ctx, |
1001 | - std::tr1::placeholders::_1), |
1002 | + apache::thrift::stdcxx::placeholders::_1), |
1003 | ctx->ibuf, |
1004 | ctx->obuf); |
1005 | } |
1006 | |
1007 | === modified file '3rdParty/libthrift/concurrency/BoostMonitor.cpp' |
1008 | --- 3rdParty/libthrift/concurrency/BoostMonitor.cpp 2013-11-21 23:30:15 +0000 |
1009 | +++ 3rdParty/libthrift/concurrency/BoostMonitor.cpp 2015-02-26 01:00:39 +0000 |
1010 | @@ -17,15 +17,13 @@ |
1011 | * under the License. |
1012 | */ |
1013 | |
1014 | -#ifdef HAVE_CONFIG_H |
1015 | -#include <config.h> |
1016 | -#endif |
1017 | -#include "Monitor.h" |
1018 | -#include "Exception.h" |
1019 | -#include "Util.h" |
1020 | +#include <thrift/thrift-config.h> |
1021 | |
1022 | +#include <thrift/concurrency/Monitor.h> |
1023 | +#include <thrift/concurrency/Exception.h> |
1024 | +#include <thrift/concurrency/Util.h> |
1025 | +#include <thrift/transport/PlatformSocket.h> |
1026 | #include <assert.h> |
1027 | -#include <errno.h> |
1028 | |
1029 | #include <boost/scoped_ptr.hpp> |
1030 | #include <boost/thread.hpp> |
1031 | @@ -38,7 +36,7 @@ |
1032 | * |
1033 | * @version $Id:$ |
1034 | */ |
1035 | -class Monitor::Impl : public boost::condition_variable { |
1036 | +class Monitor::Impl : public boost::condition_variable_any { |
1037 | |
1038 | public: |
1039 | |
1040 | @@ -71,7 +69,7 @@ |
1041 | */ |
1042 | void wait(int64_t timeout_ms) { |
1043 | int result = waitForTimeRelative(timeout_ms); |
1044 | - if (result == ETIMEDOUT) { |
1045 | + if (result == THRIFT_ETIMEDOUT) { |
1046 | throw TimedOutException(); |
1047 | } else if (result != 0) { |
1048 | throw TException( |
1049 | @@ -83,7 +81,7 @@ |
1050 | * Waits until the specified timeout in milliseconds for the condition to |
1051 | * occur, or waits forever if timeout_ms == 0. |
1052 | * |
1053 | - * Returns 0 if condition occurs, ETIMEDOUT on timeout, or an error code. |
1054 | + * Returns 0 if condition occurs, THRIFT_ETIMEDOUT on timeout, or an error code. |
1055 | */ |
1056 | int waitForTimeRelative(int64_t timeout_ms) { |
1057 | if (timeout_ms == 0LL) { |
1058 | @@ -91,41 +89,52 @@ |
1059 | } |
1060 | |
1061 | assert(mutex_); |
1062 | - boost::mutex* mutexImpl = |
1063 | - reinterpret_cast<boost::mutex*>(mutex_->getUnderlyingImpl()); |
1064 | + boost::timed_mutex* mutexImpl = |
1065 | + reinterpret_cast<boost::timed_mutex*>(mutex_->getUnderlyingImpl()); |
1066 | assert(mutexImpl); |
1067 | |
1068 | - boost::mutex::scoped_lock lock(*mutexImpl, boost::adopt_lock); |
1069 | - int res = timed_wait(lock, boost::get_system_time()+boost::posix_time::milliseconds(timeout_ms)) ? 0 : ETIMEDOUT; |
1070 | + boost::timed_mutex::scoped_lock lock(*mutexImpl, boost::adopt_lock); |
1071 | + int res = timed_wait(lock, boost::get_system_time()+boost::posix_time::milliseconds(timeout_ms)) ? 0 : THRIFT_ETIMEDOUT; |
1072 | lock.release(); |
1073 | return res; |
1074 | } |
1075 | |
1076 | /** |
1077 | - * Waits until the absolute time specified using struct timespec. |
1078 | - * Returns 0 if condition occurs, ETIMEDOUT on timeout, or an error code. |
1079 | - */ |
1080 | - int waitForTime(const timespec* abstime) { |
1081 | + * Waits until the absolute time specified using struct THRIFT_TIMESPEC. |
1082 | + * Returns 0 if condition occurs, THRIFT_ETIMEDOUT on timeout, or an error code. |
1083 | + */ |
1084 | + int waitForTime(const THRIFT_TIMESPEC* abstime) { |
1085 | + struct timeval temp; |
1086 | + temp.tv_sec = static_cast<long>(abstime->tv_sec); |
1087 | + temp.tv_usec = static_cast<long>(abstime->tv_nsec) / 1000; |
1088 | + return waitForTime(&temp); |
1089 | + } |
1090 | + |
1091 | + /** |
1092 | + * Waits until the absolute time specified using struct timeval. |
1093 | + * Returns 0 if condition occurs, THRIFT_ETIMEDOUT on timeout, or an error code. |
1094 | + */ |
1095 | + int waitForTime(const struct timeval* abstime) { |
1096 | assert(mutex_); |
1097 | - boost::mutex* mutexImpl = |
1098 | - reinterpret_cast<boost::mutex*>(mutex_->getUnderlyingImpl()); |
1099 | + boost::timed_mutex* mutexImpl = |
1100 | + static_cast<boost::timed_mutex*>(mutex_->getUnderlyingImpl()); |
1101 | assert(mutexImpl); |
1102 | |
1103 | - struct timespec currenttime; |
1104 | - Util::toTimespec(currenttime, Util::currentTime()); |
1105 | + struct timeval currenttime; |
1106 | + Util::toTimeval(currenttime, Util::currentTime()); |
1107 | |
1108 | - long tv_sec = abstime->tv_sec - currenttime.tv_sec; |
1109 | - long tv_nsec = abstime->tv_nsec - currenttime.tv_nsec; |
1110 | + long tv_sec = static_cast<long>(abstime->tv_sec - currenttime.tv_sec); |
1111 | + long tv_usec = static_cast<long>(abstime->tv_usec - currenttime.tv_usec); |
1112 | if(tv_sec < 0) |
1113 | tv_sec = 0; |
1114 | - if(tv_nsec < 0) |
1115 | - tv_nsec = 0; |
1116 | + if(tv_usec < 0) |
1117 | + tv_usec = 0; |
1118 | |
1119 | - boost::mutex::scoped_lock lock(*mutexImpl, boost::adopt_lock); |
1120 | + boost::timed_mutex::scoped_lock lock(*mutexImpl, boost::adopt_lock); |
1121 | int res = timed_wait(lock, boost::get_system_time() + |
1122 | boost::posix_time::seconds(tv_sec) + |
1123 | - boost::posix_time::microseconds(tv_nsec / 1000) |
1124 | - ) ? 0 : ETIMEDOUT; |
1125 | + boost::posix_time::microseconds(tv_usec) |
1126 | + ) ? 0 : THRIFT_ETIMEDOUT; |
1127 | lock.release(); |
1128 | return res; |
1129 | } |
1130 | @@ -136,12 +145,12 @@ |
1131 | */ |
1132 | int waitForever() { |
1133 | assert(mutex_); |
1134 | - boost::mutex* mutexImpl = |
1135 | - reinterpret_cast<boost::mutex*>(mutex_->getUnderlyingImpl()); |
1136 | + boost::timed_mutex* mutexImpl = |
1137 | + reinterpret_cast<boost::timed_mutex*>(mutex_->getUnderlyingImpl()); |
1138 | assert(mutexImpl); |
1139 | |
1140 | - boost::mutex::scoped_lock lock(*mutexImpl, boost::adopt_lock); |
1141 | - ((boost::condition_variable*)this)->wait(lock); |
1142 | + boost::timed_mutex::scoped_lock lock(*mutexImpl, boost::adopt_lock); |
1143 | + ((boost::condition_variable_any*)this)->wait(lock); |
1144 | lock.release(); |
1145 | return 0; |
1146 | } |
1147 | @@ -179,7 +188,11 @@ |
1148 | |
1149 | void Monitor::wait(int64_t timeout) const { const_cast<Monitor::Impl*>(impl_)->wait(timeout); } |
1150 | |
1151 | -int Monitor::waitForTime(const timespec* abstime) const { |
1152 | +int Monitor::waitForTime(const THRIFT_TIMESPEC* abstime) const { |
1153 | + return const_cast<Monitor::Impl*>(impl_)->waitForTime(abstime); |
1154 | +} |
1155 | + |
1156 | +int Monitor::waitForTime(const timeval* abstime) const { |
1157 | return const_cast<Monitor::Impl*>(impl_)->waitForTime(abstime); |
1158 | } |
1159 | |
1160 | |
1161 | === modified file '3rdParty/libthrift/concurrency/BoostMutex.cpp' |
1162 | --- 3rdParty/libthrift/concurrency/BoostMutex.cpp 2013-11-21 23:30:15 +0000 |
1163 | +++ 3rdParty/libthrift/concurrency/BoostMutex.cpp 2015-02-26 01:00:39 +0000 |
1164 | @@ -17,18 +17,16 @@ |
1165 | * under the License. |
1166 | */ |
1167 | |
1168 | -#ifdef HAVE_CONFIG_H |
1169 | -#include <config.h> |
1170 | -#endif |
1171 | -#include "Mutex.h" |
1172 | -#include "Util.h" |
1173 | +#include <thrift/thrift-config.h> |
1174 | + |
1175 | +#include <thrift/concurrency/Mutex.h> |
1176 | +#include <thrift/concurrency/Util.h> |
1177 | +#include <thrift/Thrift.h> |
1178 | |
1179 | #include <cassert> |
1180 | #include <boost/thread.hpp> |
1181 | +#include <boost/thread/mutex.hpp> |
1182 | #include <boost/date_time/posix_time/posix_time.hpp> |
1183 | -#include <boost/interprocess/sync/interprocess_mutex.hpp> |
1184 | - |
1185 | -using namespace boost::interprocess; |
1186 | |
1187 | namespace apache { namespace thrift { namespace concurrency { |
1188 | |
1189 | @@ -37,10 +35,11 @@ |
1190 | * |
1191 | * @version $Id:$ |
1192 | */ |
1193 | -class Mutex::impl : public interprocess_mutex { |
1194 | +class Mutex::impl : public boost::timed_mutex { |
1195 | }; |
1196 | |
1197 | -Mutex::Mutex(Initializer init) : impl_(new Mutex::impl()) {} |
1198 | +Mutex::Mutex(Initializer init) : impl_(new Mutex::impl()) |
1199 | +{ THRIFT_UNUSED_VARIABLE(init); } |
1200 | |
1201 | void* Mutex::getUnderlyingImpl() const { return impl_.get(); } |
1202 | |
1203 | @@ -53,7 +52,7 @@ |
1204 | void Mutex::unlock() const { impl_->unlock(); } |
1205 | |
1206 | void Mutex::DEFAULT_INITIALIZER(void* arg) { |
1207 | + THRIFT_UNUSED_VARIABLE(arg); |
1208 | } |
1209 | |
1210 | }}} // apache::thrift::concurrency |
1211 | - |
1212 | |
1213 | === modified file '3rdParty/libthrift/concurrency/BoostThreadFactory.cpp' |
1214 | --- 3rdParty/libthrift/concurrency/BoostThreadFactory.cpp 2013-11-21 23:30:15 +0000 |
1215 | +++ 3rdParty/libthrift/concurrency/BoostThreadFactory.cpp 2015-02-26 01:00:39 +0000 |
1216 | @@ -17,11 +17,12 @@ |
1217 | * under the License. |
1218 | */ |
1219 | |
1220 | -#ifdef HAVE_CONFIG_H |
1221 | -#include <config.h> |
1222 | -#endif |
1223 | -#include "BoostThreadFactory.h" |
1224 | -#include "Exception.h" |
1225 | +#include <thrift/thrift-config.h> |
1226 | + |
1227 | +#ifdef USE_BOOST_THREAD |
1228 | + |
1229 | +#include <thrift/concurrency/BoostThreadFactory.h> |
1230 | +#include <thrift/concurrency/Exception.h> |
1231 | |
1232 | #include <cassert> |
1233 | |
1234 | @@ -60,10 +61,10 @@ |
1235 | public: |
1236 | |
1237 | BoostThread(bool detached, shared_ptr<Runnable> runnable) : |
1238 | - state_(uninitialized), |
1239 | - detached_(detached) { |
1240 | - this->Thread::runnable(runnable); |
1241 | - } |
1242 | + state_(uninitialized), |
1243 | + detached_(detached) { |
1244 | + this->Thread::runnable(runnable); |
1245 | + } |
1246 | |
1247 | ~BoostThread() { |
1248 | if(!detached_) { |
1249 | @@ -79,27 +80,27 @@ |
1250 | if (state_ != uninitialized) { |
1251 | return; |
1252 | } |
1253 | - |
1254 | - // Create reference |
1255 | + |
1256 | + // Create reference |
1257 | shared_ptr<BoostThread>* selfRef = new shared_ptr<BoostThread>(); |
1258 | *selfRef = self_.lock(); |
1259 | |
1260 | - thread_ = std::auto_ptr<boost::thread>(new boost::thread(boost::bind(threadMain, (void*)selfRef))); |
1261 | - |
1262 | - if(detached_) |
1263 | - thread_->detach(); |
1264 | - |
1265 | - state_ = starting; |
1266 | + state_ = starting; |
1267 | + |
1268 | + thread_ = std::auto_ptr<boost::thread>(new boost::thread(boost::bind(threadMain, (void*)selfRef))); |
1269 | + |
1270 | + if(detached_) |
1271 | + thread_->detach(); |
1272 | } |
1273 | |
1274 | void join() { |
1275 | if (!detached_ && state_ != uninitialized) { |
1276 | - thread_->join(); |
1277 | + thread_->join(); |
1278 | } |
1279 | } |
1280 | |
1281 | Thread::id_t getId() { |
1282 | - return thread_.get() ? thread_->get_id() : boost::thread::id(); |
1283 | + return thread_.get() ? thread_->get_id() : boost::thread::id(); |
1284 | } |
1285 | |
1286 | shared_ptr<Runnable> runnable() const { return Thread::runnable(); } |
1287 | @@ -116,7 +117,7 @@ |
1288 | shared_ptr<BoostThread> thread = *(shared_ptr<BoostThread>*)arg; |
1289 | delete reinterpret_cast<shared_ptr<BoostThread>*>(arg); |
1290 | |
1291 | - if (thread == NULL) { |
1292 | + if (!thread) { |
1293 | return (void*)0; |
1294 | } |
1295 | |
1296 | @@ -163,9 +164,8 @@ |
1297 | void setDetached(bool value) { detached_ = value; } |
1298 | |
1299 | Thread::id_t getCurrentThreadId() const { |
1300 | - return boost::this_thread::get_id(); |
1301 | + return boost::this_thread::get_id(); |
1302 | } |
1303 | - |
1304 | }; |
1305 | |
1306 | BoostThreadFactory::BoostThreadFactory(bool detached) : |
1307 | @@ -180,3 +180,5 @@ |
1308 | Thread::id_t BoostThreadFactory::getCurrentThreadId() const { return impl_->getCurrentThreadId(); } |
1309 | |
1310 | }}} // apache::thrift::concurrency |
1311 | + |
1312 | +#endif // USE_BOOST_THREAD |
1313 | |
1314 | === modified file '3rdParty/libthrift/concurrency/BoostThreadFactory.h' |
1315 | --- 3rdParty/libthrift/concurrency/BoostThreadFactory.h 2013-11-21 23:30:15 +0000 |
1316 | +++ 3rdParty/libthrift/concurrency/BoostThreadFactory.h 2015-02-26 01:00:39 +0000 |
1317 | @@ -20,7 +20,7 @@ |
1318 | #ifndef _THRIFT_CONCURRENCY_BOOSTTHREADFACTORY_H_ |
1319 | #define _THRIFT_CONCURRENCY_BOOSTTHREADFACTORY_H_ 1 |
1320 | |
1321 | -#include "Thread.h" |
1322 | +#include <thrift/concurrency/Thread.h> |
1323 | |
1324 | #include <boost/shared_ptr.hpp> |
1325 | |
1326 | |
1327 | === modified file '3rdParty/libthrift/concurrency/FunctionRunner.h' |
1328 | --- 3rdParty/libthrift/concurrency/FunctionRunner.h 2013-11-21 23:30:15 +0000 |
1329 | +++ 3rdParty/libthrift/concurrency/FunctionRunner.h 2015-02-26 01:00:39 +0000 |
1330 | @@ -20,8 +20,8 @@ |
1331 | #ifndef _THRIFT_CONCURRENCY_FUNCTION_RUNNER_H |
1332 | #define _THRIFT_CONCURRENCY_FUNCTION_RUNNER_H 1 |
1333 | |
1334 | -#include <tr1/functional> |
1335 | -#include "thrift/lib/cpp/concurrency/Thread.h" |
1336 | +#include <cxxfunctional.h> |
1337 | +#include <concurrency/Thread.h> |
1338 | |
1339 | namespace apache { namespace thrift { namespace concurrency { |
1340 | |
1341 | @@ -34,16 +34,15 @@ |
1342 | * void* my_thread_main(void* arg); |
1343 | * shared_ptr<ThreadFactory> factory = ...; |
1344 | * // To create a thread that executes my_thread_main once: |
1345 | - * shared_ptr<Thread> thread = |
1346 | - * factory->newThread(shared_ptr<FunctionRunner>( |
1347 | - * new FunctionRunner(my_thread_main, some_argument))); |
1348 | + * shared_ptr<Thread> thread = factory->newThread( |
1349 | + * FunctionRunner::create(my_thread_main, some_argument)); |
1350 | * thread->start(); |
1351 | * |
1352 | * bool A::foo(); |
1353 | * A* a = new A(); |
1354 | * // To create a thread that executes a.foo() every 100 milliseconds: |
1355 | - * factory->newThread(shared_ptr<FunctionRunner>( |
1356 | - * new FunctionRunner(std::tr1::bind(&A::foo, a), 100)))->start(); |
1357 | + * factory->newThread(FunctionRunner::create( |
1358 | + * apache::thrift::stdcxx::bind(&A::foo, a), 100))->start(); |
1359 | * |
1360 | */ |
1361 | |
1362 | @@ -52,23 +51,43 @@ |
1363 | // This is the type of callback 'pthread_create()' expects. |
1364 | typedef void* (*PthreadFuncPtr)(void *arg); |
1365 | // This a fully-generic void(void) callback for custom bindings. |
1366 | - typedef std::tr1::function<void()> VoidFunc; |
1367 | - |
1368 | - typedef std::tr1::function<bool()> BoolFunc; |
1369 | - |
1370 | + typedef apache::thrift::stdcxx::function<void()> VoidFunc; |
1371 | + |
1372 | + typedef apache::thrift::stdcxx::function<bool()> BoolFunc; |
1373 | + |
1374 | + /** |
1375 | + * Syntactic sugar to make it easier to create new FunctionRunner |
1376 | + * objects wrapped in shared_ptr. |
1377 | + */ |
1378 | + static boost::shared_ptr<FunctionRunner> create(const VoidFunc& cob) { |
1379 | + return boost::shared_ptr<FunctionRunner>(new FunctionRunner(cob)); |
1380 | + } |
1381 | + |
1382 | + static boost::shared_ptr<FunctionRunner> create(PthreadFuncPtr func, |
1383 | + void* arg) { |
1384 | + return boost::shared_ptr<FunctionRunner>(new FunctionRunner(func, arg)); |
1385 | + } |
1386 | + |
1387 | +private: |
1388 | + static void pthread_func_wrapper(PthreadFuncPtr func, void *arg) |
1389 | + { |
1390 | + //discard return value |
1391 | + func(arg); |
1392 | + } |
1393 | +public: |
1394 | /** |
1395 | * Given a 'pthread_create' style callback, this FunctionRunner will |
1396 | * execute the given callback. Note that the 'void*' return value is ignored. |
1397 | */ |
1398 | FunctionRunner(PthreadFuncPtr func, void* arg) |
1399 | - : func_(std::tr1::bind(func, arg)), repFunc_(0) |
1400 | + : func_(apache::thrift::stdcxx::bind(pthread_func_wrapper, func, arg)) |
1401 | { } |
1402 | |
1403 | /** |
1404 | * Given a generic callback, this FunctionRunner will execute it. |
1405 | */ |
1406 | FunctionRunner(const VoidFunc& cob) |
1407 | - : func_(cob), repFunc_(0) |
1408 | + : func_(cob) |
1409 | { } |
1410 | |
1411 | /** |
1412 | @@ -78,13 +97,13 @@ |
1413 | * be intervalMs plus execution time of the callback. |
1414 | */ |
1415 | FunctionRunner(const BoolFunc& cob, int intervalMs) |
1416 | - : func_(0), repFunc_(cob), intervalMs_(intervalMs) |
1417 | + : repFunc_(cob), intervalMs_(intervalMs) |
1418 | { } |
1419 | |
1420 | void run() { |
1421 | if (repFunc_) { |
1422 | while(repFunc_()) { |
1423 | - usleep(intervalMs_*1000); |
1424 | + THRIFT_SLEEP_USEC(intervalMs_*1000); |
1425 | } |
1426 | } else { |
1427 | func_(); |
1428 | |
1429 | === modified file '3rdParty/libthrift/concurrency/Monitor.cpp' |
1430 | --- 3rdParty/libthrift/concurrency/Monitor.cpp 2013-11-21 23:30:15 +0000 |
1431 | +++ 3rdParty/libthrift/concurrency/Monitor.cpp 2015-02-26 01:00:39 +0000 |
1432 | @@ -17,14 +17,14 @@ |
1433 | * under the License. |
1434 | */ |
1435 | |
1436 | -#include "Monitor.h" |
1437 | -#include "Exception.h" |
1438 | -#include "Util.h" |
1439 | +#include <concurrency/Monitor.h> |
1440 | +#include <concurrency/Exception.h> |
1441 | +#include <concurrency/Util.h> |
1442 | +#include <transport/PlatformSocket.h> |
1443 | |
1444 | #include <boost/scoped_ptr.hpp> |
1445 | |
1446 | #include <assert.h> |
1447 | -#include <errno.h> |
1448 | |
1449 | #include <iostream> |
1450 | |
1451 | @@ -77,7 +77,7 @@ |
1452 | */ |
1453 | void wait(int64_t timeout_ms) const { |
1454 | int result = waitForTimeRelative(timeout_ms); |
1455 | - if (result == ETIMEDOUT) { |
1456 | + if (result == THRIFT_ETIMEDOUT) { |
1457 | // pthread_cond_timedwait has been observed to return early on |
1458 | // various platforms, so comment out this assert. |
1459 | //assert(Util::currentTime() >= (now + timeout)); |
1460 | @@ -92,23 +92,23 @@ |
1461 | * Waits until the specified timeout in milliseconds for the condition to |
1462 | * occur, or waits forever if timeout_ms == 0. |
1463 | * |
1464 | - * Returns 0 if condition occurs, ETIMEDOUT on timeout, or an error code. |
1465 | + * Returns 0 if condition occurs, THRIFT_ETIMEDOUT on timeout, or an error code. |
1466 | */ |
1467 | int waitForTimeRelative(int64_t timeout_ms) const { |
1468 | if (timeout_ms == 0LL) { |
1469 | return waitForever(); |
1470 | } |
1471 | |
1472 | - struct timespec abstime; |
1473 | + struct THRIFT_TIMESPEC abstime; |
1474 | Util::toTimespec(abstime, Util::currentTime() + timeout_ms); |
1475 | return waitForTime(&abstime); |
1476 | } |
1477 | |
1478 | /** |
1479 | - * Waits until the absolute time specified using struct timespec. |
1480 | - * Returns 0 if condition occurs, ETIMEDOUT on timeout, or an error code. |
1481 | + * Waits until the absolute time specified using struct THRIFT_TIMESPEC. |
1482 | + * Returns 0 if condition occurs, THRIFT_ETIMEDOUT on timeout, or an error code. |
1483 | */ |
1484 | - int waitForTime(const timespec* abstime) const { |
1485 | + int waitForTime(const THRIFT_TIMESPEC* abstime) const { |
1486 | assert(mutex_); |
1487 | pthread_mutex_t* mutexImpl = |
1488 | reinterpret_cast<pthread_mutex_t*>(mutex_->getUnderlyingImpl()); |
1489 | @@ -120,6 +120,12 @@ |
1490 | abstime); |
1491 | } |
1492 | |
1493 | + int waitForTime(const struct timeval* abstime) const { |
1494 | + struct THRIFT_TIMESPEC temp; |
1495 | + temp.tv_sec = abstime->tv_sec; |
1496 | + temp.tv_nsec = abstime->tv_usec * 1000; |
1497 | + return waitForTime(&temp); |
1498 | + } |
1499 | /** |
1500 | * Waits forever until the condition occurs. |
1501 | * Returns 0 if condition occurs, or an error code otherwise. |
1502 | @@ -136,12 +142,14 @@ |
1503 | void notify() { |
1504 | // XXX Need to assert that caller owns mutex |
1505 | int iret = pthread_cond_signal(&pthread_cond_); |
1506 | + THRIFT_UNUSED_VARIABLE(iret); |
1507 | assert(iret == 0); |
1508 | } |
1509 | |
1510 | void notifyAll() { |
1511 | // XXX Need to assert that caller owns mutex |
1512 | int iret = pthread_cond_broadcast(&pthread_cond_); |
1513 | + THRIFT_UNUSED_VARIABLE(iret); |
1514 | assert(iret == 0); |
1515 | } |
1516 | |
1517 | @@ -164,6 +172,7 @@ |
1518 | if (condInitialized_) { |
1519 | condInitialized_ = false; |
1520 | int iret = pthread_cond_destroy(&pthread_cond_); |
1521 | + THRIFT_UNUSED_VARIABLE(iret); |
1522 | assert(iret == 0); |
1523 | } |
1524 | } |
1525 | @@ -189,7 +198,11 @@ |
1526 | |
1527 | void Monitor::wait(int64_t timeout) const { impl_->wait(timeout); } |
1528 | |
1529 | -int Monitor::waitForTime(const timespec* abstime) const { |
1530 | +int Monitor::waitForTime(const THRIFT_TIMESPEC* abstime) const { |
1531 | + return impl_->waitForTime(abstime); |
1532 | +} |
1533 | + |
1534 | +int Monitor::waitForTime(const timeval* abstime) const { |
1535 | return impl_->waitForTime(abstime); |
1536 | } |
1537 | |
1538 | |
1539 | === modified file '3rdParty/libthrift/concurrency/Monitor.h' |
1540 | --- 3rdParty/libthrift/concurrency/Monitor.h 2013-11-21 23:30:15 +0000 |
1541 | +++ 3rdParty/libthrift/concurrency/Monitor.h 2015-02-26 01:00:39 +0000 |
1542 | @@ -20,8 +20,8 @@ |
1543 | #ifndef _THRIFT_CONCURRENCY_MONITOR_H_ |
1544 | #define _THRIFT_CONCURRENCY_MONITOR_H_ 1 |
1545 | |
1546 | -#include "Exception.h" |
1547 | -#include "Mutex.h" |
1548 | +#include <concurrency/Exception.h> |
1549 | +#include <concurrency/Mutex.h> |
1550 | |
1551 | #include <boost/utility.hpp> |
1552 | |
1553 | @@ -70,15 +70,21 @@ |
1554 | * Waits a maximum of the specified timeout in milliseconds for the condition |
1555 | * to occur, or waits forever if timeout_ms == 0. |
1556 | * |
1557 | - * Returns 0 if condition occurs, ETIMEDOUT on timeout, or an error code. |
1558 | + * Returns 0 if condition occurs, THRIFT_ETIMEDOUT on timeout, or an error code. |
1559 | */ |
1560 | int waitForTimeRelative(int64_t timeout_ms) const; |
1561 | |
1562 | /** |
1563 | - * Waits until the absolute time specified using struct timespec. |
1564 | - * Returns 0 if condition occurs, ETIMEDOUT on timeout, or an error code. |
1565 | - */ |
1566 | - int waitForTime(const timespec* abstime) const; |
1567 | + * Waits until the absolute time specified using struct THRIFT_TIMESPEC. |
1568 | + * Returns 0 if condition occurs, THRIFT_ETIMEDOUT on timeout, or an error code. |
1569 | + */ |
1570 | + int waitForTime(const THRIFT_TIMESPEC* abstime) const; |
1571 | + |
1572 | + /** |
1573 | + * Waits until the absolute time specified using struct timeval. |
1574 | + * Returns 0 if condition occurs, THRIFT_ETIMEDOUT on timeout, or an error code. |
1575 | + */ |
1576 | + int waitForTime(const struct timeval* abstime) const; |
1577 | |
1578 | /** |
1579 | * Waits forever until the condition occurs. |
1580 | |
1581 | === modified file '3rdParty/libthrift/concurrency/Mutex.cpp' |
1582 | --- 3rdParty/libthrift/concurrency/Mutex.cpp 2013-11-21 23:30:15 +0000 |
1583 | +++ 3rdParty/libthrift/concurrency/Mutex.cpp 2015-02-26 01:00:39 +0000 |
1584 | @@ -17,58 +17,22 @@ |
1585 | * under the License. |
1586 | */ |
1587 | |
1588 | -#ifdef HAVE_CONFIG_H |
1589 | -#include <config.h> |
1590 | -#endif |
1591 | -#include "Mutex.h" |
1592 | -#include "Util.h" |
1593 | +#include <thrift-config.h> |
1594 | + |
1595 | +#include <Thrift.h> |
1596 | +#include <concurrency/Mutex.h> |
1597 | +#include <concurrency/Util.h> |
1598 | |
1599 | #include <assert.h> |
1600 | #ifdef HAVE_PTHREAD_H |
1601 | #include <pthread.h> |
1602 | -#ifndef PTHREAD_RWLOCK_INITIALIZER |
1603 | -#define __THRIFT_NO_RWLOCKS |
1604 | -#endif |
1605 | #endif |
1606 | #include <signal.h> |
1607 | |
1608 | using boost::shared_ptr; |
1609 | |
1610 | -#ifdef __THRIFT_NO_RWLOCKS |
1611 | -typedef pthread_mutex_t pthread_rwlock_t; |
1612 | -#define pthread_rwlock_init pthread_mutex_init |
1613 | -#define pthread_rwlock_destroy pthread_mutex_destroy |
1614 | -#define pthread_rwlock_rdlock pthread_mutex_lock |
1615 | -#define pthread_rwlock_wrlock pthread_mutex_lock |
1616 | -#define pthread_rwlock_tryrdlock pthread_mutex_trylock |
1617 | -#define pthread_rwlock_trywrlock pthread_mutex_trylock |
1618 | -#define pthread_rwlock_unlock pthread_mutex_unlock |
1619 | -#endif |
1620 | - |
1621 | namespace apache { namespace thrift { namespace concurrency { |
1622 | |
1623 | -#ifndef HAVE_CLOCK_GETTIME |
1624 | - |
1625 | -#define CLOCK_REALTIME 0 |
1626 | - |
1627 | -/** |
1628 | - * Fake clock_gettime for systems like darwin |
1629 | - */ |
1630 | -static int clock_gettime(int clk_id /*ignored*/, struct timespec *tp) { |
1631 | - struct timeval now; |
1632 | - |
1633 | - int rv = gettimeofday(&now, NULL); |
1634 | - if (rv != 0) { |
1635 | - return rv; |
1636 | - } |
1637 | - |
1638 | - tp->tv_sec = now.tv_sec; |
1639 | - tp->tv_nsec = now.tv_usec * 1000; |
1640 | - return 0; |
1641 | -} |
1642 | - |
1643 | -#endif |
1644 | - |
1645 | #ifndef THRIFT_NO_CONTENTION_PROFILING |
1646 | |
1647 | static sig_atomic_t mutexProfilingSampleRate = 0; |
1648 | @@ -163,6 +127,7 @@ |
1649 | if (initialized_) { |
1650 | initialized_ = false; |
1651 | int ret = pthread_mutex_destroy(&pthread_mutex_); |
1652 | + THRIFT_UNUSED_VARIABLE(ret); |
1653 | assert(ret == 0); |
1654 | } |
1655 | } |
1656 | @@ -179,16 +144,9 @@ |
1657 | #if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 200112L |
1658 | PROFILE_MUTEX_START_LOCK(); |
1659 | |
1660 | - struct timespec ts, now; |
1661 | - clock_gettime(CLOCK_REALTIME, &now); |
1662 | - Util::toTimespec(ts, milliseconds); |
1663 | - now.tv_sec += ts.tv_sec; |
1664 | - now.tv_nsec += ts.tv_nsec; |
1665 | - if (now.tv_nsec > 1000000000LL) { |
1666 | - now.tv_sec += 1; |
1667 | - now.tv_nsec -= 1000000000LL; |
1668 | - } |
1669 | - int ret = pthread_mutex_timedlock(&pthread_mutex_, &now); |
1670 | + struct THRIFT_TIMESPEC ts; |
1671 | + Util::toTimespec(ts, milliseconds + Util::currentTime()); |
1672 | + int ret = pthread_mutex_timedlock(&pthread_mutex_, &ts); |
1673 | if (ret == 0) { |
1674 | PROFILE_MUTEX_LOCKED(); |
1675 | return true; |
1676 | @@ -198,24 +156,22 @@ |
1677 | return false; |
1678 | #else |
1679 | /* Otherwise follow solution used by Mono for Android */ |
1680 | - struct timeval was, now; |
1681 | - struct timespec sleepytime, to; |
1682 | + struct THRIFT_TIMESPEC sleepytime, now, to; |
1683 | |
1684 | /* This is just to avoid a completely busy wait */ |
1685 | sleepytime.tv_sec = 0; |
1686 | - sleepytime.tv_nsec = 10000000; /* 10ms */ |
1687 | - |
1688 | - Util::toTimespec(to, milliseconds); |
1689 | - |
1690 | - gettimeofday(&was, NULL); |
1691 | + sleepytime.tv_nsec = 10000000L; /* 10ms */ |
1692 | + |
1693 | + Util::toTimespec(to, milliseconds + Util::currentTime()); |
1694 | + |
1695 | while ((trylock()) == false) { |
1696 | - gettimeofday(&now, NULL); |
1697 | - if (now.tv_sec >= (was.tv_sec + to.tv_sec) && now.tv_usec >= (was.tv_usec + to.tv_nsec / 1000)) { |
1698 | + Util::toTimespec(now, Util::currentTime()); |
1699 | + if (now.tv_sec >= to.tv_sec && now.tv_nsec >= to.tv_nsec) { |
1700 | return false; |
1701 | } |
1702 | nanosleep(&sleepytime, NULL); |
1703 | } |
1704 | - |
1705 | + |
1706 | return true; |
1707 | #endif |
1708 | } |
1709 | @@ -251,6 +207,7 @@ |
1710 | void Mutex::DEFAULT_INITIALIZER(void* arg) { |
1711 | pthread_mutex_t* pthread_mutex = (pthread_mutex_t*)arg; |
1712 | int ret = pthread_mutex_init(pthread_mutex, NULL); |
1713 | + THRIFT_UNUSED_VARIABLE(ret); |
1714 | assert(ret == 0); |
1715 | } |
1716 | |
1717 | @@ -269,6 +226,7 @@ |
1718 | |
1719 | ret = pthread_mutexattr_destroy(&mutexattr); |
1720 | assert(ret == 0); |
1721 | + THRIFT_UNUSED_VARIABLE(ret); |
1722 | } |
1723 | #endif |
1724 | |
1725 | @@ -305,6 +263,7 @@ |
1726 | profileTime_ = 0; |
1727 | #endif |
1728 | int ret = pthread_rwlock_init(&rw_lock_, NULL); |
1729 | + THRIFT_UNUSED_VARIABLE(ret); |
1730 | assert(ret == 0); |
1731 | initialized_ = true; |
1732 | } |
1733 | @@ -313,6 +272,7 @@ |
1734 | if(initialized_) { |
1735 | initialized_ = false; |
1736 | int ret = pthread_rwlock_destroy(&rw_lock_); |
1737 | + THRIFT_UNUSED_VARIABLE(ret); |
1738 | assert(ret == 0); |
1739 | } |
1740 | } |
1741 | @@ -329,9 +289,9 @@ |
1742 | PROFILE_MUTEX_LOCKED(); |
1743 | } |
1744 | |
1745 | - bool attemptRead() const { return pthread_rwlock_tryrdlock(&rw_lock_); } |
1746 | + bool attemptRead() const { return !pthread_rwlock_tryrdlock(&rw_lock_); } |
1747 | |
1748 | - bool attemptWrite() const { return pthread_rwlock_trywrlock(&rw_lock_); } |
1749 | + bool attemptWrite() const { return !pthread_rwlock_trywrlock(&rw_lock_); } |
1750 | |
1751 | void release() const { |
1752 | PROFILE_MUTEX_START_UNLOCK(); |
1753 | @@ -359,5 +319,35 @@ |
1754 | |
1755 | void ReadWriteMutex::release() const { impl_->release(); } |
1756 | |
1757 | +NoStarveReadWriteMutex::NoStarveReadWriteMutex() : writerWaiting_(false) {} |
1758 | + |
1759 | +void NoStarveReadWriteMutex::acquireRead() const |
1760 | +{ |
1761 | + if (writerWaiting_) { |
1762 | + // writer is waiting, block on the writer's mutex until he's done with it |
1763 | + mutex_.lock(); |
1764 | + mutex_.unlock(); |
1765 | + } |
1766 | + |
1767 | + ReadWriteMutex::acquireRead(); |
1768 | +} |
1769 | + |
1770 | +void NoStarveReadWriteMutex::acquireWrite() const |
1771 | +{ |
1772 | + // if we can acquire the rwlock the easy way, we're done |
1773 | + if (attemptWrite()) { |
1774 | + return; |
1775 | + } |
1776 | + |
1777 | + // failed to get the rwlock, do it the hard way: |
1778 | + // locking the mutex and setting writerWaiting will cause all new readers to |
1779 | + // block on the mutex rather than on the rwlock. |
1780 | + mutex_.lock(); |
1781 | + writerWaiting_ = true; |
1782 | + ReadWriteMutex::acquireWrite(); |
1783 | + writerWaiting_ = false; |
1784 | + mutex_.unlock(); |
1785 | +} |
1786 | + |
1787 | }}} // apache::thrift::concurrency |
1788 | |
1789 | |
1790 | === modified file '3rdParty/libthrift/concurrency/Mutex.h' |
1791 | --- 3rdParty/libthrift/concurrency/Mutex.h 2013-11-21 23:30:15 +0000 |
1792 | +++ 3rdParty/libthrift/concurrency/Mutex.h 2015-02-26 01:00:39 +0000 |
1793 | @@ -101,6 +101,25 @@ |
1794 | boost::shared_ptr<impl> impl_; |
1795 | }; |
1796 | |
1797 | +/** |
1798 | + * A ReadWriteMutex that guarantees writers will not be starved by readers: |
1799 | + * When a writer attempts to acquire the mutex, all new readers will be |
1800 | + * blocked from acquiring the mutex until the writer has acquired and |
1801 | + * released it. In some operating systems, this may already be guaranteed |
1802 | + * by a regular ReadWriteMutex. |
1803 | + */ |
1804 | +class NoStarveReadWriteMutex : public ReadWriteMutex { |
1805 | +public: |
1806 | + NoStarveReadWriteMutex(); |
1807 | + |
1808 | + virtual void acquireRead() const; |
1809 | + virtual void acquireWrite() const; |
1810 | + |
1811 | +private: |
1812 | + Mutex mutex_; |
1813 | + mutable volatile bool writerWaiting_; |
1814 | +}; |
1815 | + |
1816 | class Guard : boost::noncopyable { |
1817 | public: |
1818 | Guard(const Mutex& value, int64_t timeout = 0) : mutex_(&value) { |
1819 | @@ -164,15 +183,6 @@ |
1820 | const ReadWriteMutex& rw_mutex_; |
1821 | }; |
1822 | |
1823 | - |
1824 | -// A little hack to prevent someone from trying to do "Guard(m);" |
1825 | -// Such a use is invalid because the temporary Guard object is |
1826 | -// destroyed at the end of the line, releasing the lock. |
1827 | -// Sorry for polluting the global namespace, but I think it's worth it. |
1828 | -#define Guard(m) incorrect_use_of_Guard(m) |
1829 | -#define RWGuard(m) incorrect_use_of_RWGuard(m) |
1830 | - |
1831 | - |
1832 | }}} // apache::thrift::concurrency |
1833 | |
1834 | #endif // #ifndef _THRIFT_CONCURRENCY_MUTEX_H_ |
1835 | |
1836 | === modified file '3rdParty/libthrift/concurrency/PlatformThreadFactory.h' |
1837 | --- 3rdParty/libthrift/concurrency/PlatformThreadFactory.h 2013-11-21 23:30:15 +0000 |
1838 | +++ 3rdParty/libthrift/concurrency/PlatformThreadFactory.h 2015-02-26 01:00:39 +0000 |
1839 | @@ -20,18 +20,23 @@ |
1840 | #ifndef _THRIFT_CONCURRENCY_PLATFORMTHREADFACTORY_H_ |
1841 | #define _THRIFT_CONCURRENCY_PLATFORMTHREADFACTORY_H_ 1 |
1842 | |
1843 | -#ifndef USE_BOOST_THREAD |
1844 | +#include <thrift-config.h> |
1845 | +#if USE_BOOST_THREAD |
1846 | +# include <concurrency/BoostThreadFactory.h> |
1847 | +#elif USE_STD_THREAD |
1848 | +# include <concurrency/StdThreadFactory.h> |
1849 | +#else |
1850 | # include <concurrency/PosixThreadFactory.h> |
1851 | -#else |
1852 | -# include <concurrency/BoostThreadFactory.h> |
1853 | #endif |
1854 | |
1855 | namespace apache { namespace thrift { namespace concurrency { |
1856 | |
1857 | -#ifndef USE_BOOST_THREAD |
1858 | +#ifdef USE_BOOST_THREAD |
1859 | + typedef BoostThreadFactory PlatformThreadFactory; |
1860 | +#elif USE_STD_THREAD |
1861 | + typedef StdThreadFactory PlatformThreadFactory; |
1862 | +#else |
1863 | typedef PosixThreadFactory PlatformThreadFactory; |
1864 | -#else |
1865 | - typedef BoostThreadFactory PlatformThreadFactory; |
1866 | #endif |
1867 | |
1868 | }}} // apache::thrift::concurrency |
1869 | |
1870 | === modified file '3rdParty/libthrift/concurrency/PosixThreadFactory.cpp' |
1871 | --- 3rdParty/libthrift/concurrency/PosixThreadFactory.cpp 2014-02-18 14:04:33 +0000 |
1872 | +++ 3rdParty/libthrift/concurrency/PosixThreadFactory.cpp 2015-02-26 01:00:39 +0000 |
1873 | @@ -17,11 +17,10 @@ |
1874 | * under the License. |
1875 | */ |
1876 | |
1877 | -#ifdef HAVE_CONFIG_H |
1878 | -#include <config.h> |
1879 | -#endif |
1880 | -#include "PosixThreadFactory.h" |
1881 | -#include "Exception.h" |
1882 | +#include <thrift-config.h> |
1883 | + |
1884 | +#include <concurrency/PosixThreadFactory.h> |
1885 | +#include <concurrency/Exception.h> |
1886 | |
1887 | #if GOOGLE_PERFTOOLS_REGISTER_THREAD |
1888 | # include <google/profiler.h> |
1889 | @@ -248,14 +247,8 @@ |
1890 | * into the correpsonding relative priority level (lowest..highest) and |
1891 | * then pro-rate accordingly. |
1892 | */ |
1893 | - static int toPthreadPriority(POLICY |
1894 | -#if defined HAVE_SCHED_GET_PRIORITY_MAX || defined HAVE_SCHED_GET_PRIORITY_MIN |
1895 | - policy |
1896 | -#endif |
1897 | - , PRIORITY priority) { |
1898 | -#if defined HAVE_SCHED_GET_PRIORITY_MAX || defined HAVE_SCHED_GET_PRIORITY_MIN |
1899 | + static int toPthreadPriority(POLICY policy, PRIORITY priority) { |
1900 | int pthread_policy = toPthreadPolicy(policy); |
1901 | -#endif |
1902 | int min_priority = 0; |
1903 | int max_priority = 0; |
1904 | #ifdef HAVE_SCHED_GET_PRIORITY_MIN |
1905 | |
1906 | === modified file '3rdParty/libthrift/concurrency/PosixThreadFactory.h' |
1907 | --- 3rdParty/libthrift/concurrency/PosixThreadFactory.h 2013-11-21 23:30:15 +0000 |
1908 | +++ 3rdParty/libthrift/concurrency/PosixThreadFactory.h 2015-02-26 01:00:39 +0000 |
1909 | @@ -20,7 +20,7 @@ |
1910 | #ifndef _THRIFT_CONCURRENCY_POSIXTHREADFACTORY_H_ |
1911 | #define _THRIFT_CONCURRENCY_POSIXTHREADFACTORY_H_ 1 |
1912 | |
1913 | -#include "Thread.h" |
1914 | +#include <concurrency/Thread.h> |
1915 | |
1916 | #include <boost/shared_ptr.hpp> |
1917 | |
1918 | |
1919 | === added file '3rdParty/libthrift/concurrency/StdMonitor.cpp' |
1920 | --- 3rdParty/libthrift/concurrency/StdMonitor.cpp 1970-01-01 00:00:00 +0000 |
1921 | +++ 3rdParty/libthrift/concurrency/StdMonitor.cpp 2015-02-26 01:00:39 +0000 |
1922 | @@ -0,0 +1,217 @@ |
1923 | +/* |
1924 | + * Licensed to the Apache Software Foundation (ASF) under one |
1925 | + * or more contributor license agreements. See the NOTICE file |
1926 | + * distributed with this work for additional information |
1927 | + * regarding copyright ownership. The ASF licenses this file |
1928 | + * to you under the Apache License, Version 2.0 (the |
1929 | + * "License"); you may not use this file except in compliance |
1930 | + * with the License. You may obtain a copy of the License at |
1931 | + * |
1932 | + * http://www.apache.org/licenses/LICENSE-2.0 |
1933 | + * |
1934 | + * Unless required by applicable law or agreed to in writing, |
1935 | + * software distributed under the License is distributed on an |
1936 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
1937 | + * KIND, either express or implied. See the License for the |
1938 | + * specific language governing permissions and limitations |
1939 | + * under the License. |
1940 | + */ |
1941 | + |
1942 | +#include <thrift/thrift-config.h> |
1943 | + |
1944 | +#include <thrift/concurrency/Monitor.h> |
1945 | +#include <thrift/concurrency/Exception.h> |
1946 | +#include <thrift/concurrency/Util.h> |
1947 | +#include <thrift/transport/PlatformSocket.h> |
1948 | +#include <assert.h> |
1949 | + |
1950 | +#include <condition_variable> |
1951 | +#include <chrono> |
1952 | +#include <thread> |
1953 | +#include <mutex> |
1954 | + |
1955 | +namespace apache { namespace thrift { namespace concurrency { |
1956 | + |
1957 | +/** |
1958 | + * Monitor implementation using the std thread library |
1959 | + * |
1960 | + * @version $Id:$ |
1961 | + */ |
1962 | +class Monitor::Impl { |
1963 | + |
1964 | + public: |
1965 | + |
1966 | + Impl() |
1967 | + : ownedMutex_(new Mutex()), |
1968 | + conditionVariable_(), |
1969 | + mutex_(NULL) { |
1970 | + init(ownedMutex_.get()); |
1971 | + } |
1972 | + |
1973 | + Impl(Mutex* mutex) |
1974 | + : ownedMutex_(), |
1975 | + conditionVariable_(), |
1976 | + mutex_(NULL) { |
1977 | + init(mutex); |
1978 | + } |
1979 | + |
1980 | + Impl(Monitor* monitor) |
1981 | + : ownedMutex_(), |
1982 | + conditionVariable_(), |
1983 | + mutex_(NULL) { |
1984 | + init(&(monitor->mutex())); |
1985 | + } |
1986 | + |
1987 | + Mutex& mutex() { return *mutex_; } |
1988 | + void lock() { mutex_->lock(); } |
1989 | + void unlock() { mutex_->unlock(); } |
1990 | + |
1991 | + /** |
1992 | + * Exception-throwing version of waitForTimeRelative(), called simply |
1993 | + * wait(int64) for historical reasons. Timeout is in milliseconds. |
1994 | + * |
1995 | + * If the condition occurs, this function returns cleanly; on timeout or |
1996 | + * error an exception is thrown. |
1997 | + */ |
1998 | + void wait(int64_t timeout_ms) { |
1999 | + int result = waitForTimeRelative(timeout_ms); |
2000 | + if (result == THRIFT_ETIMEDOUT) { |
2001 | + throw TimedOutException(); |
2002 | + } else if (result != 0) { |
2003 | + throw TException( |
2004 | + "Monitor::wait() failed"); |
2005 | + } |
2006 | + } |
2007 | + |
2008 | + /** |
2009 | + * Waits until the specified timeout in milliseconds for the condition to |
2010 | + * occur, or waits forever if timeout_ms == 0. |
2011 | + * |
2012 | + * Returns 0 if condition occurs, THRIFT_ETIMEDOUT on timeout, or an error code. |
2013 | + */ |
2014 | + int waitForTimeRelative(int64_t timeout_ms) { |
2015 | + if (timeout_ms == 0LL) { |
2016 | + return waitForever(); |
2017 | + } |
2018 | + |
2019 | + assert(mutex_); |
2020 | + std::timed_mutex* mutexImpl = |
2021 | + static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl()); |
2022 | + assert(mutexImpl); |
2023 | + |
2024 | + std::unique_lock<std::timed_mutex> lock(*mutexImpl, std::adopt_lock); |
2025 | + bool timedout = (conditionVariable_.wait_for(lock, std::chrono::milliseconds(timeout_ms)) == std::cv_status::timeout); |
2026 | + lock.release(); |
2027 | + return (timedout ? THRIFT_ETIMEDOUT : 0); |
2028 | + } |
2029 | + |
2030 | + /** |
2031 | + * Waits until the absolute time specified using struct THRIFT_TIMESPEC. |
2032 | + * Returns 0 if condition occurs, THRIFT_ETIMEDOUT on timeout, or an error code. |
2033 | + */ |
2034 | + int waitForTime(const THRIFT_TIMESPEC* abstime) { |
2035 | + struct timeval temp; |
2036 | + temp.tv_sec = static_cast<long>(abstime->tv_sec); |
2037 | + temp.tv_usec = static_cast<long>(abstime->tv_nsec) / 1000; |
2038 | + return waitForTime(&temp); |
2039 | + } |
2040 | + |
2041 | + /** |
2042 | + * Waits until the absolute time specified using struct timeval. |
2043 | + * Returns 0 if condition occurs, THRIFT_ETIMEDOUT on timeout, or an error code. |
2044 | + */ |
2045 | + int waitForTime(const struct timeval* abstime) { |
2046 | + assert(mutex_); |
2047 | + std::timed_mutex* mutexImpl = |
2048 | + static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl()); |
2049 | + assert(mutexImpl); |
2050 | + |
2051 | + struct timeval currenttime; |
2052 | + Util::toTimeval(currenttime, Util::currentTime()); |
2053 | + |
2054 | + long tv_sec = static_cast<long>(abstime->tv_sec - currenttime.tv_sec); |
2055 | + long tv_usec = static_cast<long>(abstime->tv_usec - currenttime.tv_usec); |
2056 | + if(tv_sec < 0) |
2057 | + tv_sec = 0; |
2058 | + if(tv_usec < 0) |
2059 | + tv_usec = 0; |
2060 | + |
2061 | + std::unique_lock<std::timed_mutex> lock(*mutexImpl, std::adopt_lock); |
2062 | + bool timedout = (conditionVariable_.wait_for(lock, |
2063 | + std::chrono::seconds(tv_sec) + |
2064 | + std::chrono::microseconds(tv_usec)) == std::cv_status::timeout); |
2065 | + lock.release(); |
2066 | + return (timedout ? THRIFT_ETIMEDOUT : 0); |
2067 | + } |
2068 | + |
2069 | + /** |
2070 | + * Waits forever until the condition occurs. |
2071 | + * Returns 0 if condition occurs, or an error code otherwise. |
2072 | + */ |
2073 | + int waitForever() { |
2074 | + assert(mutex_); |
2075 | + std::timed_mutex* mutexImpl = |
2076 | + static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl()); |
2077 | + assert(mutexImpl); |
2078 | + |
2079 | + std::unique_lock<std::timed_mutex> lock(*mutexImpl, std::adopt_lock); |
2080 | + conditionVariable_.wait(lock); |
2081 | + lock.release(); |
2082 | + return 0; |
2083 | + } |
2084 | + |
2085 | + |
2086 | + void notify() { |
2087 | + conditionVariable_.notify_one(); |
2088 | + } |
2089 | + |
2090 | + void notifyAll() { |
2091 | + conditionVariable_.notify_all(); |
2092 | + } |
2093 | + |
2094 | + private: |
2095 | + |
2096 | + void init(Mutex* mutex) { |
2097 | + mutex_ = mutex; |
2098 | + } |
2099 | + |
2100 | + const std::unique_ptr<Mutex> ownedMutex_; |
2101 | + std::condition_variable_any conditionVariable_; |
2102 | + Mutex* mutex_; |
2103 | +}; |
2104 | + |
2105 | +Monitor::Monitor() : impl_(new Monitor::Impl()) {} |
2106 | +Monitor::Monitor(Mutex* mutex) : impl_(new Monitor::Impl(mutex)) {} |
2107 | +Monitor::Monitor(Monitor* monitor) : impl_(new Monitor::Impl(monitor)) {} |
2108 | + |
2109 | +Monitor::~Monitor() { delete impl_; } |
2110 | + |
2111 | +Mutex& Monitor::mutex() const { return const_cast<Monitor::Impl*>(impl_)->mutex(); } |
2112 | + |
2113 | +void Monitor::lock() const { const_cast<Monitor::Impl*>(impl_)->lock(); } |
2114 | + |
2115 | +void Monitor::unlock() const { const_cast<Monitor::Impl*>(impl_)->unlock(); } |
2116 | + |
2117 | +void Monitor::wait(int64_t timeout) const { const_cast<Monitor::Impl*>(impl_)->wait(timeout); } |
2118 | + |
2119 | +int Monitor::waitForTime(const THRIFT_TIMESPEC* abstime) const { |
2120 | + return const_cast<Monitor::Impl*>(impl_)->waitForTime(abstime); |
2121 | +} |
2122 | + |
2123 | +int Monitor::waitForTime(const timeval* abstime) const { |
2124 | + return const_cast<Monitor::Impl*>(impl_)->waitForTime(abstime); |
2125 | +} |
2126 | + |
2127 | +int Monitor::waitForTimeRelative(int64_t timeout_ms) const { |
2128 | + return const_cast<Monitor::Impl*>(impl_)->waitForTimeRelative(timeout_ms); |
2129 | +} |
2130 | + |
2131 | +int Monitor::waitForever() const { |
2132 | + return const_cast<Monitor::Impl*>(impl_)->waitForever(); |
2133 | +} |
2134 | + |
2135 | +void Monitor::notify() const { const_cast<Monitor::Impl*>(impl_)->notify(); } |
2136 | + |
2137 | +void Monitor::notifyAll() const { const_cast<Monitor::Impl*>(impl_)->notifyAll(); } |
2138 | + |
2139 | +}}} // apache::thrift::concurrency |
2140 | |
2141 | === added file '3rdParty/libthrift/concurrency/StdMutex.cpp' |
2142 | --- 3rdParty/libthrift/concurrency/StdMutex.cpp 1970-01-01 00:00:00 +0000 |
2143 | +++ 3rdParty/libthrift/concurrency/StdMutex.cpp 2015-02-26 01:00:39 +0000 |
2144 | @@ -0,0 +1,55 @@ |
2145 | +/* |
2146 | + * Licensed to the Apache Software Foundation (ASF) under one |
2147 | + * or more contributor license agreements. See the NOTICE file |
2148 | + * distributed with this work for additional information |
2149 | + * regarding copyright ownership. The ASF licenses this file |
2150 | + * to you under the Apache License, Version 2.0 (the |
2151 | + * "License"); you may not use this file except in compliance |
2152 | + * with the License. You may obtain a copy of the License at |
2153 | + * |
2154 | + * http://www.apache.org/licenses/LICENSE-2.0 |
2155 | + * |
2156 | + * Unless required by applicable law or agreed to in writing, |
2157 | + * software distributed under the License is distributed on an |
2158 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
2159 | + * KIND, either express or implied. See the License for the |
2160 | + * specific language governing permissions and limitations |
2161 | + * under the License. |
2162 | + */ |
2163 | + |
2164 | +#include <thrift/thrift-config.h> |
2165 | + |
2166 | +#include <thrift/concurrency/Mutex.h> |
2167 | +#include <thrift/concurrency/Util.h> |
2168 | + |
2169 | +#include <cassert> |
2170 | +#include <chrono> |
2171 | +#include <mutex> |
2172 | + |
2173 | +namespace apache { namespace thrift { namespace concurrency { |
2174 | + |
2175 | +/** |
2176 | + * Implementation of Mutex class using C++11 std::timed_mutex |
2177 | + * |
2178 | + * @version $Id:$ |
2179 | + */ |
2180 | +class Mutex::impl : public std::timed_mutex { |
2181 | +}; |
2182 | + |
2183 | +Mutex::Mutex(Initializer init) : impl_(new Mutex::impl()) {} |
2184 | + |
2185 | +void* Mutex::getUnderlyingImpl() const { return impl_.get(); } |
2186 | + |
2187 | +void Mutex::lock() const { impl_->lock(); } |
2188 | + |
2189 | +bool Mutex::trylock() const { return impl_->try_lock(); } |
2190 | + |
2191 | +bool Mutex::timedlock(int64_t ms) const { return impl_->try_lock_for(std::chrono::milliseconds(ms)); } |
2192 | + |
2193 | +void Mutex::unlock() const { impl_->unlock(); } |
2194 | + |
2195 | +void Mutex::DEFAULT_INITIALIZER(void* arg) { |
2196 | +} |
2197 | + |
2198 | +}}} // apache::thrift::concurrency |
2199 | + |
2200 | |
2201 | === added file '3rdParty/libthrift/concurrency/StdThreadFactory.cpp' |
2202 | --- 3rdParty/libthrift/concurrency/StdThreadFactory.cpp 1970-01-01 00:00:00 +0000 |
2203 | +++ 3rdParty/libthrift/concurrency/StdThreadFactory.cpp 2015-02-26 01:00:39 +0000 |
2204 | @@ -0,0 +1,175 @@ |
2205 | +/* |
2206 | + * Licensed to the Apache Software Foundation (ASF) under one |
2207 | + * or more contributor license agreements. See the NOTICE file |
2208 | + * distributed with this work for additional information |
2209 | + * regarding copyright ownership. The ASF licenses this file |
2210 | + * to you under the Apache License, Version 2.0 (the |
2211 | + * "License"); you may not use this file except in compliance |
2212 | + * with the License. You may obtain a copy of the License at |
2213 | + * |
2214 | + * http://www.apache.org/licenses/LICENSE-2.0 |
2215 | + * |
2216 | + * Unless required by applicable law or agreed to in writing, |
2217 | + * software distributed under the License is distributed on an |
2218 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
2219 | + * KIND, either express or implied. See the License for the |
2220 | + * specific language governing permissions and limitations |
2221 | + * under the License. |
2222 | + */ |
2223 | + |
2224 | +#include <thrift/thrift-config.h> |
2225 | + |
2226 | +#ifdef USE_STD_THREAD |
2227 | + |
2228 | +#include <thrift/concurrency/StdThreadFactory.h> |
2229 | +#include <thrift/concurrency/Exception.h> |
2230 | + |
2231 | +#include <cassert> |
2232 | + |
2233 | +#include <boost/enable_shared_from_this.hpp> |
2234 | +#include <boost/weak_ptr.hpp> |
2235 | +#include <thread> |
2236 | + |
2237 | +namespace apache { namespace thrift { namespace concurrency { |
2238 | + |
2239 | +/** |
2240 | + * The C++11 thread class. |
2241 | + * |
2242 | + * Note that we use boost shared_ptr rather than std shared_ptrs here |
2243 | + * because the Thread/Runnable classes use those and we don't want to |
2244 | + * mix them. |
2245 | + * |
2246 | + * @version $Id:$ |
2247 | + */ |
2248 | +class StdThread: public Thread, public boost::enable_shared_from_this<StdThread> { |
2249 | + public: |
2250 | + |
2251 | + enum STATE { |
2252 | + uninitialized, |
2253 | + starting, |
2254 | + started, |
2255 | + stopping, |
2256 | + stopped |
2257 | + }; |
2258 | + |
2259 | + static void threadMain(boost::shared_ptr<StdThread> thread); |
2260 | + |
2261 | + private: |
2262 | + std::unique_ptr<std::thread> thread_; |
2263 | + STATE state_; |
2264 | + bool detached_; |
2265 | + |
2266 | + public: |
2267 | + |
2268 | + StdThread(bool detached, boost::shared_ptr<Runnable> runnable) : |
2269 | + state_(uninitialized), |
2270 | + detached_(detached) { |
2271 | + this->Thread::runnable(runnable); |
2272 | + } |
2273 | + |
2274 | + ~StdThread() { |
2275 | + if(!detached_) { |
2276 | + try { |
2277 | + join(); |
2278 | + } catch(...) { |
2279 | + // We're really hosed. |
2280 | + } |
2281 | + } |
2282 | + } |
2283 | + |
2284 | + void start() { |
2285 | + if (state_ != uninitialized) { |
2286 | + return; |
2287 | + } |
2288 | + |
2289 | + boost::shared_ptr<StdThread> selfRef = shared_from_this(); |
2290 | + state_ = starting; |
2291 | + |
2292 | + thread_ = std::unique_ptr<std::thread>(new std::thread(threadMain, selfRef)); |
2293 | + |
2294 | + if(detached_) |
2295 | + thread_->detach(); |
2296 | + } |
2297 | + |
2298 | + void join() { |
2299 | + if (!detached_ && state_ != uninitialized) { |
2300 | + thread_->join(); |
2301 | + } |
2302 | + } |
2303 | + |
2304 | + Thread::id_t getId() { |
2305 | + return thread_.get() ? thread_->get_id() : std::thread::id(); |
2306 | + } |
2307 | + |
2308 | + boost::shared_ptr<Runnable> runnable() const { return Thread::runnable(); } |
2309 | + |
2310 | + void runnable(boost::shared_ptr<Runnable> value) { Thread::runnable(value); } |
2311 | +}; |
2312 | + |
2313 | +void StdThread::threadMain(boost::shared_ptr<StdThread> thread) { |
2314 | + if (thread == NULL) { |
2315 | + return; |
2316 | + } |
2317 | + |
2318 | + if (thread->state_ != starting) { |
2319 | + return; |
2320 | + } |
2321 | + |
2322 | + thread->state_ = started; |
2323 | + thread->runnable()->run(); |
2324 | + |
2325 | + if (thread->state_ != stopping && thread->state_ != stopped) { |
2326 | + thread->state_ = stopping; |
2327 | + } |
2328 | + |
2329 | + return; |
2330 | +} |
2331 | + |
2332 | +/** |
2333 | + * std::thread factory implementation |
2334 | + */ |
2335 | +class StdThreadFactory::Impl { |
2336 | + |
2337 | + private: |
2338 | + bool detached_; |
2339 | + |
2340 | + public: |
2341 | + |
2342 | + Impl(bool detached) : |
2343 | + detached_(detached) {} |
2344 | + |
2345 | + /** |
2346 | + * Creates a new std::thread to run the runnable object |
2347 | + * |
2348 | + * @param runnable A runnable object |
2349 | + */ |
2350 | + boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const { |
2351 | + boost::shared_ptr<StdThread> result = boost::shared_ptr<StdThread>(new StdThread(detached_, runnable)); |
2352 | + runnable->thread(result); |
2353 | + return result; |
2354 | + } |
2355 | + |
2356 | + bool isDetached() const { return detached_; } |
2357 | + |
2358 | + void setDetached(bool value) { detached_ = value; } |
2359 | + |
2360 | + Thread::id_t getCurrentThreadId() const { |
2361 | + return std::this_thread::get_id(); |
2362 | + } |
2363 | + |
2364 | +}; |
2365 | + |
2366 | +StdThreadFactory::StdThreadFactory(bool detached) : |
2367 | + impl_(new StdThreadFactory::Impl(detached)) {} |
2368 | + |
2369 | +boost::shared_ptr<Thread> StdThreadFactory::newThread(boost::shared_ptr<Runnable> runnable) const { return impl_->newThread(runnable); } |
2370 | + |
2371 | +bool StdThreadFactory::isDetached() const { return impl_->isDetached(); } |
2372 | + |
2373 | +void StdThreadFactory::setDetached(bool value) { impl_->setDetached(value); } |
2374 | + |
2375 | +Thread::id_t StdThreadFactory::getCurrentThreadId() const { return impl_->getCurrentThreadId(); } |
2376 | + |
2377 | +}}} // apache::thrift::concurrency |
2378 | + |
2379 | +#endif // USE_STD_THREAD |
2380 | |
2381 | === added file '3rdParty/libthrift/concurrency/StdThreadFactory.h' |
2382 | --- 3rdParty/libthrift/concurrency/StdThreadFactory.h 1970-01-01 00:00:00 +0000 |
2383 | +++ 3rdParty/libthrift/concurrency/StdThreadFactory.h 2015-02-26 01:00:39 +0000 |
2384 | @@ -0,0 +1,72 @@ |
2385 | +/* |
2386 | + * Licensed to the Apache Software Foundation (ASF) under one |
2387 | + * or more contributor license agreements. See the NOTICE file |
2388 | + * distributed with this work for additional information |
2389 | + * regarding copyright ownership. The ASF licenses this file |
2390 | + * to you under the Apache License, Version 2.0 (the |
2391 | + * "License"); you may not use this file except in compliance |
2392 | + * with the License. You may obtain a copy of the License at |
2393 | + * |
2394 | + * http://www.apache.org/licenses/LICENSE-2.0 |
2395 | + * |
2396 | + * Unless required by applicable law or agreed to in writing, |
2397 | + * software distributed under the License is distributed on an |
2398 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
2399 | + * KIND, either express or implied. See the License for the |
2400 | + * specific language governing permissions and limitations |
2401 | + * under the License. |
2402 | + */ |
2403 | + |
2404 | +#ifndef _THRIFT_CONCURRENCY_STDTHREADFACTORY_H_ |
2405 | +#define _THRIFT_CONCURRENCY_STDTHREADFACTORY_H_ 1 |
2406 | + |
2407 | +#include <thrift/concurrency/Thread.h> |
2408 | + |
2409 | +#include <boost/shared_ptr.hpp> |
2410 | + |
2411 | +namespace apache { namespace thrift { namespace concurrency { |
2412 | + |
2413 | +/** |
2414 | + * A thread factory to create std::threads. |
2415 | + * |
2416 | + * @version $Id:$ |
2417 | + */ |
2418 | +class StdThreadFactory : public ThreadFactory { |
2419 | + |
2420 | + public: |
2421 | + |
2422 | + /** |
2423 | + * Std thread factory. All threads created by a factory are reference-counted |
2424 | + * via boost::shared_ptr and boost::weak_ptr. The factory guarantees that threads and |
2425 | + * the Runnable tasks they host will be properly cleaned up once the last strong reference |
2426 | + * to both is given up. |
2427 | + * |
2428 | + * By default threads are not joinable. |
2429 | + */ |
2430 | + |
2431 | + StdThreadFactory(bool detached=true); |
2432 | + |
2433 | + // From ThreadFactory; |
2434 | + boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const; |
2435 | + |
2436 | + // From ThreadFactory; |
2437 | + Thread::id_t getCurrentThreadId() const; |
2438 | + |
2439 | + /** |
2440 | + * Sets detached mode of threads |
2441 | + */ |
2442 | + virtual void setDetached(bool detached); |
2443 | + |
2444 | + /** |
2445 | + * Gets current detached mode |
2446 | + */ |
2447 | + virtual bool isDetached() const; |
2448 | + |
2449 | +private: |
2450 | + class Impl; |
2451 | + boost::shared_ptr<Impl> impl_; |
2452 | +}; |
2453 | + |
2454 | +}}} // apache::thrift::concurrency |
2455 | + |
2456 | +#endif // #ifndef _THRIFT_CONCURRENCY_STDTHREADFACTORY_H_ |
2457 | |
2458 | === modified file '3rdParty/libthrift/concurrency/Thread.h' (properties changed: -x to +x) |
2459 | --- 3rdParty/libthrift/concurrency/Thread.h 2013-11-21 23:30:15 +0000 |
2460 | +++ 3rdParty/libthrift/concurrency/Thread.h 2015-02-26 01:00:39 +0000 |
2461 | @@ -24,16 +24,16 @@ |
2462 | #include <boost/shared_ptr.hpp> |
2463 | #include <boost/weak_ptr.hpp> |
2464 | |
2465 | -#ifdef HAVE_CONFIG_H |
2466 | -#include <config.h> |
2467 | -#endif |
2468 | - |
2469 | -#ifdef USE_BOOST_THREAD |
2470 | -#include <boost/thread.hpp> |
2471 | -#endif |
2472 | - |
2473 | -#ifdef HAVE_PTHREAD_H |
2474 | -#include <pthread.h> |
2475 | +#include <thrift-config.h> |
2476 | + |
2477 | +#if USE_BOOST_THREAD |
2478 | +# include <boost/thread.hpp> |
2479 | +#elif USE_STD_THREAD |
2480 | +# include <thread> |
2481 | +#else |
2482 | +# ifdef HAVE_PTHREAD_H |
2483 | +# include <pthread.h> |
2484 | +# endif |
2485 | #endif |
2486 | |
2487 | namespace apache { namespace thrift { namespace concurrency { |
2488 | @@ -80,13 +80,19 @@ |
2489 | |
2490 | public: |
2491 | |
2492 | -#ifdef USE_BOOST_THREAD |
2493 | +#if USE_BOOST_THREAD |
2494 | typedef boost::thread::id id_t; |
2495 | |
2496 | static inline bool is_current(id_t t) { return t == boost::this_thread::get_id(); } |
2497 | static inline id_t get_current() { return boost::this_thread::get_id(); } |
2498 | +#elif USE_STD_THREAD |
2499 | + typedef std::thread::id id_t; |
2500 | + |
2501 | + static inline bool is_current(id_t t) { return t == std::this_thread::get_id(); } |
2502 | + static inline id_t get_current() { return std::this_thread::get_id(); } |
2503 | #else |
2504 | typedef pthread_t id_t; |
2505 | + |
2506 | static inline bool is_current(id_t t) { return pthread_equal(pthread_self(), t); } |
2507 | static inline id_t get_current() { return pthread_self(); } |
2508 | #endif |
2509 | |
2510 | === modified file '3rdParty/libthrift/concurrency/ThreadManager.cpp' |
2511 | --- 3rdParty/libthrift/concurrency/ThreadManager.cpp 2013-11-21 23:30:15 +0000 |
2512 | +++ 3rdParty/libthrift/concurrency/ThreadManager.cpp 2015-02-26 01:00:39 +0000 |
2513 | @@ -17,14 +17,12 @@ |
2514 | * under the License. |
2515 | */ |
2516 | |
2517 | -#ifdef HAVE_CONFIG_H |
2518 | -#include <config.h> |
2519 | -#endif |
2520 | +#include <thrift-config.h> |
2521 | |
2522 | -#include "ThreadManager.h" |
2523 | -#include "Exception.h" |
2524 | -#include "Monitor.h" |
2525 | -#include "Util.h" |
2526 | +#include <concurrency/ThreadManager.h> |
2527 | +#include <concurrency/Exception.h> |
2528 | +#include <concurrency/Monitor.h> |
2529 | +#include <concurrency/Util.h> |
2530 | |
2531 | #include <boost/shared_ptr.hpp> |
2532 | |
2533 | @@ -310,7 +308,7 @@ |
2534 | } |
2535 | } |
2536 | |
2537 | - if (task != NULL) { |
2538 | + if (task) { |
2539 | if (task->state_ == ThreadManager::Task::EXECUTING) { |
2540 | try { |
2541 | task->run(); |
2542 | @@ -377,7 +375,7 @@ |
2543 | { |
2544 | Synchronized s(monitor_); |
2545 | if (state_ == ThreadManager::UNINITIALIZED) { |
2546 | - if (threadFactory_ == NULL) { |
2547 | + if (!threadFactory_) { |
2548 | throw InvalidArgumentException(); |
2549 | } |
2550 | state_ = ThreadManager::STARTED; |
2551 | @@ -448,8 +446,8 @@ |
2552 | } |
2553 | |
2554 | for (std::set<shared_ptr<Thread> >::iterator ix = deadWorkers_.begin(); ix != deadWorkers_.end(); ix++) { |
2555 | + idMap_.erase((*ix)->getId()); |
2556 | workers_.erase(*ix); |
2557 | - idMap_.erase((*ix)->getId()); |
2558 | } |
2559 | |
2560 | deadWorkers_.clear(); |
2561 | @@ -518,7 +516,7 @@ |
2562 | |
2563 | shared_ptr<ThreadManager::Task> task = tasks_.front(); |
2564 | tasks_.pop(); |
2565 | - |
2566 | + |
2567 | return task->getRunnable(); |
2568 | } |
2569 | |
2570 | @@ -555,8 +553,7 @@ |
2571 | public: |
2572 | SimpleThreadManager(size_t workerCount=4, size_t pendingTaskCountMax=0) : |
2573 | workerCount_(workerCount), |
2574 | - pendingTaskCountMax_(pendingTaskCountMax), |
2575 | - firstTime_(true) { |
2576 | + pendingTaskCountMax_(pendingTaskCountMax) { |
2577 | } |
2578 | |
2579 | void start() { |
2580 | @@ -568,7 +565,6 @@ |
2581 | private: |
2582 | const size_t workerCount_; |
2583 | const size_t pendingTaskCountMax_; |
2584 | - bool firstTime_; |
2585 | Monitor monitor_; |
2586 | }; |
2587 | |
2588 | |
2589 | === modified file '3rdParty/libthrift/concurrency/ThreadManager.h' |
2590 | --- 3rdParty/libthrift/concurrency/ThreadManager.h 2013-11-21 23:30:15 +0000 |
2591 | +++ 3rdParty/libthrift/concurrency/ThreadManager.h 2015-02-26 01:00:39 +0000 |
2592 | @@ -21,9 +21,9 @@ |
2593 | #define _THRIFT_CONCURRENCY_THREADMANAGER_H_ 1 |
2594 | |
2595 | #include <boost/shared_ptr.hpp> |
2596 | -#include <tr1/functional> |
2597 | +#include <cxxfunctional.h> |
2598 | #include <sys/types.h> |
2599 | -#include "Thread.h" |
2600 | +#include <concurrency/Thread.h> |
2601 | |
2602 | namespace apache { namespace thrift { namespace concurrency { |
2603 | |
2604 | @@ -57,8 +57,7 @@ |
2605 | ThreadManager() {} |
2606 | |
2607 | public: |
2608 | - class Task; |
2609 | - typedef std::tr1::function<void(boost::shared_ptr<Runnable>)> ExpireCallback; |
2610 | + typedef apache::thrift::stdcxx::function<void(boost::shared_ptr<Runnable>)> ExpireCallback; |
2611 | |
2612 | virtual ~ThreadManager() {} |
2613 | |
2614 | |
2615 | === modified file '3rdParty/libthrift/concurrency/TimerManager.cpp' |
2616 | --- 3rdParty/libthrift/concurrency/TimerManager.cpp 2013-11-21 23:30:15 +0000 |
2617 | +++ 3rdParty/libthrift/concurrency/TimerManager.cpp 2015-02-26 01:00:39 +0000 |
2618 | @@ -17,9 +17,9 @@ |
2619 | * under the License. |
2620 | */ |
2621 | |
2622 | -#include "TimerManager.h" |
2623 | -#include "Exception.h" |
2624 | -#include "Util.h" |
2625 | +#include <concurrency/TimerManager.h> |
2626 | +#include <concurrency/Exception.h> |
2627 | +#include <concurrency/Util.h> |
2628 | |
2629 | #include <assert.h> |
2630 | #include <iostream> |
2631 | @@ -102,7 +102,7 @@ |
2632 | assert((timeout != 0 && manager_->taskCount_ > 0) || (timeout == 0 && manager_->taskCount_ == 0)); |
2633 | try { |
2634 | manager_->monitor_.wait(timeout); |
2635 | - } catch (TimedOutException &e) {} |
2636 | + } catch (TimedOutException &) {} |
2637 | now = Util::currentTime(); |
2638 | } |
2639 | |
2640 | @@ -140,12 +140,20 @@ |
2641 | friend class TimerManager; |
2642 | }; |
2643 | |
2644 | +#if defined(_MSC_VER) |
2645 | +#pragma warning(push) |
2646 | +#pragma warning(disable: 4355) // 'this' used in base member initializer list |
2647 | +#endif |
2648 | + |
2649 | TimerManager::TimerManager() : |
2650 | taskCount_(0), |
2651 | state_(TimerManager::UNINITIALIZED), |
2652 | dispatcher_(shared_ptr<Dispatcher>(new Dispatcher(this))) { |
2653 | } |
2654 | |
2655 | +#if defined(_MSC_VER) |
2656 | +#pragma warning(pop) |
2657 | +#endif |
2658 | |
2659 | TimerManager::~TimerManager() { |
2660 | |
2661 | @@ -166,7 +174,7 @@ |
2662 | bool doStart = false; |
2663 | { |
2664 | Synchronized s(monitor_); |
2665 | - if (threadFactory_ == NULL) { |
2666 | + if (!threadFactory_) { |
2667 | throw InvalidArgumentException(); |
2668 | } |
2669 | if (state_ == TimerManager::UNINITIALIZED) { |
2670 | @@ -255,20 +263,33 @@ |
2671 | } |
2672 | } |
2673 | |
2674 | -void TimerManager::add(shared_ptr<Runnable> task, const struct timespec& value) { |
2675 | - |
2676 | - int64_t expiration; |
2677 | - Util::toMilliseconds(expiration, value); |
2678 | - |
2679 | - int64_t now = Util::currentTime(); |
2680 | - |
2681 | - if (expiration < now) { |
2682 | - throw InvalidArgumentException(); |
2683 | - } |
2684 | - |
2685 | - add(task, expiration - now); |
2686 | -} |
2687 | - |
2688 | +void TimerManager::add(shared_ptr<Runnable> task, const struct THRIFT_TIMESPEC& value) { |
2689 | + |
2690 | + int64_t expiration; |
2691 | + Util::toMilliseconds(expiration, value); |
2692 | + |
2693 | + int64_t now = Util::currentTime(); |
2694 | + |
2695 | + if (expiration < now) { |
2696 | + throw InvalidArgumentException(); |
2697 | + } |
2698 | + |
2699 | + add(task, expiration - now); |
2700 | +} |
2701 | + |
2702 | +void TimerManager::add(shared_ptr<Runnable> task, const struct timeval& value) { |
2703 | + |
2704 | + int64_t expiration; |
2705 | + Util::toMilliseconds(expiration, value); |
2706 | + |
2707 | + int64_t now = Util::currentTime(); |
2708 | + |
2709 | + if (expiration < now) { |
2710 | + throw InvalidArgumentException(); |
2711 | + } |
2712 | + |
2713 | + add(task, expiration - now); |
2714 | +} |
2715 | |
2716 | void TimerManager::remove(shared_ptr<Runnable> task) { |
2717 | (void) task; |
2718 | |
2719 | === modified file '3rdParty/libthrift/concurrency/TimerManager.h' |
2720 | --- 3rdParty/libthrift/concurrency/TimerManager.h 2013-11-21 23:30:15 +0000 |
2721 | +++ 3rdParty/libthrift/concurrency/TimerManager.h 2015-02-26 01:00:39 +0000 |
2722 | @@ -20,9 +20,9 @@ |
2723 | #ifndef _THRIFT_CONCURRENCY_TIMERMANAGER_H_ |
2724 | #define _THRIFT_CONCURRENCY_TIMERMANAGER_H_ 1 |
2725 | |
2726 | -#include "Exception.h" |
2727 | -#include "Monitor.h" |
2728 | -#include "Thread.h" |
2729 | +#include <concurrency/Exception.h> |
2730 | +#include <concurrency/Monitor.h> |
2731 | +#include <concurrency/Thread.h> |
2732 | |
2733 | #include <boost/shared_ptr.hpp> |
2734 | #include <map> |
2735 | @@ -77,7 +77,15 @@ |
2736 | * @param task The task to execute |
2737 | * @param timeout Absolute time in the future to execute task. |
2738 | */ |
2739 | - virtual void add(boost::shared_ptr<Runnable> task, const struct timespec& timeout); |
2740 | + virtual void add(boost::shared_ptr<Runnable> task, const struct THRIFT_TIMESPEC& timeout); |
2741 | + |
2742 | + /** |
2743 | + * Adds a task to be executed at some time in the future by a worker thread. |
2744 | + * |
2745 | + * @param task The task to execute |
2746 | + * @param timeout Absolute time in the future to execute task. |
2747 | + */ |
2748 | + virtual void add(boost::shared_ptr<Runnable> task, const struct timeval& timeout); |
2749 | |
2750 | /** |
2751 | * Removes a pending task |
2752 | |
2753 | === modified file '3rdParty/libthrift/concurrency/Util.cpp' |
2754 | --- 3rdParty/libthrift/concurrency/Util.cpp 2013-11-21 23:30:15 +0000 |
2755 | +++ 3rdParty/libthrift/concurrency/Util.cpp 2015-02-26 01:00:39 +0000 |
2756 | @@ -17,37 +17,24 @@ |
2757 | * under the License. |
2758 | */ |
2759 | |
2760 | -#ifdef HAVE_CONFIG_H |
2761 | -#include <config.h> |
2762 | +#include <thrift-config.h> |
2763 | + |
2764 | +#include <Thrift.h> |
2765 | +#include <concurrency/Util.h> |
2766 | + |
2767 | +#if defined(HAVE_SYS_TIME_H) |
2768 | +#include <sys/time.h> |
2769 | #endif |
2770 | |
2771 | -#include "Util.h" |
2772 | - |
2773 | -#if defined(HAVE_CLOCK_GETTIME) |
2774 | -#include <time.h> |
2775 | -#elif defined(HAVE_SYS_TIME_H) |
2776 | -#include <sys/time.h> |
2777 | -#endif // defined(HAVE_CLOCK_GETTIME) |
2778 | - |
2779 | namespace apache { namespace thrift { namespace concurrency { |
2780 | |
2781 | int64_t Util::currentTimeTicks(int64_t ticksPerSec) { |
2782 | int64_t result; |
2783 | - |
2784 | -#if defined(HAVE_CLOCK_GETTIME) |
2785 | - struct timespec now; |
2786 | - int ret = clock_gettime(CLOCK_REALTIME, &now); |
2787 | - assert(ret == 0); |
2788 | - toTicks(result, now, ticksPerSec); |
2789 | -#elif defined(HAVE_GETTIMEOFDAY) |
2790 | struct timeval now; |
2791 | - int ret = gettimeofday(&now, NULL); |
2792 | + int ret = THRIFT_GETTIMEOFDAY(&now, NULL); |
2793 | assert(ret == 0); |
2794 | + THRIFT_UNUSED_VARIABLE(ret); //squelching "unused variable" warning |
2795 | toTicks(result, now, ticksPerSec); |
2796 | -#else |
2797 | -#error "No high-precision clock is available." |
2798 | -#endif // defined(HAVE_CLOCK_GETTIME) |
2799 | - |
2800 | return result; |
2801 | } |
2802 | |
2803 | |
2804 | === modified file '3rdParty/libthrift/concurrency/Util.h' |
2805 | --- 3rdParty/libthrift/concurrency/Util.h 2013-11-21 23:30:15 +0000 |
2806 | +++ 3rdParty/libthrift/concurrency/Util.h 2015-02-26 01:00:39 +0000 |
2807 | @@ -29,6 +29,8 @@ |
2808 | #include <sys/time.h> |
2809 | #endif |
2810 | |
2811 | +#include <transport/PlatformSocket.h> |
2812 | + |
2813 | namespace apache { namespace thrift { namespace concurrency { |
2814 | |
2815 | /** |
2816 | @@ -56,23 +58,23 @@ |
2817 | public: |
2818 | |
2819 | /** |
2820 | - * Converts millisecond timestamp into a timespec struct |
2821 | + * Converts millisecond timestamp into a THRIFT_TIMESPEC struct |
2822 | * |
2823 | - * @param struct timespec& result |
2824 | + * @param struct THRIFT_TIMESPEC& result |
2825 | * @param time or duration in milliseconds |
2826 | */ |
2827 | - static void toTimespec(struct timespec& result, int64_t value) { |
2828 | + static void toTimespec(struct THRIFT_TIMESPEC& result, int64_t value) { |
2829 | result.tv_sec = value / MS_PER_S; // ms to s |
2830 | result.tv_nsec = (value % MS_PER_S) * NS_PER_MS; // ms to ns |
2831 | } |
2832 | |
2833 | static void toTimeval(struct timeval& result, int64_t value) { |
2834 | - result.tv_sec = value / MS_PER_S; // ms to s |
2835 | - result.tv_usec = (value % MS_PER_S) * US_PER_MS; // ms to us |
2836 | + result.tv_sec = static_cast<uint32_t>(value / MS_PER_S); // ms to s |
2837 | + result.tv_usec = static_cast<uint32_t>((value % MS_PER_S) * US_PER_MS); // ms to us |
2838 | } |
2839 | |
2840 | static void toTicks(int64_t& result, int64_t secs, int64_t oldTicks, |
2841 | - int64_t oldTicksPerSec, int64_t newTicksPerSec) { |
2842 | + int64_t oldTicksPerSec, int64_t newTicksPerSec) { |
2843 | result = secs * newTicksPerSec; |
2844 | result += oldTicks * newTicksPerSec / oldTicksPerSec; |
2845 | |
2846 | @@ -82,11 +84,11 @@ |
2847 | } |
2848 | } |
2849 | /** |
2850 | - * Converts struct timespec to arbitrary-sized ticks since epoch |
2851 | + * Converts struct THRIFT_TIMESPEC to arbitrary-sized ticks since epoch |
2852 | */ |
2853 | static void toTicks(int64_t& result, |
2854 | - const struct timespec& value, |
2855 | - int64_t ticksPerSec) { |
2856 | + const struct THRIFT_TIMESPEC& value, |
2857 | + int64_t ticksPerSec) { |
2858 | return toTicks(result, value.tv_sec, value.tv_nsec, NS_PER_S, ticksPerSec); |
2859 | } |
2860 | |
2861 | @@ -94,16 +96,16 @@ |
2862 | * Converts struct timeval to arbitrary-sized ticks since epoch |
2863 | */ |
2864 | static void toTicks(int64_t& result, |
2865 | - const struct timeval& value, |
2866 | - int64_t ticksPerSec) { |
2867 | + const struct timeval& value, |
2868 | + int64_t ticksPerSec) { |
2869 | return toTicks(result, value.tv_sec, value.tv_usec, US_PER_S, ticksPerSec); |
2870 | } |
2871 | |
2872 | /** |
2873 | - * Converts struct timespec to milliseconds |
2874 | + * Converts struct THRIFT_TIMESPEC to milliseconds |
2875 | */ |
2876 | static void toMilliseconds(int64_t& result, |
2877 | - const struct timespec& value) { |
2878 | + const struct THRIFT_TIMESPEC& value) { |
2879 | return toTicks(result, value, MS_PER_S); |
2880 | } |
2881 | |
2882 | @@ -111,14 +113,14 @@ |
2883 | * Converts struct timeval to milliseconds |
2884 | */ |
2885 | static void toMilliseconds(int64_t& result, |
2886 | - const struct timeval& value) { |
2887 | + const struct timeval& value) { |
2888 | return toTicks(result, value, MS_PER_S); |
2889 | } |
2890 | |
2891 | /** |
2892 | - * Converts struct timespec to microseconds |
2893 | + * Converts struct THRIFT_TIMESPEC to microseconds |
2894 | */ |
2895 | - static void toUsec(int64_t& result, const struct timespec& value) { |
2896 | + static void toUsec(int64_t& result, const struct THRIFT_TIMESPEC& value) { |
2897 | return toTicks(result, value, US_PER_S); |
2898 | } |
2899 | |
2900 | |
2901 | === modified file '3rdParty/libthrift/config.h' |
2902 | --- 3rdParty/libthrift/config.h 2013-11-21 23:30:15 +0000 |
2903 | +++ 3rdParty/libthrift/config.h 2015-02-26 01:00:39 +0000 |
2904 | @@ -2,7 +2,7 @@ |
2905 | * Android NDK r7 compatible configuration. |
2906 | */ |
2907 | |
2908 | -#define VERSION "0.8.0-arm" |
2909 | +#define VERSION "0.9.2" |
2910 | |
2911 | #define HAVE_UNISTD_H |
2912 | #define HAVE_INTTYPES_H |
2913 | |
2914 | === added file '3rdParty/libthrift/cxxfunctional.h' |
2915 | --- 3rdParty/libthrift/cxxfunctional.h 1970-01-01 00:00:00 +0000 |
2916 | +++ 3rdParty/libthrift/cxxfunctional.h 2015-02-26 01:00:39 +0000 |
2917 | @@ -0,0 +1,126 @@ |
2918 | +/* |
2919 | + * Licensed to the Apache Software Foundation (ASF) under one |
2920 | + * or more contributor license agreements. See the NOTICE file |
2921 | + * distributed with this work for additional information |
2922 | + * regarding copyright ownership. The ASF licenses this file |
2923 | + * to you under the Apache License, Version 2.0 (the |
2924 | + * "License"); you may not use this file except in compliance |
2925 | + * with the License. You may obtain a copy of the License at |
2926 | + * |
2927 | + * http://www.apache.org/licenses/LICENSE-2.0 |
2928 | + * |
2929 | + * Unless required by applicable law or agreed to in writing, |
2930 | + * software distributed under the License is distributed on an |
2931 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
2932 | + * KIND, either express or implied. See the License for the |
2933 | + * specific language governing permissions and limitations |
2934 | + * under the License. |
2935 | + */ |
2936 | + |
2937 | +#ifndef _THRIFT_CXXFUNCTIONAL_H_ |
2938 | +#define _THRIFT_CXXFUNCTIONAL_H_ 1 |
2939 | + |
2940 | +/** |
2941 | + * Loads <functional> from the 'right' location, depending |
2942 | + * on compiler and whether or not it's using C++03 with TR1 |
2943 | + * or C++11. |
2944 | + */ |
2945 | + |
2946 | +/* |
2947 | + * MSVC 10 and 11 have the <functional> stuff at <functional>. |
2948 | + * In MSVC 10 all of the implementations live in std::tr1. |
2949 | + * In MSVC 11 all of the implementations live in std, with aliases |
2950 | + * in std::tr1 to point to the ones in std. |
2951 | + */ |
2952 | +#ifdef _WIN32 |
2953 | + #define _THRIFT_USING_MICROSOFT_STDLIB 1 |
2954 | +#endif |
2955 | + |
2956 | +#ifdef __clang__ |
2957 | + /* Clang has two options, depending on standard library: |
2958 | + * - no -stdlib or -stdlib=libstdc++ set; uses GNU libstdc++. |
2959 | + * <tr1/functional> |
2960 | + * - -stdlib=libc++; uses LLVM libc++. |
2961 | + * <functional>, no 'std::tr1'. |
2962 | + * |
2963 | + * The compiler itself doesn't define anything differently |
2964 | + * depending on the value of -stdlib, but the library headers |
2965 | + * will set different preprocessor options. In order to check, |
2966 | + * though, we have to pull in some library header. |
2967 | + */ |
2968 | + #include <utility> |
2969 | + |
2970 | + /* With LLVM libc++, utility pulls in __config, which sets |
2971 | + _LIBCPP_VERSION. */ |
2972 | + #if defined(_LIBCPP_VERSION) |
2973 | + #define _THRIFT_USING_CLANG_LIBCXX 1 |
2974 | + |
2975 | + /* With GNU libstdc++, utility pulls in bits/c++config.h, |
2976 | + which sets __GLIBCXX__. */ |
2977 | + #elif defined(__GLIBCXX__) |
2978 | + #define _THRIFT_USING_GNU_LIBSTDCXX 1 |
2979 | + |
2980 | + /* No idea. */ |
2981 | + #else |
2982 | + #error Unable to detect which C++ standard library is in use. |
2983 | + #endif |
2984 | +#elif __GNUC__ |
2985 | + #define _THRIFT_USING_GNU_LIBSTDCXX 1 |
2986 | +#endif |
2987 | + |
2988 | +#if _THRIFT_USING_MICROSOFT_STDLIB |
2989 | + #include <functional> |
2990 | + |
2991 | + namespace apache { namespace thrift { namespace stdcxx { |
2992 | + using ::std::tr1::function; |
2993 | + using ::std::tr1::bind; |
2994 | + |
2995 | + namespace placeholders { |
2996 | + using ::std::tr1::placeholders::_1; |
2997 | + using ::std::tr1::placeholders::_2; |
2998 | + using ::std::tr1::placeholders::_3; |
2999 | + using ::std::tr1::placeholders::_4; |
3000 | + using ::std::tr1::placeholders::_5; |
3001 | + using ::std::tr1::placeholders::_6; |
3002 | + } // apache::thrift::stdcxx::placeholders |
3003 | + }}} // apache::thrift::stdcxx |
3004 | + |
3005 | +#elif _THRIFT_USING_CLANG_LIBCXX |
3006 | + #include <functional> |
3007 | + |
3008 | + namespace apache { namespace thrift { namespace stdcxx { |
3009 | + using ::std::function; |
3010 | + using ::std::bind; |
3011 | + |
3012 | + namespace placeholders { |
3013 | + using ::std::placeholders::_1; |
3014 | + using ::std::placeholders::_2; |
3015 | + using ::std::placeholders::_3; |
3016 | + using ::std::placeholders::_4; |
3017 | + using ::std::placeholders::_5; |
3018 | + using ::std::placeholders::_6; |
3019 | + } // apache::thrift::stdcxx::placeholders |
3020 | + }}} // apache::thrift::stdcxx |
3021 | + |
3022 | +#elif _THRIFT_USING_GNU_LIBSTDCXX |
3023 | + #include <tr1/functional> |
3024 | + |
3025 | + namespace apache { namespace thrift { namespace stdcxx { |
3026 | + using ::std::tr1::function; |
3027 | + using ::std::tr1::bind; |
3028 | + |
3029 | + namespace placeholders { |
3030 | + using ::std::tr1::placeholders::_1; |
3031 | + using ::std::tr1::placeholders::_2; |
3032 | + using ::std::tr1::placeholders::_3; |
3033 | + using ::std::tr1::placeholders::_4; |
3034 | + using ::std::tr1::placeholders::_5; |
3035 | + using ::std::tr1::placeholders::_6; |
3036 | + } // apache::thrift::stdcxx::placeholders |
3037 | + }}} // apache::thrift::stdcxx |
3038 | +#endif |
3039 | + |
3040 | + // Alias for thrift c++ compatibility namespace |
3041 | + namespace tcxx = apache::thrift::stdcxx; |
3042 | + |
3043 | +#endif // #ifndef _THRIFT_CXXFUNCTIONAL_H_ |
3044 | |
3045 | === removed directory '3rdParty/libthrift/jni' |
3046 | === removed file '3rdParty/libthrift/jni/Android.mk' |
3047 | --- 3rdParty/libthrift/jni/Android.mk 2013-11-21 23:30:15 +0000 |
3048 | +++ 3rdParty/libthrift/jni/Android.mk 1970-01-01 00:00:00 +0000 |
3049 | @@ -1,98 +0,0 @@ |
3050 | -# |
3051 | -# Thrift 0.8.0 static and shared C++ libraries |
3052 | -# |
3053 | - |
3054 | -LOCAL_PATH := $(call my-dir) |
3055 | -SRC_PATH := .. |
3056 | -INCLUDE_PATH := $(LOCAL_PATH)/.. |
3057 | - |
3058 | -THRIFT_FILENAME := libthrift |
3059 | -THRIFT_CPPFLAGS := -DHAVE_CONFIG_H -D__GLIBC__ |
3060 | - |
3061 | -ifeq ($(BOOST_ROOT),) |
3062 | -BOOST_ROOT := $(INCLUDE_PATH)/../boost |
3063 | -endif |
3064 | - |
3065 | -THRIFT_SRC_FILES := \ |
3066 | - $(SRC_PATH)/Thrift.cpp \ |
3067 | - $(SRC_PATH)/VirtualProfiling.cpp \ |
3068 | - $(SRC_PATH)/TApplicationException.cpp \ |
3069 | - $(SRC_PATH)/async/TAsyncChannel.cpp \ |
3070 | - $(SRC_PATH)/async/TAsyncProtocolProcessor.cpp \ |
3071 | - $(SRC_PATH)/processor/PeekProcessor.cpp \ |
3072 | - $(SRC_PATH)/transport/TSocket.cpp \ |
3073 | - $(SRC_PATH)/transport/TTransportException.cpp \ |
3074 | - $(SRC_PATH)/transport/TZlibTransport.cpp \ |
3075 | - $(SRC_PATH)/transport/TSocketPool.cpp \ |
3076 | - $(SRC_PATH)/transport/TServerSocket.cpp \ |
3077 | - $(SRC_PATH)/transport/THttpClient.cpp \ |
3078 | - $(SRC_PATH)/transport/TTransportUtils.cpp \ |
3079 | - $(SRC_PATH)/transport/THttpTransport.cpp \ |
3080 | - $(SRC_PATH)/transport/TBufferTransports.cpp \ |
3081 | - $(SRC_PATH)/transport/TFileTransport.cpp \ |
3082 | - $(SRC_PATH)/transport/TSimpleFileTransport.cpp \ |
3083 | - $(SRC_PATH)/transport/THttpServer.cpp \ |
3084 | - $(SRC_PATH)/transport/TFDTransport.cpp \ |
3085 | - $(SRC_PATH)/concurrency/Util.cpp \ |
3086 | - $(SRC_PATH)/concurrency/PosixThreadFactory.cpp \ |
3087 | - $(SRC_PATH)/concurrency/TimerManager.cpp \ |
3088 | - $(SRC_PATH)/concurrency/Mutex.cpp \ |
3089 | - $(SRC_PATH)/concurrency/ThreadManager.cpp \ |
3090 | - $(SRC_PATH)/concurrency/Monitor.cpp \ |
3091 | - $(SRC_PATH)/server/TThreadPoolServer.cpp \ |
3092 | - $(SRC_PATH)/server/TServer.cpp \ |
3093 | - $(SRC_PATH)/server/TThreadedServer.cpp \ |
3094 | - $(SRC_PATH)/server/TSimpleServer.cpp \ |
3095 | - $(SRC_PATH)/protocol/TDebugProtocol.cpp \ |
3096 | - $(SRC_PATH)/protocol/TDenseProtocol.cpp \ |
3097 | - $(SRC_PATH)/protocol/TJSONProtocol.cpp \ |
3098 | - $(SRC_PATH)/protocol/TBase64Utils.cpp \ |
3099 | - |
3100 | - # not supported yet |
3101 | - # async/TEvhttpServer.cpp \ |
3102 | - # async/TEvhttpClientChannel.cpp \ |
3103 | - # transport/TSSLSocket.cpp \ |
3104 | - # transport/TSSLServerSocket.cpp \ |
3105 | - # server/TNonblockingServer.cpp \ |
3106 | - |
3107 | -# |
3108 | -# Shared library directives |
3109 | -# |
3110 | - |
3111 | -include $(CLEAR_VARS) |
3112 | - |
3113 | -LOCAL_MODULE := thrift_shared |
3114 | - |
3115 | -LOCAL_C_INCLUDES := $(INCLUDE_PATH) $(BOOST_ROOT) |
3116 | - |
3117 | -LOCAL_MODULE_FILENAME := $(THRIFT_FILENAME) |
3118 | -LOCAL_CPPFLAGS := $(THRIFT_CPPFLAGS) |
3119 | -LOCAL_SRC_FILES := $(THRIFT_SRC_FILES) |
3120 | - |
3121 | -LOCAL_LDLIBS := -lz |
3122 | - |
3123 | -LOCAL_EXPORT_C_INCLUDES := $(INCLUDE_PATH) |
3124 | -LOCAL_EXPORT_CPPFLAGS := $(THRIFT_CPPFLAGS) |
3125 | - |
3126 | -include $(BUILD_SHARED_LIBRARY) |
3127 | - |
3128 | -# |
3129 | -# Static library directives |
3130 | -# |
3131 | - |
3132 | -include $(CLEAR_VARS) |
3133 | - |
3134 | -LOCAL_MODULE := thrift_static |
3135 | - |
3136 | -LOCAL_C_INCLUDES := $(INCLUDE_PATH) $(BOOST_ROOT) |
3137 | - |
3138 | -LOCAL_MODULE_FILENAME := $(THRIFT_FILENAME) |
3139 | -LOCAL_CPPFLAGS := $(THRIFT_CPPFLAGS) |
3140 | -LOCAL_SRC_FILES := $(THRIFT_SRC_FILES) |
3141 | - |
3142 | -LOCAL_LDLIBS := -lz |
3143 | - |
3144 | -LOCAL_EXPORT_C_INCLUDES := $(INCLUDE_PATH) |
3145 | -LOCAL_EXPORT_CPPFLAGS := $(THRIFT_CPPFLAGS) |
3146 | - |
3147 | -include $(BUILD_STATIC_LIBRARY) |
3148 | |
3149 | === removed file '3rdParty/libthrift/jni/Application.mk' |
3150 | --- 3rdParty/libthrift/jni/Application.mk 2013-11-21 23:30:15 +0000 |
3151 | +++ 3rdParty/libthrift/jni/Application.mk 1970-01-01 00:00:00 +0000 |
3152 | @@ -1,7 +0,0 @@ |
3153 | -APP_MODULES := thrift_shared thrift_static |
3154 | -APP_PLATFORM := android-8 |
3155 | -APP_ABI := all |
3156 | -APP_STL := gnustl_static |
3157 | -APP_OPTIM := debug |
3158 | - |
3159 | -APP_CPPFLAGS := -fexceptions -frtti |
3160 | \ No newline at end of file |
3161 | |
3162 | === removed file '3rdParty/libthrift/jni/shared.mk' |
3163 | --- 3rdParty/libthrift/jni/shared.mk 2013-11-21 23:30:15 +0000 |
3164 | +++ 3rdParty/libthrift/jni/shared.mk 1970-01-01 00:00:00 +0000 |
3165 | @@ -1,17 +0,0 @@ |
3166 | -# |
3167 | -# Thrift 0.8.0 prebuilt shared C++ librariy |
3168 | -# |
3169 | - |
3170 | -__WAS_PATH := $(LOCAL_PATH) |
3171 | -LOCAL_PATH := $(call my-dir) |
3172 | - |
3173 | -include $(CLEAR_VARS) |
3174 | - |
3175 | -LOCAL_MODULE := thrift_prebuilt_shared |
3176 | -LOCAL_SRC_FILES := ../lib/$(TARGET_ARCH_ABI)/libthrift.so |
3177 | -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. |
3178 | -LOCAL_EXPORT_CPPFLAGS := -DHAVE_CONFIG_H -D__GLIBC__ |
3179 | - |
3180 | -include $(PREBUILT_SHARED_LIBRARY) |
3181 | - |
3182 | -LOCAL_PATH := $(__WAS_PATH) |
3183 | |
3184 | === removed file '3rdParty/libthrift/jni/static.mk' |
3185 | --- 3rdParty/libthrift/jni/static.mk 2013-11-21 23:30:15 +0000 |
3186 | +++ 3rdParty/libthrift/jni/static.mk 1970-01-01 00:00:00 +0000 |
3187 | @@ -1,17 +0,0 @@ |
3188 | -# |
3189 | -# Thrift 0.8.0 prebuilt static C++ library |
3190 | -# |
3191 | - |
3192 | -__WAS_PATH := $(LOCAL_PATH) |
3193 | -LOCAL_PATH := $(call my-dir) |
3194 | - |
3195 | -include $(CLEAR_VARS) |
3196 | - |
3197 | -LOCAL_MODULE := thrift_prebuilt_static |
3198 | -LOCAL_SRC_FILES := ../obj/local/$(TARGET_ARCH_ABI)/libthrift.a |
3199 | -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. |
3200 | -LOCAL_EXPORT_CPPFLAGS := -DHAVE_CONFIG_H -D__GLIBC__ |
3201 | - |
3202 | -include $(PREBUILT_STATIC_LIBRARY) |
3203 | - |
3204 | -LOCAL_PATH := $(__WAS_PATH) |
3205 | |
3206 | === modified file '3rdParty/libthrift/processor/PeekProcessor.cpp' |
3207 | --- 3rdParty/libthrift/processor/PeekProcessor.cpp 2013-11-21 23:30:15 +0000 |
3208 | +++ 3rdParty/libthrift/processor/PeekProcessor.cpp 2015-02-26 01:00:39 +0000 |
3209 | @@ -17,7 +17,7 @@ |
3210 | * under the License. |
3211 | */ |
3212 | |
3213 | -#include "PeekProcessor.h" |
3214 | +#include <thrift/processor/PeekProcessor.h> |
3215 | |
3216 | using namespace apache::thrift::transport; |
3217 | using namespace apache::thrift::protocol; |
3218 | @@ -66,7 +66,7 @@ |
3219 | int32_t seqid; |
3220 | in->readMessageBegin(fname, mtype, seqid); |
3221 | |
3222 | - if (mtype != T_CALL) { |
3223 | + if (mtype != T_CALL && mtype != T_ONEWAY) { |
3224 | throw TException("Unexpected message type"); |
3225 | } |
3226 | |
3227 | |
3228 | === modified file '3rdParty/libthrift/processor/PeekProcessor.h' |
3229 | --- 3rdParty/libthrift/processor/PeekProcessor.h 2013-11-21 23:30:15 +0000 |
3230 | +++ 3rdParty/libthrift/processor/PeekProcessor.h 2015-02-26 01:00:39 +0000 |
3231 | @@ -21,10 +21,10 @@ |
3232 | #define PEEKPROCESSOR_H |
3233 | |
3234 | #include <string> |
3235 | -#include <TProcessor.h> |
3236 | -#include <transport/TTransport.h> |
3237 | -#include <transport/TTransportUtils.h> |
3238 | -#include <transport/TBufferTransports.h> |
3239 | +#include <thrift/TProcessor.h> |
3240 | +#include <thrift/transport/TTransport.h> |
3241 | +#include <thrift/transport/TTransportUtils.h> |
3242 | +#include <thrift/transport/TBufferTransports.h> |
3243 | #include <boost/shared_ptr.hpp> |
3244 | |
3245 | namespace apache { namespace thrift { namespace processor { |
3246 | |
3247 | === modified file '3rdParty/libthrift/processor/StatsProcessor.h' |
3248 | --- 3rdParty/libthrift/processor/StatsProcessor.h 2013-11-21 23:30:15 +0000 |
3249 | +++ 3rdParty/libthrift/processor/StatsProcessor.h 2015-02-26 01:00:39 +0000 |
3250 | @@ -21,8 +21,8 @@ |
3251 | #define STATSPROCESSOR_H |
3252 | |
3253 | #include <boost/shared_ptr.hpp> |
3254 | -#include <transport/TTransport.h> |
3255 | -#include <protocol/TProtocol.h> |
3256 | +#include <thrift/transport/TTransport.h> |
3257 | +#include <thrift/protocol/TProtocol.h> |
3258 | #include <TProcessor.h> |
3259 | |
3260 | namespace apache { namespace thrift { namespace processor { |
3261 | @@ -50,7 +50,7 @@ |
3262 | int32_t seqid; |
3263 | |
3264 | piprot_->readMessageBegin(fname, mtype, seqid); |
3265 | - if (mtype != apache::thrift::protocol::T_CALL) { |
3266 | + if (mtype != apache::thrift::protocol::T_CALL && mtype != apache::thrift::protocol::T_ONEWAY) { |
3267 | if (print_) { |
3268 | printf("Unknown message type\n"); |
3269 | } |
3270 | |
3271 | === added file '3rdParty/libthrift/processor/TMultiplexedProcessor.h' |
3272 | --- 3rdParty/libthrift/processor/TMultiplexedProcessor.h 1970-01-01 00:00:00 +0000 |
3273 | +++ 3rdParty/libthrift/processor/TMultiplexedProcessor.h 2015-02-26 01:00:39 +0000 |
3274 | @@ -0,0 +1,218 @@ |
3275 | +/* |
3276 | + * Licensed to the Apache Software Foundation (ASF) under one |
3277 | + * or more contributor license agreements. See the NOTICE file |
3278 | + * distributed with this work for additional information |
3279 | + * regarding copyright ownership. The ASF licenses this file |
3280 | + * to you under the Apache License, Version 2.0 (the |
3281 | + * "License"); you may not use this file except in compliance |
3282 | + * with the License. You may obtain a copy of the License at |
3283 | + * |
3284 | + * http://www.apache.org/licenses/LICENSE-2.0 |
3285 | + * |
3286 | + * Unless required by applicable law or agreed to in writing, |
3287 | + * software distributed under the License is distributed on an |
3288 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
3289 | + * KIND, either express or implied. See the License for the |
3290 | + * specific language governing permissions and limitations |
3291 | + * under the License. |
3292 | + */ |
3293 | + |
3294 | +#ifndef THRIFT_TMULTIPLEXEDPROCESSOR_H_ |
3295 | +#define THRIFT_TMULTIPLEXEDPROCESSOR_H_ 1 |
3296 | + |
3297 | +#include <thrift/protocol/TProtocolDecorator.h> |
3298 | +#include <thrift/TApplicationException.h> |
3299 | +#include <thrift/TProcessor.h> |
3300 | +#include <boost/tokenizer.hpp> |
3301 | + |
3302 | +namespace apache |
3303 | +{ |
3304 | + namespace thrift |
3305 | + { |
3306 | + using boost::shared_ptr; |
3307 | + |
3308 | + namespace protocol { |
3309 | + |
3310 | + /** |
3311 | + * To be able to work with any protocol, we needed |
3312 | + * to allow them to call readMessageBegin() and get a TMessage in exactly |
3313 | + * the standard format, without the service name prepended to TMessage.name. |
3314 | + */ |
3315 | + class StoredMessageProtocol : public TProtocolDecorator |
3316 | + { |
3317 | + public: |
3318 | + StoredMessageProtocol( shared_ptr<protocol::TProtocol> _protocol, |
3319 | + const std::string& _name, const TMessageType _type, |
3320 | + const int32_t _seqid) : |
3321 | + TProtocolDecorator(_protocol), |
3322 | + name(_name), |
3323 | + type(_type), |
3324 | + seqid(_seqid) |
3325 | + { |
3326 | + } |
3327 | + |
3328 | + uint32_t readMessageBegin_virt(std::string& _name, TMessageType& _type, int32_t& _seqid) |
3329 | + { |
3330 | + |
3331 | + _name = name; |
3332 | + _type = type; |
3333 | + _seqid = seqid; |
3334 | + |
3335 | + return 0; // (Normal TProtocol read functions return number of bytes read) |
3336 | + } |
3337 | + |
3338 | + std::string name; |
3339 | + TMessageType type; |
3340 | + int32_t seqid; |
3341 | + }; |
3342 | + } //namespace protocol |
3343 | + |
3344 | + /** |
3345 | + * <code>TMultiplexedProcessor</code> is a <code>TProcessor</code> allowing |
3346 | + * a single <code>TServer</code> to provide multiple services. |
3347 | + * |
3348 | + * <p>To do so, you instantiate the processor and then register additional |
3349 | + * processors with it, as shown in the following example:</p> |
3350 | + * |
3351 | + * <blockquote><code> |
3352 | + * shared_ptr<TMultiplexedProcessor> processor(new TMultiplexedProcessor()); |
3353 | + * |
3354 | + * processor->registerProcessor( |
3355 | + * "Calculator", |
3356 | + * shared_ptr<TProcessor>( new CalculatorProcessor( |
3357 | + * shared_ptr<CalculatorHandler>( new CalculatorHandler())))); |
3358 | + * |
3359 | + * processor->registerProcessor( |
3360 | + * "WeatherReport", |
3361 | + * shared_ptr<TProcessor>( new WeatherReportProcessor( |
3362 | + * shared_ptr<WeatherReportHandler>( new WeatherReportHandler())))); |
3363 | + * |
3364 | + * shared_ptr<TServerTransport> transport(new TServerSocket(9090)); |
3365 | + * TSimpleServer server(processor, transport); |
3366 | + * |
3367 | + * server.serve(); |
3368 | + * </code></blockquote> |
3369 | + */ |
3370 | + class TMultiplexedProcessor : public TProcessor |
3371 | + { |
3372 | + public: |
3373 | + typedef std::map< std::string, shared_ptr<TProcessor> > services_t; |
3374 | + |
3375 | + /** |
3376 | + * 'Register' a service with this <code>TMultiplexedProcessor</code>. This |
3377 | + * allows us to broker requests to individual services by using the service |
3378 | + * name to select them at request time. |
3379 | + * |
3380 | + * \param [in] serviceName Name of a service, has to be identical to the name |
3381 | + * declared in the Thrift IDL, e.g. "WeatherReport". |
3382 | + * \param [in] processor Implementation of a service, ususally referred to |
3383 | + * as "handlers", e.g. WeatherReportHandler, |
3384 | + * implementing WeatherReportIf interface. |
3385 | + */ |
3386 | + void registerProcessor( const std::string & serviceName, |
3387 | + shared_ptr<TProcessor> processor ) |
3388 | + { |
3389 | + services[serviceName] = processor; |
3390 | + } |
3391 | + |
3392 | + /** |
3393 | + * This implementation of <code>process</code> performs the following steps: |
3394 | + * |
3395 | + * <ol> |
3396 | + * <li>Read the beginning of the message.</li> |
3397 | + * <li>Extract the service name from the message.</li> |
3398 | + * <li>Using the service name to locate the appropriate processor.</li> |
3399 | + * <li>Dispatch to the processor, with a decorated instance of TProtocol |
3400 | + * that allows readMessageBegin() to return the original TMessage.</li> |
3401 | + * </ol> |
3402 | + * |
3403 | + * \throws TException If the message type is not T_CALL or T_ONEWAY, if |
3404 | + * the service name was not found in the message, or if the service |
3405 | + * name was not found in the service map. |
3406 | + */ |
3407 | + bool process( shared_ptr<protocol::TProtocol> in, |
3408 | + shared_ptr<protocol::TProtocol> out, |
3409 | + void *connectionContext) |
3410 | + { |
3411 | + std::string name; |
3412 | + protocol::TMessageType type; |
3413 | + int32_t seqid; |
3414 | + |
3415 | + // Use the actual underlying protocol (e.g. TBinaryProtocol) to read the |
3416 | + // message header. This pulls the message "off the wire", which we'll |
3417 | + // deal with at the end of this method. |
3418 | + in->readMessageBegin(name, type, seqid); |
3419 | + |
3420 | + if( type != protocol::T_CALL && type != protocol::T_ONEWAY ) { |
3421 | + // Unexpected message type. |
3422 | + in->skip(::apache::thrift::protocol::T_STRUCT); |
3423 | + in->readMessageEnd(); |
3424 | + in->getTransport()->readEnd(); |
3425 | + const std::string msg("TMultiplexedProcessor: Unexpected message type"); |
3426 | + ::apache::thrift::TApplicationException x( |
3427 | + ::apache::thrift::TApplicationException::PROTOCOL_ERROR, |
3428 | + msg); |
3429 | + out->writeMessageBegin(name, ::apache::thrift::protocol::T_EXCEPTION, seqid); |
3430 | + x.write(out.get()); |
3431 | + out->writeMessageEnd(); |
3432 | + out->getTransport()->writeEnd(); |
3433 | + out->getTransport()->flush(); |
3434 | + throw TException(msg); |
3435 | + } |
3436 | + |
3437 | + // Extract the service name |
3438 | + |
3439 | + boost::tokenizer<boost::char_separator<char> > tok( name, boost::char_separator<char>(":") ); |
3440 | + |
3441 | + std::vector<std::string> tokens; |
3442 | + std::copy( tok.begin(), tok.end(), std::back_inserter(tokens) ); |
3443 | + |
3444 | + // A valid message should consist of two tokens: the service |
3445 | + // name and the name of the method to call. |
3446 | + if( tokens.size() == 2 ) |
3447 | + { |
3448 | + // Search for a processor associated with this service name. |
3449 | + services_t::iterator it = services.find(tokens[0]); |
3450 | + |
3451 | + if( it != services.end() ) |
3452 | + { |
3453 | + shared_ptr<TProcessor> processor = it->second; |
3454 | + // Let the processor registered for this service name |
3455 | + // process the message. |
3456 | + return processor->process( |
3457 | + shared_ptr<protocol::TProtocol>( |
3458 | + new protocol::StoredMessageProtocol( in, tokens[1], type, seqid ) ), |
3459 | + out, connectionContext ); |
3460 | + } |
3461 | + else |
3462 | + { |
3463 | + // Unknown service. |
3464 | + in->skip(::apache::thrift::protocol::T_STRUCT); |
3465 | + in->readMessageEnd(); |
3466 | + in->getTransport()->readEnd(); |
3467 | + |
3468 | + std::string msg("TMultiplexedProcessor: Unknown service: "); |
3469 | + msg += tokens[0]; |
3470 | + ::apache::thrift::TApplicationException x( |
3471 | + ::apache::thrift::TApplicationException::PROTOCOL_ERROR, |
3472 | + msg); |
3473 | + out->writeMessageBegin(name, ::apache::thrift::protocol::T_EXCEPTION, seqid); |
3474 | + x.write(out.get()); |
3475 | + out->writeMessageEnd(); |
3476 | + out->getTransport()->writeEnd(); |
3477 | + out->getTransport()->flush(); |
3478 | + msg += ". Did you forget to call registerProcessor()?"; |
3479 | + throw TException(msg); |
3480 | + } |
3481 | + } |
3482 | + return false; |
3483 | + } |
3484 | + |
3485 | + private: |
3486 | + /** Map of service processor objects, indexed by service names. */ |
3487 | + services_t services; |
3488 | + }; |
3489 | + } |
3490 | +} |
3491 | + |
3492 | +#endif // THRIFT_TMULTIPLEXEDPROCESSOR_H_ |
3493 | |
3494 | === modified file '3rdParty/libthrift/protocol/TBase64Utils.cpp' |
3495 | --- 3rdParty/libthrift/protocol/TBase64Utils.cpp 2013-11-21 23:30:15 +0000 |
3496 | +++ 3rdParty/libthrift/protocol/TBase64Utils.cpp 2015-02-26 01:00:39 +0000 |
3497 | @@ -17,7 +17,7 @@ |
3498 | * under the License. |
3499 | */ |
3500 | |
3501 | -#include "TBase64Utils.h" |
3502 | +#include <thrift/protocol/TBase64Utils.h> |
3503 | |
3504 | #include <boost/static_assert.hpp> |
3505 | |
3506 | @@ -30,36 +30,36 @@ |
3507 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
3508 | |
3509 | void base64_encode(const uint8_t *in, uint32_t len, uint8_t *buf) { |
3510 | - buf[0] = kBase64EncodeTable[(in[0] >> 2) & 0x3F]; |
3511 | + buf[0] = kBase64EncodeTable[(in[0] >> 2) & 0x3f]; |
3512 | if (len == 3) { |
3513 | - buf[1] = kBase64EncodeTable[((in[0] << 4) + (in[1] >> 4)) & 0x3f]; |
3514 | - buf[2] = kBase64EncodeTable[((in[1] << 2) + (in[2] >> 6)) & 0x3f]; |
3515 | + buf[1] = kBase64EncodeTable[((in[0] << 4) & 0x30) | ((in[1] >> 4) & 0x0f)]; |
3516 | + buf[2] = kBase64EncodeTable[((in[1] << 2) & 0x3c) | ((in[2] >> 6) & 0x03)]; |
3517 | buf[3] = kBase64EncodeTable[in[2] & 0x3f]; |
3518 | } else if (len == 2) { |
3519 | - buf[1] = kBase64EncodeTable[((in[0] << 4) + (in[1] >> 4)) & 0x3f]; |
3520 | - buf[2] = kBase64EncodeTable[(in[1] << 2) & 0x3f]; |
3521 | + buf[1] = kBase64EncodeTable[((in[0] << 4) & 0x30) | ((in[1] >> 4) & 0x0f)]; |
3522 | + buf[2] = kBase64EncodeTable[(in[1] << 2) & 0x3c]; |
3523 | } else { // len == 1 |
3524 | - buf[1] = kBase64EncodeTable[(in[0] << 4) & 0x3f]; |
3525 | + buf[1] = kBase64EncodeTable[(in[0] << 4) & 0x30]; |
3526 | } |
3527 | } |
3528 | |
3529 | static const uint8_t kBase64DecodeTable[256] ={ |
3530 | - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
3531 | - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
3532 | - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, |
3533 | - 52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1, |
3534 | - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, |
3535 | - 15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1, |
3536 | - -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, |
3537 | - 41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1, |
3538 | - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
3539 | - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
3540 | - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
3541 | - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
3542 | - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
3543 | - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
3544 | - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
3545 | - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, |
3546 | +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
3547 | +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
3548 | +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3e,0xff,0xff,0xff,0x3f, |
3549 | +0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0xff,0xff,0xff,0xff,0xff,0xff, |
3550 | +0xff,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e, |
3551 | +0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0xff,0xff,0xff,0xff,0xff, |
3552 | +0xff,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28, |
3553 | +0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0xff,0xff,0xff,0xff,0xff, |
3554 | +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
3555 | +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
3556 | +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
3557 | +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
3558 | +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
3559 | +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
3560 | +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
3561 | +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, |
3562 | }; |
3563 | |
3564 | void base64_decode(uint8_t *buf, uint32_t len) { |
3565 | |
3566 | === modified file '3rdParty/libthrift/protocol/TBinaryProtocol.h' |
3567 | --- 3rdParty/libthrift/protocol/TBinaryProtocol.h 2013-11-21 23:30:15 +0000 |
3568 | +++ 3rdParty/libthrift/protocol/TBinaryProtocol.h 2015-02-26 01:00:39 +0000 |
3569 | @@ -20,8 +20,8 @@ |
3570 | #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_ |
3571 | #define _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_ 1 |
3572 | |
3573 | -#include "TProtocol.h" |
3574 | -#include "TVirtualProtocol.h" |
3575 | +#include <protocol/TProtocol.h> |
3576 | +#include <protocol/TVirtualProtocol.h> |
3577 | |
3578 | #include <boost/shared_ptr.hpp> |
3579 | |
3580 | @@ -134,7 +134,8 @@ |
3581 | |
3582 | inline uint32_t writeDouble(const double dub); |
3583 | |
3584 | - inline uint32_t writeString(const std::string& str); |
3585 | + template <typename StrType> |
3586 | + inline uint32_t writeString(const StrType& str); |
3587 | |
3588 | inline uint32_t writeBinary(const std::string& str); |
3589 | |
3590 | @@ -187,12 +188,14 @@ |
3591 | |
3592 | inline uint32_t readDouble(double& dub); |
3593 | |
3594 | - inline uint32_t readString(std::string& str); |
3595 | + template<typename StrType> |
3596 | + inline uint32_t readString(StrType& str); |
3597 | |
3598 | inline uint32_t readBinary(std::string& str); |
3599 | |
3600 | protected: |
3601 | - uint32_t readStringBody(std::string& str, int32_t sz); |
3602 | + template<typename StrType> |
3603 | + uint32_t readStringBody(StrType& str, int32_t sz); |
3604 | |
3605 | Transport_* trans_; |
3606 | |
3607 | @@ -274,6 +277,6 @@ |
3608 | |
3609 | }}} // apache::thrift::protocol |
3610 | |
3611 | -#include "TBinaryProtocol.tcc" |
3612 | +#include <protocol/TBinaryProtocol.tcc> |
3613 | |
3614 | #endif // #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_ |
3615 | |
3616 | === modified file '3rdParty/libthrift/protocol/TBinaryProtocol.tcc' |
3617 | --- 3rdParty/libthrift/protocol/TBinaryProtocol.tcc 2013-11-21 23:30:15 +0000 |
3618 | +++ 3rdParty/libthrift/protocol/TBinaryProtocol.tcc 2015-02-26 01:00:39 +0000 |
3619 | @@ -20,7 +20,7 @@ |
3620 | #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_TCC_ |
3621 | #define _THRIFT_PROTOCOL_TBINARYPROTOCOL_TCC_ 1 |
3622 | |
3623 | -#include "TBinaryProtocol.h" |
3624 | +#include <protocol/TBinaryProtocol.h> |
3625 | |
3626 | #include <limits> |
3627 | |
3628 | @@ -176,8 +176,11 @@ |
3629 | |
3630 | |
3631 | template <class Transport_> |
3632 | -uint32_t TBinaryProtocolT<Transport_>::writeString(const std::string& str) { |
3633 | - uint32_t size = str.size(); |
3634 | +template<typename StrType> |
3635 | +uint32_t TBinaryProtocolT<Transport_>::writeString(const StrType& str) { |
3636 | + if(str.size() > static_cast<size_t>((std::numeric_limits<int32_t>::max)())) |
3637 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
3638 | + uint32_t size = static_cast<uint32_t>(str.size()); |
3639 | uint32_t result = writeI32((int32_t)size); |
3640 | if (size > 0) { |
3641 | this->trans_->write((uint8_t*)str.data(), size); |
3642 | @@ -401,7 +404,8 @@ |
3643 | } |
3644 | |
3645 | template <class Transport_> |
3646 | -uint32_t TBinaryProtocolT<Transport_>::readString(std::string& str) { |
3647 | +template<typename StrType> |
3648 | +uint32_t TBinaryProtocolT<Transport_>::readString(StrType& str) { |
3649 | uint32_t result; |
3650 | int32_t size; |
3651 | result = readI32(size); |
3652 | @@ -414,7 +418,8 @@ |
3653 | } |
3654 | |
3655 | template <class Transport_> |
3656 | -uint32_t TBinaryProtocolT<Transport_>::readStringBody(std::string& str, |
3657 | +template<typename StrType> |
3658 | +uint32_t TBinaryProtocolT<Transport_>::readStringBody(StrType& str, |
3659 | int32_t size) { |
3660 | uint32_t result = 0; |
3661 | |
3662 | @@ -441,17 +446,8 @@ |
3663 | return size; |
3664 | } |
3665 | |
3666 | - // Use the heap here to prevent stack overflow for v. large strings |
3667 | - if (size > this->string_buf_size_ || this->string_buf_ == NULL) { |
3668 | - void* new_string_buf = std::realloc(this->string_buf_, (uint32_t)size); |
3669 | - if (new_string_buf == NULL) { |
3670 | - throw std::bad_alloc(); |
3671 | - } |
3672 | - this->string_buf_ = (uint8_t*)new_string_buf; |
3673 | - this->string_buf_size_ = size; |
3674 | - } |
3675 | - this->trans_->readAll(this->string_buf_, size); |
3676 | - str.assign((char*)this->string_buf_, size); |
3677 | + str.resize(size); |
3678 | + this->trans_->readAll(reinterpret_cast<uint8_t *>(&str[0]), size); |
3679 | return (uint32_t)size; |
3680 | } |
3681 | |
3682 | |
3683 | === modified file '3rdParty/libthrift/protocol/TCompactProtocol.h' |
3684 | --- 3rdParty/libthrift/protocol/TCompactProtocol.h 2013-11-21 23:30:15 +0000 |
3685 | +++ 3rdParty/libthrift/protocol/TCompactProtocol.h 2015-02-26 01:00:39 +0000 |
3686 | @@ -20,7 +20,7 @@ |
3687 | #ifndef _THRIFT_PROTOCOL_TCOMPACTPROTOCOL_H_ |
3688 | #define _THRIFT_PROTOCOL_TCOMPACTPROTOCOL_H_ 1 |
3689 | |
3690 | -#include "TVirtualProtocol.h" |
3691 | +#include <thrift/protocol/TVirtualProtocol.h> |
3692 | |
3693 | #include <stack> |
3694 | #include <boost/shared_ptr.hpp> |
3695 | @@ -35,10 +35,11 @@ |
3696 | : public TVirtualProtocol< TCompactProtocolT<Transport_> > { |
3697 | |
3698 | protected: |
3699 | - static const int8_t PROTOCOL_ID = (int8_t)0x82; |
3700 | + static const int8_t PROTOCOL_ID = (int8_t)0x82u; |
3701 | static const int8_t VERSION_N = 1; |
3702 | static const int8_t VERSION_MASK = 0x1f; // 0001 1111 |
3703 | - static const int8_t TYPE_MASK = (int8_t)0xE0; // 1110 0000 |
3704 | + static const int8_t TYPE_MASK = (int8_t)0xE0u; // 1110 0000 |
3705 | + static const int8_t TYPE_BITS = 0x07; // 0000 0111 |
3706 | static const int32_t TYPE_SHIFT_AMOUNT = 5; |
3707 | |
3708 | Transport_* trans_; |
3709 | @@ -161,12 +162,12 @@ |
3710 | const TType fieldType, |
3711 | const int16_t fieldId, |
3712 | int8_t typeOverride); |
3713 | - uint32_t writeCollectionBegin(int8_t elemType, int32_t size); |
3714 | + uint32_t writeCollectionBegin(const TType elemType, int32_t size); |
3715 | uint32_t writeVarint32(uint32_t n); |
3716 | uint32_t writeVarint64(uint64_t n); |
3717 | uint64_t i64ToZigzag(const int64_t l); |
3718 | uint32_t i32ToZigzag(const int32_t n); |
3719 | - inline int8_t getCompactType(int8_t ttype); |
3720 | + inline int8_t getCompactType(const TType ttype); |
3721 | |
3722 | public: |
3723 | uint32_t readMessageBegin(std::string& name, |
3724 | @@ -284,6 +285,6 @@ |
3725 | |
3726 | }}} // apache::thrift::protocol |
3727 | |
3728 | -#include "TCompactProtocol.tcc" |
3729 | +#include <thrift/protocol/TCompactProtocol.tcc> |
3730 | |
3731 | #endif |
3732 | |
3733 | === modified file '3rdParty/libthrift/protocol/TCompactProtocol.tcc' |
3734 | --- 3rdParty/libthrift/protocol/TCompactProtocol.tcc 2013-11-21 23:30:15 +0000 |
3735 | +++ 3rdParty/libthrift/protocol/TCompactProtocol.tcc 2015-02-26 01:00:39 +0000 |
3736 | @@ -198,16 +198,20 @@ |
3737 | |
3738 | if (booleanField_.name != NULL) { |
3739 | // we haven't written the field header yet |
3740 | - wsize += writeFieldBeginInternal(booleanField_.name, |
3741 | - booleanField_.fieldType, |
3742 | - booleanField_.fieldId, |
3743 | - value ? detail::compact::CT_BOOLEAN_TRUE : |
3744 | - detail::compact::CT_BOOLEAN_FALSE); |
3745 | + wsize |
3746 | + += writeFieldBeginInternal(booleanField_.name, |
3747 | + booleanField_.fieldType, |
3748 | + booleanField_.fieldId, |
3749 | + static_cast<int8_t>(value |
3750 | + ? detail::compact::CT_BOOLEAN_TRUE |
3751 | + : detail::compact::CT_BOOLEAN_FALSE)); |
3752 | booleanField_.name = NULL; |
3753 | } else { |
3754 | // we're not part of a field, so just write the value |
3755 | - wsize += writeByte(value ? detail::compact::CT_BOOLEAN_TRUE : |
3756 | - detail::compact::CT_BOOLEAN_FALSE); |
3757 | + wsize |
3758 | + += writeByte(static_cast<int8_t>(value |
3759 | + ? detail::compact::CT_BOOLEAN_TRUE |
3760 | + : detail::compact::CT_BOOLEAN_FALSE)); |
3761 | } |
3762 | return wsize; |
3763 | } |
3764 | @@ -266,8 +270,15 @@ |
3765 | |
3766 | template <class Transport_> |
3767 | uint32_t TCompactProtocolT<Transport_>::writeBinary(const std::string& str) { |
3768 | - uint32_t ssize = str.size(); |
3769 | - uint32_t wsize = writeVarint32(ssize) + ssize; |
3770 | + if(str.size() > (std::numeric_limits<uint32_t>::max)()) |
3771 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
3772 | + uint32_t ssize = static_cast<uint32_t>(str.size()); |
3773 | + uint32_t wsize = writeVarint32(ssize) ; |
3774 | + // checking ssize + wsize > uint_max, but we don't want to overflow while checking for overflows. |
3775 | + // transforming the check to ssize > uint_max - wsize |
3776 | + if(ssize > (std::numeric_limits<uint32_t>::max)() - wsize) |
3777 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
3778 | + wsize += ssize; |
3779 | trans_->write((uint8_t*)str.data(), ssize); |
3780 | return wsize; |
3781 | } |
3782 | @@ -296,7 +307,8 @@ |
3783 | // check if we can use delta encoding for the field id |
3784 | if (fieldId > lastFieldId_ && fieldId - lastFieldId_ <= 15) { |
3785 | // write them together |
3786 | - wsize += writeByte((fieldId - lastFieldId_) << 4 | typeToWrite); |
3787 | + wsize += writeByte(static_cast<int8_t>((fieldId - lastFieldId_) |
3788 | + << 4 | typeToWrite)); |
3789 | } else { |
3790 | // write them separate |
3791 | wsize += writeByte(typeToWrite); |
3792 | @@ -312,11 +324,12 @@ |
3793 | * the wire differ only by the type indicator. |
3794 | */ |
3795 | template <class Transport_> |
3796 | -uint32_t TCompactProtocolT<Transport_>::writeCollectionBegin(int8_t elemType, |
3797 | +uint32_t TCompactProtocolT<Transport_>::writeCollectionBegin(const TType elemType, |
3798 | int32_t size) { |
3799 | uint32_t wsize = 0; |
3800 | if (size <= 14) { |
3801 | - wsize += writeByte(size << 4 | getCompactType(elemType)); |
3802 | + wsize += writeByte(static_cast<int8_t>(size |
3803 | + << 4 | getCompactType(elemType))); |
3804 | } else { |
3805 | wsize += writeByte(0xf0 | getCompactType(elemType)); |
3806 | wsize += writeVarint32(size); |
3807 | @@ -388,7 +401,7 @@ |
3808 | * Given a TType value, find the appropriate detail::compact::Types value |
3809 | */ |
3810 | template <class Transport_> |
3811 | -int8_t TCompactProtocolT<Transport_>::getCompactType(int8_t ttype) { |
3812 | +int8_t TCompactProtocolT<Transport_>::getCompactType(const TType ttype) { |
3813 | return detail::compact::TTypeToCType[ttype]; |
3814 | } |
3815 | |
3816 | @@ -420,7 +433,7 @@ |
3817 | throw TProtocolException(TProtocolException::BAD_VERSION, "Bad protocol version"); |
3818 | } |
3819 | |
3820 | - messageType = (TMessageType)((versionAndType >> TYPE_SHIFT_AMOUNT) & 0x03); |
3821 | + messageType = (TMessageType)((versionAndType >> TYPE_SHIFT_AMOUNT) & TYPE_BITS); |
3822 | rsize += readVarint32(seqid); |
3823 | rsize += readString(name); |
3824 | |
3825 | @@ -641,12 +654,13 @@ |
3826 | BOOST_STATIC_ASSERT(sizeof(double) == sizeof(uint64_t)); |
3827 | BOOST_STATIC_ASSERT(std::numeric_limits<double>::is_iec559); |
3828 | |
3829 | - uint64_t bits; |
3830 | - uint8_t b[8]; |
3831 | - trans_->readAll(b, 8); |
3832 | - bits = *(uint64_t*)b; |
3833 | - bits = letohll(bits); |
3834 | - dub = bitwise_cast<double>(bits); |
3835 | + union { |
3836 | + uint64_t bits; |
3837 | + uint8_t b[8]; |
3838 | + } u; |
3839 | + trans_->readAll(u.b, 8); |
3840 | + u.bits = letohll(u.bits); |
3841 | + dub = bitwise_cast<double>(u.bits); |
3842 | return 8; |
3843 | } |
3844 | |
3845 | @@ -761,7 +775,7 @@ |
3846 | */ |
3847 | template <class Transport_> |
3848 | int32_t TCompactProtocolT<Transport_>::zigzagToI32(uint32_t n) { |
3849 | - return (n >> 1) ^ -(n & 1); |
3850 | + return (n >> 1) ^ static_cast<uint32_t>(-static_cast<int32_t>(n & 1)); |
3851 | } |
3852 | |
3853 | /** |
3854 | @@ -769,7 +783,7 @@ |
3855 | */ |
3856 | template <class Transport_> |
3857 | int64_t TCompactProtocolT<Transport_>::zigzagToI64(uint64_t n) { |
3858 | - return (n >> 1) ^ -(n & 1); |
3859 | + return (n >> 1) ^ static_cast<uint64_t>(-static_cast<int64_t>(n & 1)); |
3860 | } |
3861 | |
3862 | template <class Transport_> |
3863 | @@ -801,9 +815,8 @@ |
3864 | case detail::compact::CT_STRUCT: |
3865 | return T_STRUCT; |
3866 | default: |
3867 | - throw TException("don't know what type: " + type); |
3868 | + throw TException(std::string("don't know what type: ") + (char)type); |
3869 | } |
3870 | - return T_STOP; |
3871 | } |
3872 | |
3873 | }}} // apache::thrift::protocol |
3874 | |
3875 | === modified file '3rdParty/libthrift/protocol/TDebugProtocol.cpp' |
3876 | --- 3rdParty/libthrift/protocol/TDebugProtocol.cpp 2013-11-21 23:30:15 +0000 |
3877 | +++ 3rdParty/libthrift/protocol/TDebugProtocol.cpp 2015-02-26 01:00:39 +0000 |
3878 | @@ -17,7 +17,7 @@ |
3879 | * under the License. |
3880 | */ |
3881 | |
3882 | -#include "TDebugProtocol.h" |
3883 | +#include <thrift/protocol/TDebugProtocol.h> |
3884 | |
3885 | #include <cassert> |
3886 | #include <cctype> |
3887 | @@ -32,6 +32,7 @@ |
3888 | static string byte_to_hex(const uint8_t byte) { |
3889 | char buf[3]; |
3890 | int ret = std::sprintf(buf, "%02x", (int)byte); |
3891 | + THRIFT_UNUSED_VARIABLE(ret); |
3892 | assert(ret == 2); |
3893 | assert(buf[2] == '\0'); |
3894 | return buf; |
3895 | @@ -74,14 +75,23 @@ |
3896 | } |
3897 | |
3898 | uint32_t TDebugProtocol::writePlain(const string& str) { |
3899 | - trans_->write((uint8_t*)str.data(), str.length()); |
3900 | - return str.length(); |
3901 | + if(str.length() > (std::numeric_limits<uint32_t>::max)()) |
3902 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
3903 | + trans_->write((uint8_t*)str.data(), static_cast<uint32_t>(str.length())); |
3904 | + return static_cast<uint32_t>(str.length()); |
3905 | } |
3906 | |
3907 | uint32_t TDebugProtocol::writeIndented(const string& str) { |
3908 | - trans_->write((uint8_t*)indent_str_.data(), indent_str_.length()); |
3909 | - trans_->write((uint8_t*)str.data(), str.length()); |
3910 | - return indent_str_.length() + str.length(); |
3911 | + if(str.length() > (std::numeric_limits<uint32_t>::max)()) |
3912 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
3913 | + if(indent_str_.length() > (std::numeric_limits<uint32_t>::max)()) |
3914 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
3915 | + uint64_t total_len = indent_str_.length() + str.length(); |
3916 | + if(total_len > (std::numeric_limits<uint32_t>::max)()) |
3917 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
3918 | + trans_->write((uint8_t*)indent_str_.data(), static_cast<uint32_t>(indent_str_.length())); |
3919 | + trans_->write((uint8_t*)str.data(), static_cast<uint32_t>(str.length())); |
3920 | + return static_cast<uint32_t>(indent_str_.length() + str.length()); |
3921 | } |
3922 | |
3923 | uint32_t TDebugProtocol::startItem() { |
3924 | |
3925 | === modified file '3rdParty/libthrift/protocol/TDebugProtocol.h' |
3926 | --- 3rdParty/libthrift/protocol/TDebugProtocol.h 2013-11-21 23:30:15 +0000 |
3927 | +++ 3rdParty/libthrift/protocol/TDebugProtocol.h 2015-02-26 01:00:39 +0000 |
3928 | @@ -20,7 +20,7 @@ |
3929 | #ifndef _THRIFT_PROTOCOL_TDEBUGPROTOCOL_H_ |
3930 | #define _THRIFT_PROTOCOL_TDEBUGPROTOCOL_H_ 1 |
3931 | |
3932 | -#include "TVirtualProtocol.h" |
3933 | +#include <thrift/protocol/TVirtualProtocol.h> |
3934 | |
3935 | #include <boost/shared_ptr.hpp> |
3936 | |
3937 | @@ -171,7 +171,7 @@ |
3938 | |
3939 | |
3940 | // TODO(dreiss): Move (part of) ThriftDebugString into a .cpp file and remove this. |
3941 | -#include <transport/TBufferTransports.h> |
3942 | +#include <thrift/transport/TBufferTransports.h> |
3943 | |
3944 | namespace apache { namespace thrift { |
3945 | |
3946 | |
3947 | === modified file '3rdParty/libthrift/protocol/TDenseProtocol.cpp' |
3948 | --- 3rdParty/libthrift/protocol/TDenseProtocol.cpp 2013-11-21 23:30:15 +0000 |
3949 | +++ 3rdParty/libthrift/protocol/TDenseProtocol.cpp 2015-02-26 01:00:39 +0000 |
3950 | @@ -89,8 +89,8 @@ |
3951 | |
3952 | #define __STDC_LIMIT_MACROS |
3953 | #include <stdint.h> |
3954 | -#include "TDenseProtocol.h" |
3955 | -#include "TReflectionLocal.h" |
3956 | +#include <thrift/protocol/TDenseProtocol.h> |
3957 | +#include <thrift/TReflectionLocal.h> |
3958 | |
3959 | // Leaving this on for now. Disabling it will turn off asserts, which should |
3960 | // give a performance boost. When we have *really* thorough test cases, |
3961 | @@ -245,7 +245,7 @@ |
3962 | |
3963 | while (vlq > 0) { |
3964 | assert(pos >= 0); |
3965 | - buf[pos] = (vlq | 0x80); |
3966 | + buf[pos] = static_cast<uint8_t>(vlq | 0x80); |
3967 | vlq >>= 7; |
3968 | pos--; |
3969 | } |
3970 | @@ -253,8 +253,8 @@ |
3971 | // Back up one step before writing. |
3972 | pos++; |
3973 | |
3974 | - trans_->write(buf+pos, sizeof(buf) - pos); |
3975 | - return sizeof(buf) - pos; |
3976 | + trans_->write(buf+pos, static_cast<uint32_t>(sizeof(buf) - pos)); |
3977 | + return static_cast<uint32_t>(sizeof(buf) - pos); |
3978 | } |
3979 | |
3980 | |
3981 | @@ -463,7 +463,9 @@ |
3982 | } |
3983 | |
3984 | uint32_t TDenseProtocol::subWriteString(const std::string& str) { |
3985 | - uint32_t size = str.size(); |
3986 | + if(str.size() > static_cast<size_t>((std::numeric_limits<int32_t>::max)())) |
3987 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
3988 | + uint32_t size = static_cast<uint32_t>(str.size()); |
3989 | uint32_t xfer = subWriteI32((int32_t)size); |
3990 | if (size > 0) { |
3991 | trans_->write((uint8_t*)str.data(), size); |
3992 | |
3993 | === modified file '3rdParty/libthrift/protocol/TDenseProtocol.h' |
3994 | --- 3rdParty/libthrift/protocol/TDenseProtocol.h 2013-11-21 23:30:15 +0000 |
3995 | +++ 3rdParty/libthrift/protocol/TDenseProtocol.h 2015-02-26 01:00:39 +0000 |
3996 | @@ -20,7 +20,7 @@ |
3997 | #ifndef _THRIFT_PROTOCOL_TDENSEPROTOCOL_H_ |
3998 | #define _THRIFT_PROTOCOL_TDENSEPROTOCOL_H_ 1 |
3999 | |
4000 | -#include "TBinaryProtocol.h" |
4001 | +#include <thrift/protocol/TBinaryProtocol.h> |
4002 | |
4003 | namespace apache { namespace thrift { namespace protocol { |
4004 | |
4005 | |
4006 | === modified file '3rdParty/libthrift/protocol/TJSONProtocol.cpp' |
4007 | --- 3rdParty/libthrift/protocol/TJSONProtocol.cpp 2013-11-21 23:30:15 +0000 |
4008 | +++ 3rdParty/libthrift/protocol/TJSONProtocol.cpp 2015-02-26 01:00:39 +0000 |
4009 | @@ -17,12 +17,12 @@ |
4010 | * under the License. |
4011 | */ |
4012 | |
4013 | -#include "TJSONProtocol.h" |
4014 | +#include <thrift/protocol/TJSONProtocol.h> |
4015 | |
4016 | #include <math.h> |
4017 | #include <boost/lexical_cast.hpp> |
4018 | -#include "TBase64Utils.h" |
4019 | -#include <transport/TTransportException.h> |
4020 | +#include <thrift/protocol/TBase64Utils.h> |
4021 | +#include <thrift/transport/TTransportException.h> |
4022 | |
4023 | using namespace apache::thrift::transport; |
4024 | |
4025 | @@ -380,7 +380,7 @@ |
4026 | // Write the character ch as a JSON escape sequence ("\u00xx") |
4027 | uint32_t TJSONProtocol::writeJSONEscapeChar(uint8_t ch) { |
4028 | trans_->write((const uint8_t *)kJSONEscapePrefix.c_str(), |
4029 | - kJSONEscapePrefix.length()); |
4030 | + static_cast<uint32_t>(kJSONEscapePrefix.length())); |
4031 | uint8_t outCh = hexChar(ch >> 4); |
4032 | trans_->write(&outCh, 1); |
4033 | outCh = hexChar(ch); |
4034 | @@ -442,7 +442,9 @@ |
4035 | trans_->write(&kJSONStringDelimiter, 1); |
4036 | uint8_t b[4]; |
4037 | const uint8_t *bytes = (const uint8_t *)str.c_str(); |
4038 | - uint32_t len = str.length(); |
4039 | + if(str.length() > (std::numeric_limits<uint32_t>::max)()) |
4040 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
4041 | + uint32_t len = static_cast<uint32_t>(str.length()); |
4042 | while (len >= 3) { |
4043 | // Encode 3 bytes at a time |
4044 | base64_encode(bytes, 3, b); |
4045 | @@ -471,8 +473,10 @@ |
4046 | trans_->write(&kJSONStringDelimiter, 1); |
4047 | result += 1; |
4048 | } |
4049 | - trans_->write((const uint8_t *)val.c_str(), val.length()); |
4050 | - result += val.length(); |
4051 | + if(val.length() > (std::numeric_limits<uint32_t>::max)()) |
4052 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
4053 | + trans_->write((const uint8_t *)val.c_str(), static_cast<uint32_t>(val.length())); |
4054 | + result += static_cast<uint32_t>(val.length()); |
4055 | if (escapeNum) { |
4056 | trans_->write(&kJSONStringDelimiter, 1); |
4057 | result += 1; |
4058 | @@ -512,8 +516,10 @@ |
4059 | trans_->write(&kJSONStringDelimiter, 1); |
4060 | result += 1; |
4061 | } |
4062 | - trans_->write((const uint8_t *)val.c_str(), val.length()); |
4063 | - result += val.length(); |
4064 | + if(val.length() > (std::numeric_limits<uint32_t>::max)()) |
4065 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
4066 | + trans_->write((const uint8_t *)val.c_str(), static_cast<uint32_t>(val.length())); |
4067 | + result += static_cast<uint32_t>(val.length()); |
4068 | if (escapeNum) { |
4069 | trans_->write(&kJSONStringDelimiter, 1); |
4070 | result += 1; |
4071 | @@ -721,7 +727,9 @@ |
4072 | std::string tmp; |
4073 | uint32_t result = readJSONString(tmp); |
4074 | uint8_t *b = (uint8_t *)tmp.c_str(); |
4075 | - uint32_t len = tmp.length(); |
4076 | + if(tmp.length() > (std::numeric_limits<uint32_t>::max)()) |
4077 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
4078 | + uint32_t len = static_cast<uint32_t>(tmp.length()); |
4079 | str.clear(); |
4080 | while (len >= 4) { |
4081 | base64_decode(b, 4); |
4082 | @@ -869,7 +877,9 @@ |
4083 | result += readJSONInteger(tmpVal); |
4084 | messageType = (TMessageType)tmpVal; |
4085 | result += readJSONInteger(tmpVal); |
4086 | - seqid = tmpVal; |
4087 | + if(tmpVal > static_cast<uint64_t>((std::numeric_limits<int32_t>::max)())) |
4088 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
4089 | + seqid = static_cast<int32_t>(tmpVal); |
4090 | return result; |
4091 | } |
4092 | |
4093 | @@ -900,7 +910,9 @@ |
4094 | uint64_t tmpVal = 0; |
4095 | std::string tmpStr; |
4096 | result += readJSONInteger(tmpVal); |
4097 | - fieldId = tmpVal; |
4098 | + if(tmpVal > static_cast<uint32_t>((std::numeric_limits<int16_t>::max)())) |
4099 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
4100 | + fieldId = static_cast<int16_t>(tmpVal); |
4101 | result += readJSONObjectStart(); |
4102 | result += readJSONString(tmpStr); |
4103 | fieldType = getTypeIDForTypeName(tmpStr); |
4104 | @@ -923,7 +935,9 @@ |
4105 | result += readJSONString(tmpStr); |
4106 | valType = getTypeIDForTypeName(tmpStr); |
4107 | result += readJSONInteger(tmpVal); |
4108 | - size = tmpVal; |
4109 | + if(tmpVal > (std::numeric_limits<uint32_t>::max)()) |
4110 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
4111 | + size = static_cast<uint32_t>(tmpVal); |
4112 | result += readJSONObjectStart(); |
4113 | return result; |
4114 | } |
4115 | @@ -940,7 +954,9 @@ |
4116 | result += readJSONString(tmpStr); |
4117 | elemType = getTypeIDForTypeName(tmpStr); |
4118 | result += readJSONInteger(tmpVal); |
4119 | - size = tmpVal; |
4120 | + if(tmpVal > (std::numeric_limits<uint32_t>::max)()) |
4121 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
4122 | + size = static_cast<uint32_t>(tmpVal); |
4123 | return result; |
4124 | } |
4125 | |
4126 | @@ -956,7 +972,9 @@ |
4127 | result += readJSONString(tmpStr); |
4128 | elemType = getTypeIDForTypeName(tmpStr); |
4129 | result += readJSONInteger(tmpVal); |
4130 | - size = tmpVal; |
4131 | + if(tmpVal > (std::numeric_limits<uint32_t>::max)()) |
4132 | + throw TProtocolException(TProtocolException::SIZE_LIMIT); |
4133 | + size = static_cast<uint32_t>(tmpVal); |
4134 | return result; |
4135 | } |
4136 | |
4137 | |
4138 | === modified file '3rdParty/libthrift/protocol/TJSONProtocol.h' |
4139 | --- 3rdParty/libthrift/protocol/TJSONProtocol.h 2013-11-21 23:30:15 +0000 |
4140 | +++ 3rdParty/libthrift/protocol/TJSONProtocol.h 2015-02-26 01:00:39 +0000 |
4141 | @@ -20,7 +20,7 @@ |
4142 | #ifndef _THRIFT_PROTOCOL_TJSONPROTOCOL_H_ |
4143 | #define _THRIFT_PROTOCOL_TJSONPROTOCOL_H_ 1 |
4144 | |
4145 | -#include "TVirtualProtocol.h" |
4146 | +#include <thrift/protocol/TVirtualProtocol.h> |
4147 | |
4148 | #include <stack> |
4149 | |
4150 | @@ -314,7 +314,7 @@ |
4151 | |
4152 | |
4153 | // TODO(dreiss): Move part of ThriftJSONString into a .cpp file and remove this. |
4154 | -#include <transport/TBufferTransports.h> |
4155 | +#include <thrift/transport/TBufferTransports.h> |
4156 | |
4157 | namespace apache { namespace thrift { |
4158 | |
4159 | |
4160 | === added file '3rdParty/libthrift/protocol/TMultiplexedProtocol.cpp' |
4161 | --- 3rdParty/libthrift/protocol/TMultiplexedProtocol.cpp 1970-01-01 00:00:00 +0000 |
4162 | +++ 3rdParty/libthrift/protocol/TMultiplexedProtocol.cpp 2015-02-26 01:00:39 +0000 |
4163 | @@ -0,0 +1,47 @@ |
4164 | +/* |
4165 | + * Licensed to the Apache Software Foundation (ASF) under one |
4166 | + * or more contributor license agreements. See the NOTICE file |
4167 | + * distributed with this work for additional information |
4168 | + * regarding copyright ownership. The ASF licenses this file |
4169 | + * to you under the Apache License, Version 2.0 (the |
4170 | + * "License"); you may not use this file except in compliance |
4171 | + * with the License. You may obtain a copy of the License at |
4172 | + * |
4173 | + * http://www.apache.org/licenses/LICENSE-2.0 |
4174 | + * |
4175 | + * Unless required by applicable law or agreed to in writing, |
4176 | + * software distributed under the License is distributed on an |
4177 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
4178 | + * KIND, either express or implied. See the License for the |
4179 | + * specific language governing permissions and limitations |
4180 | + * under the License. |
4181 | + */ |
4182 | + |
4183 | +#include <thrift/protocol/TMultiplexedProtocol.h> |
4184 | +#include <thrift/processor/TMultiplexedProcessor.h> |
4185 | +#include <thrift/protocol/TProtocolDecorator.h> |
4186 | + |
4187 | +namespace apache |
4188 | +{ |
4189 | + namespace thrift |
4190 | + { |
4191 | + namespace protocol |
4192 | + { |
4193 | + uint32_t TMultiplexedProtocol::writeMessageBegin_virt( |
4194 | + const std::string& _name, |
4195 | + const TMessageType _type, |
4196 | + const int32_t _seqid) |
4197 | + { |
4198 | + if( _type == T_CALL || _type == T_ONEWAY ) |
4199 | + { |
4200 | + return TProtocolDecorator::writeMessageBegin_virt( serviceName + separator + _name, _type, _seqid ); |
4201 | + } |
4202 | + else |
4203 | + { |
4204 | + return TProtocolDecorator::writeMessageBegin_virt(_name, _type, _seqid); |
4205 | + } |
4206 | + } |
4207 | + } |
4208 | + } |
4209 | +} |
4210 | + |
4211 | |
4212 | === added file '3rdParty/libthrift/protocol/TMultiplexedProtocol.h' |
4213 | --- 3rdParty/libthrift/protocol/TMultiplexedProtocol.h 1970-01-01 00:00:00 +0000 |
4214 | +++ 3rdParty/libthrift/protocol/TMultiplexedProtocol.h 2015-02-26 01:00:39 +0000 |
4215 | @@ -0,0 +1,103 @@ |
4216 | +/* |
4217 | + * Licensed to the Apache Software Foundation (ASF) under one |
4218 | + * or more contributor license agreements. See the NOTICE file |
4219 | + * distributed with this work for additional information |
4220 | + * regarding copyright ownership. The ASF licenses this file |
4221 | + * to you under the Apache License, Version 2.0 (the |
4222 | + * "License"); you may not use this file except in compliance |
4223 | + * with the License. You may obtain a copy of the License at |
4224 | + * |
4225 | + * http://www.apache.org/licenses/LICENSE-2.0 |
4226 | + * |
4227 | + * Unless required by applicable law or agreed to in writing, |
4228 | + * software distributed under the License is distributed on an |
4229 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
4230 | + * KIND, either express or implied. See the License for the |
4231 | + * specific language governing permissions and limitations |
4232 | + * under the License. |
4233 | + */ |
4234 | + |
4235 | +#ifndef THRIFT_TMULTIPLEXEDPROTOCOL_H_ |
4236 | +#define THRIFT_TMULTIPLEXEDPROTOCOL_H_ 1 |
4237 | + |
4238 | +#include <thrift/protocol/TProtocolDecorator.h> |
4239 | + |
4240 | +namespace apache |
4241 | +{ |
4242 | + namespace thrift |
4243 | + { |
4244 | + namespace protocol |
4245 | + { |
4246 | + using boost::shared_ptr; |
4247 | + |
4248 | + /** |
4249 | + * <code>TMultiplexedProtocol</code> is a protocol-independent concrete decorator |
4250 | + * that allows a Thrift client to communicate with a multiplexing Thrift server, |
4251 | + * by prepending the service name to the function name during function calls. |
4252 | + * |
4253 | + * \note THIS IS NOT USED BY SERVERS. On the server, use |
4254 | + * {@link apache::thrift::TMultiplexedProcessor TMultiplexedProcessor} to handle requests |
4255 | + * from a multiplexing client. |
4256 | + * |
4257 | + * This example uses a single socket transport to invoke two services: |
4258 | + * |
4259 | + * <blockquote><code> |
4260 | + * shared_ptr<TSocket> transport(new TSocket("localhost", 9090)); |
4261 | + * transport->open(); |
4262 | + * |
4263 | + * shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport)); |
4264 | + * |
4265 | + * shared_ptr<TMultiplexedProtocol> mp1(new TMultiplexedProtocol(protocol, "Calculator")); |
4266 | + * shared_ptr<CalculatorClient> service1(new CalculatorClient(mp1)); |
4267 | + * |
4268 | + * shared_ptr<TMultiplexedProtocol> mp2(new TMultiplexedProtocol(protocol, "WeatherReport")); |
4269 | + * shared_ptr<WeatherReportClient> service2(new WeatherReportClient(mp2)); |
4270 | + * |
4271 | + * service1->add(2,2); |
4272 | + * int temp = service2->getTemperature(); |
4273 | + * </code></blockquote> |
4274 | + * |
4275 | + * @see apache::thrift::protocol::TProtocolDecorator |
4276 | + */ |
4277 | + class TMultiplexedProtocol : public TProtocolDecorator |
4278 | + { |
4279 | + public: |
4280 | + /** |
4281 | + * Wrap the specified protocol, allowing it to be used to communicate with a |
4282 | + * multiplexing server. The <code>serviceName</code> is required as it is |
4283 | + * prepended to the message header so that the multiplexing server can broker |
4284 | + * the function call to the proper service. |
4285 | + * |
4286 | + * \param _protocol Your communication protocol of choice, e.g. <code>TBinaryProtocol</code>. |
4287 | + * \param _serviceName The service name of the service communicating via this protocol. |
4288 | + */ |
4289 | + TMultiplexedProtocol( shared_ptr<TProtocol> _protocol, const std::string& _serviceName ) |
4290 | + : TProtocolDecorator(_protocol), |
4291 | + serviceName(_serviceName), |
4292 | + separator(":") |
4293 | + { } |
4294 | + virtual ~TMultiplexedProtocol() {} |
4295 | + |
4296 | + /** |
4297 | + * Prepends the service name to the function name, separated by TMultiplexedProtocol::SEPARATOR. |
4298 | + * |
4299 | + * \param [in] _name The name of the method to be called in the service. |
4300 | + * \param [in] _type The type of message |
4301 | + * \param [in] _name The sequential id of the message |
4302 | + * |
4303 | + * \throws TException Passed through from wrapped <code>TProtocol</code> instance. |
4304 | + */ |
4305 | + uint32_t writeMessageBegin_virt( |
4306 | + const std::string& _name, |
4307 | + const TMessageType _type, |
4308 | + const int32_t _seqid); |
4309 | + private: |
4310 | + const std::string serviceName; |
4311 | + const std::string separator; |
4312 | + }; |
4313 | + |
4314 | + } |
4315 | + } |
4316 | +} |
4317 | + |
4318 | +#endif // THRIFT_TMULTIPLEXEDPROTOCOL_H_ |
4319 | |
4320 | === modified file '3rdParty/libthrift/protocol/TProtocol.h' |
4321 | --- 3rdParty/libthrift/protocol/TProtocol.h 2013-11-21 23:30:15 +0000 |
4322 | +++ 3rdParty/libthrift/protocol/TProtocol.h 2015-02-26 01:00:39 +0000 |
4323 | @@ -75,10 +75,6 @@ |
4324 | } |
4325 | |
4326 | |
4327 | -namespace apache { namespace thrift { namespace protocol { |
4328 | - |
4329 | -using apache::thrift::transport::TTransport; |
4330 | - |
4331 | #ifdef HAVE_SYS_PARAM_H |
4332 | #include <sys/param.h> |
4333 | #endif |
4334 | @@ -129,14 +125,21 @@ |
4335 | # include <byteswap.h> |
4336 | # define ntohll(n) bswap_64(n) |
4337 | # define htonll(n) bswap_64(n) |
4338 | -# else /* GNUC & GLIBC */ |
4339 | -# define ntohll(n) ( (((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32) ) |
4340 | -# define htonll(n) ( (((uint64_t)htonl(n)) << 32) + htonl(n >> 32) ) |
4341 | -# endif /* GNUC & GLIBC */ |
4342 | +# elif defined(_MSC_VER) /* Microsoft Visual C++ */ |
4343 | +# define ntohll(n) ( _byteswap_uint64((uint64_t)n) ) |
4344 | +# define htonll(n) ( _byteswap_uint64((uint64_t)n) ) |
4345 | +# else /* Not GNUC/GLIBC or MSVC */ |
4346 | +# define ntohll(n) ( (((uint64_t)ntohl((uint32_t)n)) << 32) + ntohl((uint32_t)(n >> 32)) ) |
4347 | +# define htonll(n) ( (((uint64_t)htonl((uint32_t)n)) << 32) + htonl((uint32_t)(n >> 32)) ) |
4348 | +# endif /* GNUC/GLIBC or MSVC or something else */ |
4349 | #else /* __THRIFT_BYTE_ORDER */ |
4350 | # error "Can't define htonll or ntohll!" |
4351 | #endif |
4352 | |
4353 | +namespace apache { namespace thrift { namespace protocol { |
4354 | + |
4355 | +using apache::thrift::transport::TTransport; |
4356 | + |
4357 | /** |
4358 | * Enumerated definition of the types that the Thrift protocol supports. |
4359 | * Take special note of the T_END type which is used specifically to mark |
4360 | @@ -280,6 +283,8 @@ |
4361 | return 0; |
4362 | } |
4363 | |
4364 | +static const uint32_t DEFAULT_RECURSION_LIMIT = 64; |
4365 | + |
4366 | /** |
4367 | * Abstract class for a thrift protocol driver. These are all the methods that |
4368 | * a protocol must implement. Essentially, there must be some way of reading |
4369 | @@ -657,15 +662,28 @@ |
4370 | return ptrans_; |
4371 | } |
4372 | |
4373 | + void incrementRecursionDepth() { |
4374 | + if (recursion_limit_ < ++recursion_depth_) { |
4375 | + throw TProtocolException(TProtocolException::DEPTH_LIMIT); |
4376 | + } |
4377 | + } |
4378 | + |
4379 | + void decrementRecursionDepth() { |
4380 | + --recursion_depth_; |
4381 | + } |
4382 | + |
4383 | protected: |
4384 | - TProtocol(boost::shared_ptr<TTransport> ptrans): |
4385 | - ptrans_(ptrans) { |
4386 | - } |
4387 | + TProtocol(boost::shared_ptr<TTransport> ptrans) |
4388 | + : ptrans_(ptrans) |
4389 | + , recursion_depth_(0) |
4390 | + , recursion_limit_(DEFAULT_RECURSION_LIMIT) {} |
4391 | |
4392 | boost::shared_ptr<TTransport> ptrans_; |
4393 | |
4394 | private: |
4395 | TProtocol() {} |
4396 | + uint32_t recursion_depth_; |
4397 | + uint32_t recursion_limit_; |
4398 | }; |
4399 | |
4400 | /** |
4401 | |
4402 | === added file '3rdParty/libthrift/protocol/TProtocolDecorator.h' |
4403 | --- 3rdParty/libthrift/protocol/TProtocolDecorator.h 1970-01-01 00:00:00 +0000 |
4404 | +++ 3rdParty/libthrift/protocol/TProtocolDecorator.h 2015-02-26 01:00:39 +0000 |
4405 | @@ -0,0 +1,133 @@ |
4406 | +/* |
4407 | + * Licensed to the Apache Software Foundation (ASF) under one |
4408 | + * or more contributor license agreements. See the NOTICE file |
4409 | + * distributed with this work for additional information |
4410 | + * regarding copyright ownership. The ASF licenses this file |
4411 | + * to you under the Apache License, Version 2.0 (the |
4412 | + * "License"); you may not use this file except in compliance |
4413 | + * with the License. You may obtain a copy of the License at |
4414 | + * |
4415 | + * http://www.apache.org/licenses/LICENSE-2.0 |
4416 | + * |
4417 | + * Unless required by applicable law or agreed to in writing, |
4418 | + * software distributed under the License is distributed on an |
4419 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
4420 | + * KIND, either express or implied. See the License for the |
4421 | + * specific language governing permissions and limitations |
4422 | + * under the License. |
4423 | + */ |
4424 | + |
4425 | +#ifndef THRIFT_TPROTOCOLDECORATOR_H_ |
4426 | +#define THRIFT_TPROTOCOLDECORATOR_H_ 1 |
4427 | + |
4428 | +#include <thrift/protocol/TProtocol.h> |
4429 | +#include <boost/shared_ptr.hpp> |
4430 | + |
4431 | +namespace apache |
4432 | +{ |
4433 | + namespace thrift |
4434 | + { |
4435 | + namespace protocol |
4436 | + { |
4437 | + using boost::shared_ptr; |
4438 | + |
4439 | + /** |
4440 | + * <code>TProtocolDecorator</code> forwards all requests to an enclosed |
4441 | + * <code>TProtocol</code> instance, providing a way to author concise |
4442 | + * concrete decorator subclasses. |
4443 | + * |
4444 | + * <p>See p.175 of Design Patterns (by Gamma et al.)</p> |
4445 | + * |
4446 | + * @see apache::thrift::protocol::TMultiplexedProtocol |
4447 | + */ |
4448 | + class TProtocolDecorator : public TProtocol |
4449 | + { |
4450 | + public: |
4451 | + virtual ~TProtocolDecorator() {} |
4452 | + |
4453 | + // Desc: Initializes the protocol decorator object. |
4454 | + TProtocolDecorator( shared_ptr<TProtocol> proto ) |
4455 | + : TProtocol(proto->getTransport()), protocol(proto) |
4456 | + { |
4457 | + } |
4458 | + |
4459 | + virtual uint32_t writeMessageBegin_virt( |
4460 | + const std::string& name, |
4461 | + const TMessageType messageType, |
4462 | + const int32_t seqid) |
4463 | + { |
4464 | + return protocol->writeMessageBegin(name, messageType, seqid); |
4465 | + } |
4466 | + virtual uint32_t writeMessageEnd_virt() { return protocol->writeMessageEnd(); } |
4467 | + virtual uint32_t writeStructBegin_virt(const char* name) { return protocol->writeStructBegin(name); } |
4468 | + virtual uint32_t writeStructEnd_virt() { return protocol->writeStructEnd(); } |
4469 | + |
4470 | + virtual uint32_t writeFieldBegin_virt(const char* name, |
4471 | + const TType fieldType, |
4472 | + const int16_t fieldId) { return protocol->writeFieldBegin(name,fieldType,fieldId); } |
4473 | + |
4474 | + virtual uint32_t writeFieldEnd_virt() { return protocol->writeFieldEnd(); } |
4475 | + virtual uint32_t writeFieldStop_virt() { return protocol->writeFieldStop(); } |
4476 | + |
4477 | + virtual uint32_t writeMapBegin_virt(const TType keyType, |
4478 | + const TType valType, |
4479 | + const uint32_t size) { return protocol->writeMapBegin(keyType,valType,size); } |
4480 | + |
4481 | + virtual uint32_t writeMapEnd_virt() { return protocol->writeMapEnd(); } |
4482 | + |
4483 | + virtual uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) { return protocol->writeListBegin(elemType,size); } |
4484 | + virtual uint32_t writeListEnd_virt() { return protocol->writeListEnd(); } |
4485 | + |
4486 | + virtual uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) { return protocol->writeSetBegin(elemType,size); } |
4487 | + virtual uint32_t writeSetEnd_virt() { return protocol->writeSetEnd(); } |
4488 | + |
4489 | + virtual uint32_t writeBool_virt(const bool value) { return protocol->writeBool(value); } |
4490 | + virtual uint32_t writeByte_virt(const int8_t byte) { return protocol->writeByte(byte); } |
4491 | + virtual uint32_t writeI16_virt(const int16_t i16) { return protocol->writeI16(i16); } |
4492 | + virtual uint32_t writeI32_virt(const int32_t i32) { return protocol->writeI32(i32); } |
4493 | + virtual uint32_t writeI64_virt(const int64_t i64) { return protocol->writeI64(i64); } |
4494 | + |
4495 | + virtual uint32_t writeDouble_virt(const double dub) { return protocol->writeDouble(dub); } |
4496 | + virtual uint32_t writeString_virt(const std::string& str) { return protocol->writeString(str); } |
4497 | + virtual uint32_t writeBinary_virt(const std::string& str) { return protocol->writeBinary(str); } |
4498 | + |
4499 | + virtual uint32_t readMessageBegin_virt(std::string& name, TMessageType& messageType, int32_t& seqid) { return protocol->readMessageBegin(name,messageType,seqid); } |
4500 | + virtual uint32_t readMessageEnd_virt() { return protocol->readMessageEnd(); } |
4501 | + |
4502 | + virtual uint32_t readStructBegin_virt(std::string& name) { return protocol->readStructBegin(name); } |
4503 | + virtual uint32_t readStructEnd_virt() { return protocol->readStructEnd(); } |
4504 | + |
4505 | + virtual uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) { return protocol->readFieldBegin(name, fieldType, fieldId); } |
4506 | + virtual uint32_t readFieldEnd_virt() { return protocol->readFieldEnd(); } |
4507 | + |
4508 | + virtual uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) { return protocol->readMapBegin(keyType,valType,size); } |
4509 | + virtual uint32_t readMapEnd_virt() { return protocol->readMapEnd(); } |
4510 | + |
4511 | + virtual uint32_t readListBegin_virt(TType& elemType, uint32_t& size) { return protocol->readListBegin(elemType,size); } |
4512 | + virtual uint32_t readListEnd_virt() { return protocol->readListEnd(); } |
4513 | + |
4514 | + virtual uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) { return protocol->readSetBegin(elemType,size); } |
4515 | + virtual uint32_t readSetEnd_virt() { return protocol->readSetEnd(); } |
4516 | + |
4517 | + virtual uint32_t readBool_virt(bool& value) { return protocol->readBool(value); } |
4518 | + virtual uint32_t readBool_virt(std::vector<bool>::reference value) { return protocol->readBool(value); } |
4519 | + |
4520 | + virtual uint32_t readByte_virt(int8_t& byte) { return protocol->readByte(byte); } |
4521 | + |
4522 | + virtual uint32_t readI16_virt(int16_t& i16) { return protocol->readI16(i16); } |
4523 | + virtual uint32_t readI32_virt(int32_t& i32) { return protocol->readI32(i32); } |
4524 | + virtual uint32_t readI64_virt(int64_t& i64) { return protocol->readI64(i64); } |
4525 | + |
4526 | + virtual uint32_t readDouble_virt(double& dub) { return protocol->readDouble(dub); } |
4527 | + |
4528 | + virtual uint32_t readString_virt(std::string& str) { return protocol->readString(str); } |
4529 | + virtual uint32_t readBinary_virt(std::string& str) { return protocol->readBinary(str); } |
4530 | + |
4531 | + private: |
4532 | + shared_ptr<TProtocol> protocol; |
4533 | + }; |
4534 | + } |
4535 | + } |
4536 | +} |
4537 | + |
4538 | +#endif // THRIFT_TPROTOCOLDECORATOR_H_ |
4539 | |
4540 | === modified file '3rdParty/libthrift/protocol/TProtocolException.h' |
4541 | --- 3rdParty/libthrift/protocol/TProtocolException.h 2013-11-21 23:30:15 +0000 |
4542 | +++ 3rdParty/libthrift/protocol/TProtocolException.h 2015-02-26 01:00:39 +0000 |
4543 | @@ -45,6 +45,7 @@ |
4544 | , SIZE_LIMIT = 3 |
4545 | , BAD_VERSION = 4 |
4546 | , NOT_IMPLEMENTED = 5 |
4547 | + , DEPTH_LIMIT = 6 |
4548 | }; |
4549 | |
4550 | TProtocolException() : |
4551 | |
4552 | === modified file '3rdParty/libthrift/protocol/TProtocolTap.h' |
4553 | --- 3rdParty/libthrift/protocol/TProtocolTap.h 2013-11-21 23:30:15 +0000 |
4554 | +++ 3rdParty/libthrift/protocol/TProtocolTap.h 2015-02-26 01:00:39 +0000 |
4555 | @@ -20,7 +20,7 @@ |
4556 | #ifndef _THRIFT_PROTOCOL_TPROTOCOLTAP_H_ |
4557 | #define _THRIFT_PROTOCOL_TPROTOCOLTAP_H_ 1 |
4558 | |
4559 | -#include <protocol/TVirtualProtocol.h> |
4560 | +#include <thrift/protocol/TVirtualProtocol.h> |
4561 | |
4562 | namespace apache { namespace thrift { namespace protocol { |
4563 | |
4564 | |
4565 | === added directory '3rdParty/libthrift/qt' |
4566 | === added file '3rdParty/libthrift/qt/TQIODeviceTransport.cpp' |
4567 | --- 3rdParty/libthrift/qt/TQIODeviceTransport.cpp 1970-01-01 00:00:00 +0000 |
4568 | +++ 3rdParty/libthrift/qt/TQIODeviceTransport.cpp 2015-02-26 01:00:39 +0000 |
4569 | @@ -0,0 +1,179 @@ |
4570 | +/* |
4571 | + * Licensed to the Apache Software Foundation (ASF) under one |
4572 | + * or more contributor license agreements. See the NOTICE file |
4573 | + * distributed with this work for additional information |
4574 | + * regarding copyright ownership. The ASF licenses this file |
4575 | + * to you under the Apache License, Version 2.0 (the |
4576 | + * "License"); you may not use this file except in compliance |
4577 | + * with the License. You may obtain a copy of the License at |
4578 | + * |
4579 | + * http://www.apache.org/licenses/LICENSE-2.0 |
4580 | + * |
4581 | + * Unless required by applicable law or agreed to in writing, |
4582 | + * software distributed under the License is distributed on an |
4583 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
4584 | + * KIND, either express or implied. See the License for the |
4585 | + * specific language governing permissions and limitations |
4586 | + * under the License. |
4587 | + */ |
4588 | + |
4589 | +#include <thrift/qt/TQIODeviceTransport.h> |
4590 | + |
4591 | +#include <QAbstractSocket> |
4592 | +#include <QIODevice> |
4593 | + |
4594 | +#include <thrift/transport/TBufferTransports.h> |
4595 | + |
4596 | +using boost::shared_ptr; |
4597 | + |
4598 | +namespace apache { namespace thrift { namespace transport { |
4599 | + |
4600 | +TQIODeviceTransport::TQIODeviceTransport(shared_ptr<QIODevice> dev) |
4601 | + : dev_(dev) |
4602 | +{ |
4603 | +} |
4604 | + |
4605 | +TQIODeviceTransport::~TQIODeviceTransport() |
4606 | +{ |
4607 | + dev_->close(); |
4608 | +} |
4609 | + |
4610 | +void TQIODeviceTransport::open() |
4611 | +{ |
4612 | + if (!isOpen()) { |
4613 | + throw TTransportException(TTransportException::NOT_OPEN, |
4614 | + "open(): underlying QIODevice isn't open"); |
4615 | + } |
4616 | +} |
4617 | + |
4618 | +bool TQIODeviceTransport::isOpen() |
4619 | +{ |
4620 | + return dev_->isOpen(); |
4621 | +} |
4622 | + |
4623 | +bool TQIODeviceTransport::peek() |
4624 | +{ |
4625 | + return dev_->bytesAvailable() > 0; |
4626 | +} |
4627 | + |
4628 | +void TQIODeviceTransport::close() |
4629 | +{ |
4630 | + dev_->close(); |
4631 | +} |
4632 | + |
4633 | +uint32_t TQIODeviceTransport::readAll(uint8_t* buf, uint32_t len) |
4634 | +{ |
4635 | + uint32_t requestLen = len; |
4636 | + while (len) { |
4637 | + uint32_t readSize; |
4638 | + try { |
4639 | + readSize = read(buf, len); |
4640 | + } catch (...) { |
4641 | + if (len != requestLen) { |
4642 | + // something read already |
4643 | + return requestLen - len; |
4644 | + } |
4645 | + // error but nothing read yet |
4646 | + throw; |
4647 | + } |
4648 | + if (readSize == 0) { |
4649 | + dev_->waitForReadyRead(50); |
4650 | + } else { |
4651 | + buf += readSize; |
4652 | + len -= readSize; |
4653 | + } |
4654 | + } |
4655 | + return requestLen; |
4656 | +} |
4657 | + |
4658 | +uint32_t TQIODeviceTransport::read(uint8_t* buf, uint32_t len) |
4659 | +{ |
4660 | + uint32_t actualSize; |
4661 | + qint64 readSize; |
4662 | + |
4663 | + if (!dev_->isOpen()) { |
4664 | + throw TTransportException(TTransportException::NOT_OPEN, |
4665 | + "read(): underlying QIODevice is not open"); |
4666 | + } |
4667 | + |
4668 | + actualSize = (uint32_t)std::min((qint64)len, dev_->bytesAvailable()); |
4669 | + readSize = dev_->read(reinterpret_cast<char *>(buf), actualSize); |
4670 | + |
4671 | + if (readSize < 0) { |
4672 | + QAbstractSocket* socket; |
4673 | + if ((socket = qobject_cast<QAbstractSocket* >(dev_.get()))) { |
4674 | + throw TTransportException(TTransportException::UNKNOWN, |
4675 | + "Failed to read() from QAbstractSocket", |
4676 | + socket->error()); |
4677 | + } |
4678 | + throw TTransportException(TTransportException::UNKNOWN, |
4679 | + "Failed to read from from QIODevice"); |
4680 | + } |
4681 | + |
4682 | + return (uint32_t)readSize; |
4683 | +} |
4684 | + |
4685 | +void TQIODeviceTransport::write(const uint8_t* buf, uint32_t len) |
4686 | +{ |
4687 | + while (len) { |
4688 | + uint32_t written = write_partial(buf, len); |
4689 | + len -= written; |
4690 | + dev_->waitForBytesWritten(50); |
4691 | + } |
4692 | +} |
4693 | + |
4694 | +uint32_t TQIODeviceTransport::write_partial(const uint8_t* buf, uint32_t len) |
4695 | +{ |
4696 | + qint64 written; |
4697 | + |
4698 | + if (!dev_->isOpen()) { |
4699 | + throw TTransportException(TTransportException::NOT_OPEN, |
4700 | + "write_partial(): underlying QIODevice is not open"); |
4701 | + } |
4702 | + |
4703 | + written = dev_->write(reinterpret_cast<const char*>(buf), len); |
4704 | + if (written < 0) { |
4705 | + QAbstractSocket* socket; |
4706 | + if ((socket = qobject_cast<QAbstractSocket*>(dev_.get()))) { |
4707 | + throw TTransportException(TTransportException::UNKNOWN, |
4708 | + "write_partial(): failed to write to QAbstractSocket", socket->error()); |
4709 | + } |
4710 | + |
4711 | + throw TTransportException(TTransportException::UNKNOWN, |
4712 | + "write_partial(): failed to write to underlying QIODevice"); |
4713 | + } |
4714 | + |
4715 | + return (uint32_t)written; |
4716 | +} |
4717 | + |
4718 | +void TQIODeviceTransport::flush() |
4719 | +{ |
4720 | + if (!dev_->isOpen()) { |
4721 | + throw TTransportException(TTransportException::NOT_OPEN, |
4722 | + "flush(): underlying QIODevice is not open"); |
4723 | + } |
4724 | + |
4725 | + QAbstractSocket* socket; |
4726 | + |
4727 | + if ((socket = qobject_cast<QAbstractSocket*>(dev_.get()))) { |
4728 | + socket->flush(); |
4729 | + } else { |
4730 | + dev_->waitForBytesWritten(1); |
4731 | + } |
4732 | +} |
4733 | + |
4734 | +uint8_t* TQIODeviceTransport::borrow(uint8_t* buf, uint32_t* len) |
4735 | +{ |
4736 | + (void) buf; |
4737 | + (void) len; |
4738 | + return NULL; |
4739 | +} |
4740 | + |
4741 | +void TQIODeviceTransport::consume(uint32_t len) |
4742 | +{ |
4743 | + (void) len; |
4744 | + throw TTransportException(TTransportException::UNKNOWN); |
4745 | +} |
4746 | + |
4747 | +}}} // apache::thrift::transport |
4748 | + |
4749 | |
4750 | === added file '3rdParty/libthrift/qt/TQIODeviceTransport.h' |
4751 | --- 3rdParty/libthrift/qt/TQIODeviceTransport.h 1970-01-01 00:00:00 +0000 |
4752 | +++ 3rdParty/libthrift/qt/TQIODeviceTransport.h 2015-02-26 01:00:39 +0000 |
4753 | @@ -0,0 +1,64 @@ |
4754 | +/* |
4755 | + * Licensed to the Apache Software Foundation (ASF) under one |
4756 | + * or more contributor license agreements. See the NOTICE file |
4757 | + * distributed with this work for additional information |
4758 | + * regarding copyright ownership. The ASF licenses this file |
4759 | + * to you under the Apache License, Version 2.0 (the |
4760 | + * "License"); you may not use this file except in compliance |
4761 | + * with the License. You may obtain a copy of the License at |
4762 | + * |
4763 | + * http://www.apache.org/licenses/LICENSE-2.0 |
4764 | + * |
4765 | + * Unless required by applicable law or agreed to in writing, |
4766 | + * software distributed under the License is distributed on an |
4767 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
4768 | + * KIND, either express or implied. See the License for the |
4769 | + * specific language governing permissions and limitations |
4770 | + * under the License. |
4771 | + */ |
4772 | + |
4773 | +#ifndef _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_ |
4774 | +#define _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_ 1 |
4775 | + |
4776 | +#include <boost/shared_ptr.hpp> |
4777 | + |
4778 | +#include <thrift/transport/TVirtualTransport.h> |
4779 | + |
4780 | +class QIODevice; |
4781 | + |
4782 | +namespace apache { namespace thrift { namespace transport { |
4783 | + |
4784 | +/** |
4785 | + * Transport that operates on a QIODevice (socket, file, etc). |
4786 | + */ |
4787 | +class TQIODeviceTransport : public apache::thrift::transport::TVirtualTransport<TQIODeviceTransport> { |
4788 | + public: |
4789 | + explicit TQIODeviceTransport(boost::shared_ptr<QIODevice> dev); |
4790 | + virtual ~TQIODeviceTransport(); |
4791 | + |
4792 | + void open(); |
4793 | + bool isOpen(); |
4794 | + bool peek(); |
4795 | + void close(); |
4796 | + |
4797 | + uint32_t readAll(uint8_t *buf, uint32_t len); |
4798 | + uint32_t read(uint8_t* buf, uint32_t len); |
4799 | + |
4800 | + void write(const uint8_t* buf, uint32_t len); |
4801 | + uint32_t write_partial(const uint8_t* buf, uint32_t len); |
4802 | + |
4803 | + void flush(); |
4804 | + |
4805 | + uint8_t* borrow(uint8_t* buf, uint32_t* len); |
4806 | + void consume(uint32_t len); |
4807 | + |
4808 | + private: |
4809 | + TQIODeviceTransport(const TQIODeviceTransport&); |
4810 | + TQIODeviceTransport& operator=(const TQIODeviceTransport&); |
4811 | + |
4812 | + boost::shared_ptr<QIODevice> dev_; |
4813 | +}; |
4814 | +}}} // apache::thrift::transport |
4815 | + |
4816 | +#endif // #ifndef _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_ |
4817 | + |
4818 | |
4819 | === added file '3rdParty/libthrift/qt/TQTcpServer.cpp' |
4820 | --- 3rdParty/libthrift/qt/TQTcpServer.cpp 1970-01-01 00:00:00 +0000 |
4821 | +++ 3rdParty/libthrift/qt/TQTcpServer.cpp 2015-02-26 01:00:39 +0000 |
4822 | @@ -0,0 +1,157 @@ |
4823 | +/* |
4824 | + * Licensed to the Apache Software Foundation (ASF) under one |
4825 | + * or more contributor license agreements. See the NOTICE file |
4826 | + * distributed with this work for additional information |
4827 | + * regarding copyright ownership. The ASF licenses this file |
4828 | + * to you under the Apache License, Version 2.0 (the |
4829 | + * "License"); you may not use this file except in compliance |
4830 | + * with the License. You may obtain a copy of the License at |
4831 | + * |
4832 | + * http://www.apache.org/licenses/LICENSE-2.0 |
4833 | + * |
4834 | + * Unless required by applicable law or agreed to in writing, |
4835 | + * software distributed under the License is distributed on an |
4836 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
4837 | + * KIND, either express or implied. See the License for the |
4838 | + * specific language governing permissions and limitations |
4839 | + * under the License. |
4840 | + */ |
4841 | + |
4842 | +#include <thrift/qt/TQTcpServer.h> |
4843 | +#include <thrift/qt/TQIODeviceTransport.h> |
4844 | + |
4845 | +#include <QTcpSocket> |
4846 | + |
4847 | +#include <thrift/cxxfunctional.h> |
4848 | + |
4849 | +#include <thrift/protocol/TProtocol.h> |
4850 | +#include <thrift/async/TAsyncProcessor.h> |
4851 | + |
4852 | +using boost::shared_ptr; |
4853 | +using apache::thrift::protocol::TProtocol; |
4854 | +using apache::thrift::protocol::TProtocolFactory; |
4855 | +using apache::thrift::transport::TTransport; |
4856 | +using apache::thrift::transport::TTransportException; |
4857 | +using apache::thrift::transport::TQIODeviceTransport; |
4858 | +using apache::thrift::stdcxx::function; |
4859 | +using apache::thrift::stdcxx::bind; |
4860 | + |
4861 | +QT_USE_NAMESPACE |
4862 | + |
4863 | +namespace apache { namespace thrift { namespace async { |
4864 | + |
4865 | +struct TQTcpServer::ConnectionContext { |
4866 | + shared_ptr<QTcpSocket> connection_; |
4867 | + shared_ptr<TTransport> transport_; |
4868 | + shared_ptr<TProtocol> iprot_; |
4869 | + shared_ptr<TProtocol> oprot_; |
4870 | + |
4871 | + explicit ConnectionContext(shared_ptr<QTcpSocket> connection, |
4872 | + shared_ptr<TTransport> transport, |
4873 | + shared_ptr<TProtocol> iprot, |
4874 | + shared_ptr<TProtocol> oprot) |
4875 | + : connection_(connection) |
4876 | + , transport_(transport) |
4877 | + , iprot_(iprot) |
4878 | + , oprot_(oprot) |
4879 | + {} |
4880 | +}; |
4881 | + |
4882 | +TQTcpServer::TQTcpServer(shared_ptr<QTcpServer> server, |
4883 | + shared_ptr<TAsyncProcessor> processor, |
4884 | + shared_ptr<TProtocolFactory> pfact, |
4885 | + QObject* parent) |
4886 | + : QObject(parent) |
4887 | + , server_(server) |
4888 | + , processor_(processor) |
4889 | + , pfact_(pfact) |
4890 | +{ |
4891 | + connect(server.get(), SIGNAL(newConnection()), SLOT(processIncoming())); |
4892 | +} |
4893 | + |
4894 | +TQTcpServer::~TQTcpServer() |
4895 | +{ |
4896 | +} |
4897 | + |
4898 | +void TQTcpServer::processIncoming() |
4899 | +{ |
4900 | + while (server_->hasPendingConnections()) { |
4901 | + // take ownership of the QTcpSocket; technically it could be deleted |
4902 | + // when the QTcpServer is destroyed, but any real app should delete this |
4903 | + // class before deleting the QTcpServer that we are using |
4904 | + shared_ptr<QTcpSocket> connection(server_->nextPendingConnection()); |
4905 | + |
4906 | + shared_ptr<TTransport> transport; |
4907 | + shared_ptr<TProtocol> iprot; |
4908 | + shared_ptr<TProtocol> oprot; |
4909 | + |
4910 | + try { |
4911 | + transport = shared_ptr<TTransport>(new TQIODeviceTransport(connection)); |
4912 | + iprot = shared_ptr<TProtocol>(pfact_->getProtocol(transport)); |
4913 | + oprot = shared_ptr<TProtocol>(pfact_->getProtocol(transport)); |
4914 | + } catch(...) { |
4915 | + qWarning("[TQTcpServer] Failed to initialize transports/protocols"); |
4916 | + continue; |
4917 | + } |
4918 | + |
4919 | + ctxMap_[connection.get()] = |
4920 | + shared_ptr<ConnectionContext>( |
4921 | + new ConnectionContext(connection, transport, iprot, oprot)); |
4922 | + |
4923 | + connect(connection.get(), SIGNAL(readyRead()), SLOT(beginDecode())); |
4924 | + |
4925 | + // need to use QueuedConnection since we will be deleting the socket in the slot |
4926 | + connect(connection.get(), SIGNAL(disconnected()), SLOT(socketClosed()), |
4927 | + Qt::QueuedConnection); |
4928 | + } |
4929 | +} |
4930 | + |
4931 | +void TQTcpServer::beginDecode() |
4932 | +{ |
4933 | + QTcpSocket* connection(qobject_cast<QTcpSocket*>(sender())); |
4934 | + Q_ASSERT(connection); |
4935 | + |
4936 | + if (ctxMap_.find(connection) == ctxMap_.end()) { |
4937 | + qWarning("[TQTcpServer] Got data on an unknown QTcpSocket"); |
4938 | + return; |
4939 | + } |
4940 | + |
4941 | + shared_ptr<ConnectionContext> ctx = ctxMap_[connection]; |
4942 | + |
4943 | + try { |
4944 | + processor_->process( |
4945 | + bind(&TQTcpServer::finish, this, |
4946 | + ctx, apache::thrift::stdcxx::placeholders::_1), |
4947 | + ctx->iprot_, ctx->oprot_); |
4948 | + } catch(const TTransportException& ex) { |
4949 | + qWarning("[TQTcpServer] TTransportException during processing: '%s'", |
4950 | + ex.what()); |
4951 | + ctxMap_.erase(connection); |
4952 | + } catch(...) { |
4953 | + qWarning("[TQTcpServer] Unknown processor exception"); |
4954 | + ctxMap_.erase(connection); |
4955 | + } |
4956 | +} |
4957 | + |
4958 | +void TQTcpServer::socketClosed() |
4959 | +{ |
4960 | + QTcpSocket* connection(qobject_cast<QTcpSocket*>(sender())); |
4961 | + Q_ASSERT(connection); |
4962 | + |
4963 | + if (ctxMap_.find(connection) == ctxMap_.end()) { |
4964 | + qWarning("[TQTcpServer] Unknown QTcpSocket closed"); |
4965 | + return; |
4966 | + } |
4967 | + |
4968 | + ctxMap_.erase(connection); |
4969 | +} |
4970 | + |
4971 | +void TQTcpServer::finish(shared_ptr<ConnectionContext> ctx, bool healthy) |
4972 | +{ |
4973 | + if (!healthy) { |
4974 | + qWarning("[TQTcpServer] Processor failed to process data successfully"); |
4975 | + ctxMap_.erase(ctx->connection_.get()); |
4976 | + } |
4977 | +} |
4978 | + |
4979 | +}}} // apache::thrift::async |
4980 | |
4981 | === added file '3rdParty/libthrift/qt/TQTcpServer.h' |
4982 | --- 3rdParty/libthrift/qt/TQTcpServer.h 1970-01-01 00:00:00 +0000 |
4983 | +++ 3rdParty/libthrift/qt/TQTcpServer.h 2015-02-26 01:00:39 +0000 |
4984 | @@ -0,0 +1,72 @@ |
4985 | +/* |
4986 | + * Licensed to the Apache Software Foundation (ASF) under one |
4987 | + * or more contributor license agreements. See the NOTICE file |
4988 | + * distributed with this work for additional information |
4989 | + * regarding copyright ownership. The ASF licenses this file |
4990 | + * to you under the Apache License, Version 2.0 (the |
4991 | + * "License"); you may not use this file except in compliance |
4992 | + * with the License. You may obtain a copy of the License at |
4993 | + * |
4994 | + * http://www.apache.org/licenses/LICENSE-2.0 |
4995 | + * |
4996 | + * Unless required by applicable law or agreed to in writing, |
4997 | + * software distributed under the License is distributed on an |
4998 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
4999 | + * KIND, either express or implied. See the License for the |
5000 | + * specific language governing permissions and limitations |
FAILED: Continuous integration, rev:351 /code.launchpad .net/~mzanetti/ reminders- app/update- thrift/ +merge/ 251027/ +edit-commit- message
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http:// 91.189. 93.70:8080/ job/reminders- app-ci/ 672/ 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 2114 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 2114/artifact/ work/output/ *zip*/output. zip 91.189. 93.70:8080/ job/reminders- app-vivid- amd64-ci/ 93
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/reminders- app-ci/ 672/rebuild
http://