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
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
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
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
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
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
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
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
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
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
- 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
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
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
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
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
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
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
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
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
- 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
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
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
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
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
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
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
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
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
- 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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