Commit Graph

315 Commits

Author SHA1 Message Date
Kevin Clark
022b224ebd THRIFT-96. cpp: TSocket.peek fails on FreeBSD
Author: Alexander Shigin

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@750585 13f79535-47bb-0310-9956-ffa450edef68
2009-03-05 21:05:37 +00:00
Kevin Clark
5ace1780ab THRIFT-265. cpp: Reset buffers every 512 calls in TNonblockingServer
Author: Erik Frey

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@750153 13f79535-47bb-0310-9956-ffa450edef68
2009-03-04 21:10:58 +00:00
David Reiss
57b500610f THRIFT-348. cpp: Fix readBool for vectors of bools (again)
This bug only affected the returned number bytes read
(which is not currently used), not the actual bool value.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@747635 13f79535-47bb-0310-9956-ffa450edef68
2009-02-25 00:59:55 +00:00
David Reiss
035aed90c0 cpp: Fix implementations of "list<bool>"
TProtocol::readBool expects a "bool&" as its argument, but "list<bool>"
is implemented as "vector<bool>", which is a specialization of vector
that uses a custom structure as its reference type.  Therefore, we need
to overload TProtocol::readBool for std::vector<bool>::reference.
This function is provided as a non-virtual for efficiency since it is
highly unlikely that any subclass will want to override it.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@743112 13f79535-47bb-0310-9956-ffa450edef68
2009-02-10 21:38:48 +00:00
David Reiss
0b7d6fa5ee THRIFT-314. Purge reflection.limited
This was a feature designed to allow a Thrift server to report
information about its interface.  However, the feature has
significant design problems, and is presence is currently causing
confusion without doing any good.  Therefore, it is being removed.
It will always be in source control if and when we are ready to
come back to it.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@741824 13f79535-47bb-0310-9956-ffa450edef68
2009-02-07 02:36:35 +00:00
T Jake Luciani
b5e6221eb5 THRIFT-270: change cpp namespaces from facebook::thrift to apache::thrift
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@739644 13f79535-47bb-0310-9956-ffa450edef68
2009-01-31 22:36:20 +00:00
David Reiss
4c266ccc2c THRIFT-244. cpp: Make TJSONProtocolFactor inherit from TProtocolFactory
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@734863 13f79535-47bb-0310-9956-ffa450edef68
2009-01-15 23:56:24 +00:00
David Reiss
6713e1b126 THRIFT-244. cpp: Fix TJSONProtocol::writeMessageBegin
uint8_t is a character type, so lexical_cast doesn't convert it
to an integer representation.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@734862 13f79535-47bb-0310-9956-ffa450edef68
2009-01-15 23:56:19 +00:00
David Reiss
322e595c2a THRIFT-203. cpp: Make library headers compile under g++ -pedantic
It turns out that trailing commas in enum definitions are
not actually valid C++.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@723562 13f79535-47bb-0310-9956-ffa450edef68
2008-12-05 02:54:09 +00:00
David Reiss
fbb14ef1b3 THRIFT-214. cpp: Qualify a cast to fix OSX compilation
id_t is defined in some OSX header, and the id_t in this function
resolved to that one instead of Thread::id_t.  This change fully
qualifies the type to make sure it resolves properly.

