Commit Graph

381 Commits

Author SHA1 Message Date
David Reiss
d28ce1035b cpp: Fix an OpenBSD compilation error that appears to be a real bug
The (Linux) man page for ctime_r states pretty clearly that
the buffer it uses must have space for at least 26 characters.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@776925 13f79535-47bb-0310-9956-ffa450edef68
2009-05-21 02:28:14 +00:00
David Reiss
be378f232b THRIFT-490. Clarify the comment for the Guard macro
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@772478 13f79535-47bb-0310-9956-ffa450edef68
2009-05-07 00:41:18 +00:00
Bryan Duxbury
def30a6072 THRIFT-387. Add appropriate Apache header to all code files
This hits all the documentation and some misc code files that have avoided the license up to this point.



git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@763048 13f79535-47bb-0310-9956-ffa450edef68
2009-04-08 00:19:37 +00:00
Bryan Duxbury
141eab4147 THRIFT-425. cpp: numeric_limits is declared in <limits>
TCompactProtocol.cpp doesn't compile without including limits.



git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@761705 13f79535-47bb-0310-9956-ffa450edef68
2009-04-03 15:05:28 +00:00
David Reiss
260fa93aaa THRIFT-411. cpp: Make TNonblockingServer::connectionStackLimit_ accessors use the right type
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@761481 13f79535-47bb-0310-9956-ffa450edef68
2009-04-02 23:51:39 +00:00
David Reiss
7247b8cfd6 cpp: Fix compiler and library compilation with newer glibc
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@761464 13f79535-47bb-0310-9956-ffa450edef68
2009-04-02 23:05:40 +00:00
David Reiss
e4d4ea0e83 THRIFT-333. cpp: Initial TCompactProtocol implementation
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@761438 13f79535-47bb-0310-9956-ffa450edef68
2009-04-02 21:37:17 +00:00
David Reiss
deda141392 THRIFT-388. Create a "ONEWAY" message type that is an alias for "CALL"
Pave the way for a new message type for oneway function calls.
For now, just define the constant in all languages and make
server implementations treat it the same way as a normal call.
Only C++ and Erlang currently check the message type (on the
server side).

There is a little bit of redundancy in the Erlang code, but
the alternative is a bit gross, and this split-up will be
necessary eventually when we start handling one-way calls
differently.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@761389 13f79535-47bb-0310-9956-ffa450edef68
2009-04-02 19:22:31 +00:00
David Reiss
e48e55447f THRIFT-387. Add license to pkgconfig files
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@760219 13f79535-47bb-0310-9956-ffa450edef68
2009-03-30 22:52:42 +00:00
David Reiss
ea2cba8ba8 THRIFT-387. Add license headers to a bunch of files
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@760189 13f79535-47bb-0310-9956-ffa450edef68
2009-03-30 21:35:00 +00:00
David Reiss
abb56a4a0d THRIFT-255. cpp: Add TSimpleFileTransport, a wrapper around TFDTransport
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@758533 13f79535-47bb-0310-9956-ffa450edef68
2009-03-26 06:23:57 +00:00
David Reiss
c51986f438 THRIFT-136. s/async/oneway/ in comments
This is an internal-only change.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@757990 13f79535-47bb-0310-9956-ffa450edef68
2009-03-24 20:01:25 +00:00
Bryan Duxbury
13083d6d52 THRIFT-294. Remove @author tags
They're gone. Don't add any new ones!