Also remove a comment about eliminating the C-style cast, since it
is actually quite appropriate in this case.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@722337 13f79535-47bb-0310-9956-ffa450edef68
2008-12-02 02:32:25 +00:00
David Reiss
428d5695ab THRIFT-215. cpp: Disable an assertion that fails on various platforms
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@722336 13f79535-47bb-0310-9956-ffa450edef68
2008-12-02 02:22:01 +00:00
David Reiss
d90cd1f539 THRIFT-168. cpp: Clear transport buffers before a flush
Previously, TBufferedTransport and TFramedTransport could
leave data in their buffers if a flush threw an exception.
This patch makes them reset their internal pointers before
flushing to the underlying transport.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@709037 13f79535-47bb-0310-9956-ffa450edef68
2008-10-29 22:50:34 +00:00
David Reiss
826e648354 THRIFT-177. cpp: Add a missing "std::"
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@706418 13f79535-47bb-0310-9956-ffa450edef68
2008-10-20 21:29:07 +00:00
David Reiss
c53a5944ed Fix a compile bug introduced by r702644
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@702672 13f79535-47bb-0310-9956-ffa450edef68
2008-10-07 23:55:24 +00:00
David Reiss
e11f3073f7 THRIFT-149. cpp: Make TNonblockingServer handle a shut-down ThreadManager
This is a step toward implementing a graceful shutdown.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@702644 13f79535-47bb-0310-9956-ffa450edef68
2008-10-07 21:39:19 +00:00
David Reiss
5317b1ecd2 THRIFT-95. cpp: Fix write buffer initialization in TBufferedTransport
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@679500 13f79535-47bb-0310-9956-ffa450edef68
2008-07-24 19:10:16 +00:00
David Reiss
01e55c1c28 cpp: Eliminate the use of fprintf [THRIFT-77]
Add printf and perror methods to TOutput and use them to
replace uses of fprintf in the C++ library.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@676448 13f79535-47bb-0310-9956-ffa450edef68
2008-07-13 22:18:51 +00:00
David Reiss
2be87f3ab0 (THRIFT-37) Add some missing newlines to fprintfs.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@676087 13f79535-47bb-0310-9956-ffa450edef68
2008-07-11 21:39:58 +00:00
David Reiss
53f18f01be (THRIFT-69) Fix Util::currentTime for use in applications.
This function didn't work properly when used outside of the Thrift library
because config.h isn't available.  This patch fixes the issue by moving
the function definition into the library.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@675819 13f79535-47bb-0310-9956-ffa450edef68
2008-07-11 00:45:29 +00:00
David Reiss
af78778acd (THRIFT-54) Remove "frameResponses" from TNonblockingServer
TNonblockingServer and TFramedTransport used to have the option to only
frame messages on one side of the communication.  This capability was
removed from TFramedTransport because it was poorly implemented and not
useful.  This change removes it from TNonblockingServer as well, and
removes references to it in some of the C++ test code.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@673791 13f79535-47bb-0310-9956-ffa450edef68
2008-07-03 20:29:34 +00:00
David Reiss
52cb7a7413 (THRIFT-45) TNonblockingServer (C++): only do one write in responses.
Instead of doing one 4-byte write for the frame length before the write
of the actual message, prepend the frame length to the message buffer
so we can send them both at once.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@672937 13f79535-47bb-0310-9956-ffa450edef68
2008-06-30 21:40:35 +00:00
David Reiss
c88eb8c9dd Include <cstring> and use "std::" for memset in T[Server]Socket.cpp.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666498 13f79535-47bb-0310-9956-ffa450edef68
2008-06-11 01:18:54 +00:00
David Reiss
a27c3cd0c9 Include <cstring> and use "std::" for memcpy in TBufferTransports.h.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666497 13f79535-47bb-0310-9956-ffa450edef68
2008-06-11 01:18:44 +00:00
David Reiss
32e95f8bb9 Include <limits> in TBinaryProtocol.cpp for numeric_limits.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666496 13f79535-47bb-0310-9956-ffa450edef68
2008-06-11 01:18:36 +00:00
David Reiss
fb1c5ace0a Declare special mutex initializers unconditionally.
We don't want to include pthread.h in Mutex.h, so we can't detect whether
the non-portable mutex initializers are defined.  Instead, we just declare
them unconditionally and only define them if they are available.
Unfortunately, this means that users will get a link error instead of a
compile error if they try to use them when they are not available.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666495 13f79535-47bb-0310-9956-ffa450edef68
2008-06-11 01:18:28 +00:00
David Reiss
a4d7eef5cd Fix some includes in Thrift.{h,cpp}.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666494 13f79535-47bb-0310-9956-ffa450edef68
2008-06-11 01:18:20 +00:00
David Reiss
77bb916766 Regenerate reflection_limited to pick up some compiler improvements.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666493 13f79535-47bb-0310-9956-ffa450edef68
2008-06-11 01:18:11 +00:00
David Reiss
c6c6498b02 Allow out-of-source builds.
- Clean up lib/cpp/Makefile.am to use AM_CXXFLAGS etc instead of
  target-specific so we can take advantage of default flags.
- Use top_builddir in a few places instead of top_srcdir.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666489 13f79535-47bb-0310-9956-ffa450edef68
2008-06-11 01:16:45 +00:00
David Reiss
1a2f2187cd Another whitespace rampage
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666477 13f79535-47bb-0310-9956-ffa450edef68
2008-06-11 01:14:01 +00:00
David Reiss
13aea4600c Fix IPv6 on FreeBSD.
On FreeBSD (and possibly other BSDs), binding to ipv6 is restricted unless the
sysctl net.inet6.ip6.v6only=0 or the socket option IPV6_V6ONLY is turned off.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666367 13f79535-47bb-0310-9956-ffa450edef68
2008-06-10 22:56:04 +00:00
David Reiss
c6dab61300 Thrift: Allow for alternative Mutex initializers.
Summary:
Add an argument to the Mutex constructor.
It takes a pointer to a function that initializes the internal pthread_mutex_t.
We provide initializers for default pthread_mutex_t (which is our default),
adaptive mutexes, and recursive mutexes.

Reviewed By: hzhao, psaab, mcslee

Test Plan: Built libthrift.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666362 13f79535-47bb-0310-9956-ffa450edef68
2008-06-10 22:55:13 +00:00
David Reiss
e3a64923e9 Fix locking bug in ThreadManager.
It looks like the scheduler waits on monitor_, but the worker notifies
workerMonitor_. Also, it does so out of critical section.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666361 13f79535-47bb-0310-9956-ffa450edef68
2008-06-10 22:55:04 +00:00
David Reiss
791a57f528 FunctionRunner Utility Class.
Runs arbitrary functions of form 'void(void)' and 'void*(void*)'
without need to create custom Runnable classes.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666360 13f79535-47bb-0310-9956-ffa450edef68
2008-06-10 22:54:56 +00:00
David Reiss
af296954ea Add ProfilerRegisterThead() to PosixThread.
Adds an #ifdef'd block that calls ProfilerRegisterThread() if
"REGISTER_THREAD_GOOGLE_PERFTOOLS" is set.  Apparently, this makes the
Google perftools CPU profiler work much better on x86-64.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666358 13f79535-47bb-0310-9956-ffa450edef68
2008-06-10 22:54:40 +00:00
David Reiss
7dab93e237 Fix a few copy-paste errors in TBufferTransports (not code).
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665684 13f79535-47bb-0310-9956-ffa450edef68
2008-05-09 19:18:29 +00:00
David Reiss
80097936bd C++/TFramedTransport: Don't write an empty frame on flush.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665681 13f79535-47bb-0310-9956-ffa450edef68
2008-05-09 07:14:10 +00:00
David Reiss
4771458432 Fix a small logic error in TBufferedTransport::borrowSlow.
Was using an unsigned int for a value that could be negative.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665680 13f79535-47bb-0310-9956-ffa450edef68
2008-05-09 00:40:26 +00:00
David Reiss
f233e46a2d Throw a transport exception if fstat fails.
This was failing on an NFS mount that was dying.
Better to fail hard then return uninitialized data.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665677 13f79535-47bb-0310-9956-ffa450edef68
2008-05-01 06:21:04 +00:00
David Reiss
28f298dd5d Memory-based transport rewrite.
The old implementations of the memory-based transports (TBufferedTransport,
TFramedTransport, and TMemoryBuffer) shared very little code and all worked
a bit differently.  This change unifies them all as subclasses of a single
base (TBufferBase) which handles the fast-path operations (when requests
can be satisfied by the buffer) with inline methods (that will eventually
be made nonvirtual in the template branch) and calls out to pure-virutal
methods to handle full/empty buffers.  All of the buffer-management is now
done in terms of "base and bound" pointers rather than "pos" integers.

These classes were moved to TBufferTransports.{h,cpp}.  The .h is included
in TTransportUtils for backwards compatibility.