git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@756307 13f79535-47bb-0310-9956-ffa450edef68
2009-03-20 02:19:46 +00:00
Kevin Clark
cbcd63ab49 Thrift-357. cpp: Fix buffer and connection bloat in TNonBlockingServer
Author: Anthony Giardullo

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@755824 13f79535-47bb-0310-9956-ffa450edef68
2009-03-19 03:50:05 +00:00
David Reiss
48141bf5a6 THRIFT-373. Update lists of files to include in release tarballs
This is mostly EXTRA_DIST, but also includes some headers.
I had to drill down into test because "make dist" builds some
of the test code.  .gitignore is not included in the tarballs.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@755791 13f79535-47bb-0310-9956-ffa450edef68
2009-03-18 23:59:56 +00:00
David Reiss
45d56965c2 THRIFT-351. cpp: Allow a custom ThreadFactory in TThreadedServer
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@754551 13f79535-47bb-0310-9956-ffa450edef68
2009-03-14 23:35:16 +00:00
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
David Reiss
9b20955b2d Thrift error logging improvements
Summary: - Move strerror_s to Thrift.h (was previously in TTransportException.h)
         - Capture errno as soon as syscall returns failure and make it part of error message.
         - Cleaned up several instances of the wrong error value being printed.
         - More consistently pass the errno in the TTransport Exception
         - Add more consistent error logging for the various transport failure modes

Reviewed By: dreiss

Test Plan: - compile everything.
           - test on search tier

Revert: OK

TracCamp Project: Thrift

DiffCamp Revision: 11077


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665648 13f79535-47bb-0310-9956-ffa450edef68
2008-04-08 06:26:05 +00:00
David Reiss
22b1886dc7 use poll instead of select in TSocket
Summary: fd_set, which we pass into select only supports  fds with values < 1024.
         fds can be >= 1024.
         this can cause memory corruption

         learning this stuff over 2 weeks of examining crazy core dumps is way more fun that reading it up somewhere.

         poll takes an array of fds insetad, so your fd can be any int

Reviewed By: dreiss

Test Plan: ran inside a test search cluster

Revert: OK

DiffCamp Revision: 10731


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665647 13f79535-47bb-0310-9956-ffa450edef68
2008-04-08 06:25:45 +00:00
David Reiss
1ffb61beaa Fix a bug in TPipedTransport that broke pipelining.
Previously, TPipedTransport wrote it's full buffer to the "pipe" and
fully reset its buffer on a readEnd.  This assumed that the buffer was
fully read at that point.  This is not the case if requests are pipelined.
This change makes it only pipe out the portion that has been read and
copy the unread portion to the beginning of the buffer.

Also add a test that verifies the new functionality.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665646 13f79535-47bb-0310-9956-ffa450edef68
2008-04-08 05:07:26 +00:00
David Reiss
e4db03d110 Add TFDTransport: a dead-simple wrapper around a file-descriptor.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665644 13f79535-47bb-0310-9956-ffa450edef68
2008-04-08 05:06:59 +00:00
David Reiss
e0e3d1b232 Add TProtocolTap: a meta-protocol for "wiretapping".
TProtocolTap is a protocol that passes reads through to a "source" protocol,
but mirrors them as writes to a "sink" protocol.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665643 13f79535-47bb-0310-9956-ffa450edef68
2008-04-08 05:06:45 +00:00
David Reiss
642f2d3fbe TDebugProtocol: Add support for messages.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665642 13f79535-47bb-0310-9956-ffa450edef68
2008-04-08 05:06:32 +00:00
David Reiss
a80f0fb47a TDebugProtocol: Support a limit on string length.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665641 13f79535-47bb-0310-9956-ffa450edef68
2008-04-08 05:06:15 +00:00
David Reiss
58b4fa7e26 Fix a memory leak in TBinaryProtocol.
Summary:
realloc doesn't free the original pointer when it returns null.

Reviewed By: cpiro

Test Plan: make check

TracCamp Project: Thrift

Revert Plan: ok


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665626 13f79535-47bb-0310-9956-ffa450edef68
2008-04-01 04:17:58 +00:00
Christopher Piro
9cc63b53ef [thrift] add setTcp{Send,Recv}Buffer to C++ TSocketServer
Summary: needs moar BDPs

Reviewed By: mcslee

Test Plan: now using in our service

Revert Plan: ok


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665579 13f79535-47bb-0310-9956-ffa450edef68
2008-03-21 00:40:42 +00:00
David Reiss
8f3bce4153 TSocketPool changes
Summary: 1] Added empty constructor
         2] Added function to set server list
         3] Made getServers return by ref
         4] Made list of servers be a list of pointers

         The last change is so that someone can pass in the list of servers and rely on TSocketPool to change the failure time directly on the TSocketServer object

Reviewed By: aditya

Test Plan: Ran with a test search server

Revert: OK

DiffCamp Revision: 9529


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665571 13f79535-47bb-0310-9956-ffa450edef68
2008-03-18 18:21:52 +00:00
David Reiss
84e63abf2e Remove some trailing whitespace.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665564 13f79535-47bb-0310-9956-ffa450edef68
2008-03-07 20:12:28 +00:00
David Reiss
a79e48874b TNonblockingServer: Fix wrong exception names
Reviewed By: dreiss

Test Plan: trivial :)

Revert: OK

DiffCamp Revision: 8789


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665556 13f79535-47bb-0310-9956-ffa450edef68
2008-03-05 07:51:47 +00:00
David Reiss
edde04804b Thrift: Add writePtr(), wroteBytes() to TMemoryBuffer
Summary: This adds the discussed interface to TMemoryBuffer, as follows:

         - writePtr(size) returns a ptr you can write (size) bytes to
         - wroteBytes() lets it know you wrote that many bytes

         To do this, I refactored an:
         - ensureCanWrite(size) private func

Reviewed By: dreiss

Test Plan: works in my test environment

Revert: OK

TracCamp Project: Thrift

DiffCamp Revision: 8739


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665555 13f79535-47bb-0310-9956-ffa450edef68
2008-03-05 07:51:44 +00:00
David Reiss
631dcb42d1 Thrift: concurrency/Util.h: Add converters for 'struct timeval', cleanup
Summary: - Added 'struct timeval' toMilliseconds and toTimeval converters modeled on the timespec ones
         - Added constants for microsecs, and got rid of the 500000 and 500 magic #'s :)

Reviewed By: dreiss

Test Plan: works in my test env

Revert: OK

DiffCamp Revision: 8742


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665554 13f79535-47bb-0310-9956-ffa450edef68
2008-03-05 07:51:40 +00:00
David Reiss
907ad76c2d Adding a few integration points to the C++ TSocketPool.
- Adding ability to use a vector of TSocketPoolServers to construct a TSocketPool
- Ability to get back the list of TSocketPoolServers

This is especially useful in multithreaded client code that
will just keep around the list of servers, and create the pool
on every request. Since TSocketPool updates the failure stuff,
we need a way to get back the updated TSocketPoolServers

Reviewed By: aditya

Test Plan: just compiling the code


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665537 13f79535-47bb-0310-9956-ffa450edef68
2008-03-02 00:25:58 +00:00
David Reiss
2c9824c5bd Fix potential out of bounds read issue with getTypeIDForTypeName().
Make sure type name is at least 2 characters long.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665536 13f79535-47bb-0310-9956-ffa450edef68
2008-03-02 00:20:47 +00:00
David Reiss
f50021af66 Bug fix for C++ TSocketPool
Wasn't setting the host or port for each server in the pool on open.

Reviewed By: dbraginsky

Test Plan: Just compiled.  Will test with dbraginsky's server.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665535 13f79535-47bb-0310-9956-ffa450edef68
2008-02-29 07:33:47 +00:00
David Reiss
6d0cccd640 Fail and retry logic for TSocketPool
Summary: Replicating php logic: If opening fails enough times, mark server as down for some amount of time

Reviewed By: aditya

Test Plan: compiling thrift - any good test ideas?

Revert: OK

DiffCamp Revision: 8381


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665534 13f79535-47bb-0310-9956-ffa450edef68
2008-02-28 21:20:12 +00:00
David Reiss
9163073ca1 Fix for JSON Protocol string-reading methods.
Clear return-by-reference strings before appending to them
in the JSON Protocol reading methods.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665533 13f79535-47bb-0310-9956-ffa450edef68
2008-02-28 21:11:39 +00:00
David Reiss
1a3546464d Fix for Base64 decoding.
Previously, the Base64 decoding table only covered ASCII characters,
but the decoding function looked up any character in the table.
This change extends the table.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665532 13f79535-47bb-0310-9956-ffa450edef68
2008-02-28 21:11:34 +00:00
veeve
01d187cb80 add increase_max_fds to the new TServer.cpp
Summary: - added TServer.cpp
         - increase_max_fds() defaults to 2^24.