Also added a "TShortReadTransport" to assist testing transports.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665676 13f79535-47bb-0310-9956-ffa450edef68
2008-05-01 06:17:36 +00:00
David Reiss
e39e937911 Remove a few unnecessary includes to speed up compiles.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665673 13f79535-47bb-0310-9956-ffa450edef68
2008-05-01 05:52:48 +00:00
David Reiss
6412000143 C++: Make write{Struct,Field}Begin take "name" as a const char*.
Summary:
These methods previously took name as a const string&.  While that way
is more idiomatic, it requires a temporary string to be constructed
when we pass a string literal (which is always).  This was significantly
slowing down the serialization of field-heavy structures.  This change
will break ABI compatibility, but the serialization speed boost with
no external API changes is too important to pass up.

Reviewed By: mcslee, aditya

Test Plan: make check

TracCamp Project: Thrift

Revert Plan: ok


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665672 13f79535-47bb-0310-9956-ffa450edef68
2008-04-29 23:12:24 +00:00
David Reiss
c17fe6b918 THRIFT: Nonblcoking bug fix
calling decrement with -1 even though param is an integer. Just made it clean by adding a decrement function

reviewed by: mcslee
revertable
test plan: ran on a test server


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665669 13f79535-47bb-0310-9956-ffa450edef68
2008-04-29 00:29:43 +00:00
David Reiss
1997f10e28 Persistent conns in TSocketPool
Summary: Added support for persistent conns in TSocketPool
         Also, added some util functions in TNonblockingServer

Reviewed By: mcslee

Test Plan: Ran a test search cluster with these changes - open was only called once (I put fprintfs in open and close), after which the socket was reused

Revert: OK

TracCamp Project: Thrift

DiffCamp Revision: 11425


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665668 13f79535-47bb-0310-9956-ffa450edef68
2008-04-29 00:29:41 +00:00
David Reiss
bd3b168e63 Silence a valgrind complaint by matching "delete[]" with "new[]".
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665666 13f79535-47bb-0310-9956-ffa450edef68
2008-04-28 02:42:28 +00:00
David Reiss
94058454a0 Add TBase64Utils.h and TJSONProto.h to lib/cpp/Makefile.am.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665663 13f79535-47bb-0310-9956-ffa450edef68
2008-04-21 18:07:58 +00:00
David Reiss
2724c7a311 Thrift: bug fix for interrupting server socket
Summary: TServerSocket uses a socket pair to signal interruption to the select() call on its main server socket.  A bug in the code prevented the select() from listening for events on the internal socket pair; in fact, it was accidentally listening to file descriptor 1.

Reviewed By: aditya

Test Plan: Use a server that supports a call to shutdown, which should signal an interrupt to the internal socket, and should result in an immediate and clean termination of the server socket thread.

Revert: OK

TracCamp Project: Thrift

DiffCamp Revision: 11932


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665658 13f79535-47bb-0310-9956-ffa450edef68
2008-04-18 17:48:03 +00:00
David Reiss
739cbe2b86 Add a few missing includes.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665657 13f79535-47bb-0310-9956-ffa450edef68
2008-04-15 05:44:00 +00:00
David Reiss
a177109752 Fix Thrift.cpp for non-Linux systems.
- Add some missing namespace qualifiers that are not used in the glibc case.
- Move an include from Thrift.h to Thrift.cpp.
- Include boost/lexical_cast.hpp in TJSONProtocol, in case we ever eliminate
  it from our header files.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665656 13f79535-47bb-0310-9956-ffa450edef68
2008-04-11 22:36:31 +00:00
David Reiss
b54deb1ca5 Fix a minor bug in TDebugProtocol and remove dead code.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665650 13f79535-47bb-0310-9956-ffa450edef68
2008-04-08 19:38:49 +00:00
David Reiss
1677ac9cc7 Use poll instead of select in TServerSocket
Summary: - select has a restricted max fd set size. While this should not be an issue in the normal case for
           TServerSocket because it is started when the process starts, it could be a problem if someone wanted
           to start a new server socket at a later point in time when socket values could be greater than max.

Reviewed By: dreiss

Test Plan: - Compiled.
           - Deployed search tier and made sure it could serve queries.

Revert: OK

TracCamp Project: Thrift

DiffCamp Revision: 11076


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665649 13f79535-47bb-0310-9956-ffa450edef68
2008-04-08 06:26:27 +00:00