Reviewed By: dreiss

Test Plan: - Linked this code into chatloggerd and verified the return value.

Revert: OK

TracCamp Project: Chirp

DiffCamp Revision: 8275


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665500 13f79535-47bb-0310-9956-ffa450edef68
2008-02-26 05:12:08 +00:00
David Reiss
1e62ab468c TJSONProtocol no longer uses borrow, and miscellaneous fixes.
Summary:
Added a LookaheadReader to the TJSONProtocol so it doesn't have to
rely on the transport to borrow.
Also added a check to a corner case and fixed up some comments and whitespace.

Reviewed By: mcslee

Test Plan: make check

Revert Plan: ok


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665491 13f79535-47bb-0310-9956-ffa450edef68
2008-02-21 22:37:45 +00:00
David Reiss
d7a16f4c11 Thrift: Add "#include <cstdlib>" in a few places and s/malloc/std::malloc/
Summary:
There were a few places where we were calling malloc/reallaoc/free without
including cstdlib (or stdlib.h).  This is broken, but it worked because
other headers that we were including included stdlib.h.  However, on a
platform where this wasn't true, it broke the Thrift build.  This change
adds the proper includes.  It also changes malloc to std::malloc (same
with realloc and free) in a few places, because that is the correct way
of doing it when you include cstdlib.

Reviewed By: mcslee

Test Plan: Compiled Thrift.

Revert Plan: ok

Other Notes:
This bug was noticed by a Thrudb user, and the patch was sent in by
Ross McFarland.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665487 13f79535-47bb-0310-9956-ffa450edef68
2008-02-19 22:47:29 +00:00
David Reiss
db0ea15310 Thrift: Add a full-featured JSON protocol for C++.
Summary:
This change adds a new and exciting protocol to Thrift.  It uses
RFC-compliant JSON as the wire protocol and is fully human readable.
(once a little whitespace has been inserted.)  Unlike the existing
JSON protocol for Java, which is intended to allow Thrift data to be
transferred to scripting languages, this protocol is lossless and fully
read-write.  It was written by Chad Walters of Powerset and reviewed
by David Reiss.

Tested by running make check.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665482 13f79535-47bb-0310-9956-ffa450edef68
2008-02-18 01:49:37 +00:00
David Reiss
c005b1b65e Thrift: Distinguish between string and binary types in C++ and Java.
Summary:
The upcoming TJSONProtocol handles string and binary types quite differently.
This change makes that distinction in all parts of the C++ binding.

Java already distinguished between string and binary, but this change
also updates the Java skip method to skip over strings as binary
so we don't get encoding errors when skipping binary data.

Reviewed By: mcslee

Test Plan: make check

Revert Plan: ok

Other Notes:
I just pulled this out of Chad Walters' JSON patch.
The only other change was adding readBinary (or was it writeBinary)
to TDenseProtocol.  Maybe inheriting from TBinaryProtocol wasn't a good idea.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665481 13f79535-47bb-0310-9956-ffa450edef68
2008-02-15 01:38:18 +00:00
Mark Slee
a8de4895f6 Patch from Ross McFarland to compile with strict warnings
Summary: Use comment trick in params that are unused to prevent warnings

Reviewed By: dreiss

Test Plan: Generate C++ code and compile -W -Wall


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665469 13f79535-47bb-0310-9956-ffa450edef68
2008-02-09 00:02:26 +00:00
David Reiss
0c90f6f8af Thrift: Whitespace cleanup.
Summary:
- Expanded tabs to spaces where spaces were the norm.
- Deleted almost all trailing whitespace.
- Added newlines to the ends of a few files.
- Ran dos2unix on one file or two.

Reviewed By: mcslee

Test Plan: git diff -b

Revert Plan: ok


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665467 13f79535-47bb-0310-9956-ffa450edef68
2008-02-06 22:18:40 +00:00
David Reiss
f7baf549bc Thrift: Revamp TMemoryBuffer constructors.
Summary:
There were some weird cases where the implicit conversion from
const char* to std::string was causing the wrong constructor to be called.
There wasn't really a clean workaround, so we're dropping the string
constructors.

Reviewed By: mcslee

Test Plan:
Ran the test.
Grepped around the /projects tree for uses that had to fixed,
and fixed them.

Revert Plan: ok

Other Notes:
This risk was pointed out by Ben Maurer.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665461 13f79535-47bb-0310-9956-ffa450edef68
2008-02-04 21:56:27 +00:00
David Reiss
20f009d625 Thrift: Forgot to dereference a pointer.
Summary:
This didn't get updated when the interface changed,
and the cast silenced the warning message.  Stupid C.

Reviewed By: mcslee

Test Plan: Trust Chad Walters.

Revert Plan: ok


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665457 13f79535-47bb-0310-9956-ffa450edef68
2008-02-04 19:24:00 +00:00
David Reiss
f495f367c9 Thrift: Make borrow (almost) always succeed for TBufferedTransport.
Chad Walters is writing a JSON protocol for Thrift, but he wants
borrow to always succeed.  That would be a pain to implement,
but here is a first step: borrow will almost always work with
TBufferedTransport.

Reviewed by: mcslee

Test Plan: Ran the DenseProtocol test and Zlib test, but more needs to be done.

Other Notes:
Also reviewed by Chad Walters, and maybe Ben Maurer.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665455 13f79535-47bb-0310-9956-ffa450edef68
2008-02-02 00:54:55 +00:00
David Reiss
d46eb09bef Thrift: Update the interface for TTransport's "borrow" method.
Summary:
I don't know what I was thinking when I first wrote this.
It makes sense that the transport might not want to allocate its own memory,
so the protocol is expected to provide a buffer for the data.
However, if the transport already has the data buffered,
there is no need to memcpy it; it can just return a pointer into its buffer.
The new interface still requires the protocol to provide a buffer,
but allows the transport to return a pointer to an interal buffer.
In addition, I made len a pass-by-pointer parameter so that
the transport can return more than the requested data if it has it
available in its buffers.

Reviewed By: mcslee

Test Plan: Ran the DenseProtocol test and the Zlib test.

Revert Plan: ok

Other Notes:
Also got this reviewed by Chad Walters from Powerset.
Ben Maurer suggested making len a reference parameter.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665454 13f79535-47bb-0310-9956-ffa450edef68
2008-02-02 00:54:48 +00:00
Mark Slee
2e8a8d4095 Make sure exceptinos in servers are caught
Summary: There was potential for a write exception in close() because it might call flush() internally

Reviewed By: dreiss


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665430 13f79535-47bb-0310-9956-ffa450edef68
2008-01-16 00:38:20 +00:00
pfung
e8abada6ad [Thrift] disabling catching general type exceptions in Tthreadpoolserver
the threadpoolserver should just crash if an unknown exception type is thrown.

This should probably be true for all server types, will put this on the TODO list.

reviewed by jwang
test plan: network selector servers in production


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665412 13f79535-47bb-0310-9956-ffa450edef68
2008-01-05 23:23:53 +00:00
David Reiss
832b262aca Thrift: Revamp build to use a single configure.ac.
Summary:
Ben Maurer suggested that it would make sense for Thrift to build as
a single project, with one configure.ac and multiple Makefile.am.
He was also kind enough to do the heavy lifting, and this commit
is the application of his patch (with minor modifications).
The most significant visible change from this diff is that
in order to buidl one of the thrift sub-projects (i.e.: the compiler,
the C++ library, or the Python library) you must run bootstrap.sh
and configure in the Thrift root, then make in the specific project.
Users who want to build and install the Python library but
can't run configure because they don't have Boost can simply
run setup.py directly.

Reviewed By: mcslee

Test Plan: Built Thrift from scratch.

Revert Plan: ok


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665409 13f79535-47bb-0310-9956-ffa450edef68
2007-12-28 18:25:33 +00:00