Commit Graph

389 Commits

Author SHA1 Message Date
Roger Meier
8a441a46ad THRIFT-940 use BOOST_LDFLAGS for unit tests, required to build on Mac OS X
Patch: Christian Lavoie


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1004431 13f79535-47bb-0310-9956-ffa450edef68
2010-10-04 21:13:36 +00:00
Bryan Duxbury
a18364ac88 THRIFT-900. cpp: Unix domain socket
This patch adds a new Unix Socket transport.

Patch: Roger Meier

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1002179 13f79535-47bb-0310-9956-ffa450edef68
2010-09-28 14:36:07 +00:00
Bryan Duxbury
7a0825c34d THRIFT-856. cpp: Building cpp library fails on OS X with malloc and free not being declared in scope
This patch adds include which seems to fix the problem for some people.

Patch: James Clarke

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@992013 13f79535-47bb-0310-9956-ffa450edef68
2010-09-02 16:42:18 +00:00
David Reiss
8ede81860c THRIFT-798. cpp: Reduce resource leakage by TNonblockingServer destructor
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991980 13f79535-47bb-0310-9956-ffa450edef68
2010-09-02 15:26:28 +00:00
Bryan Duxbury
383e949566 THRIFT-567. cpp: Can't immediately stop a TSimpleServer thread that is idle
This interrupts the server in addition to setting the stop flag.

Patch: Rush Manbert

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991974 13f79535-47bb-0310-9956-ffa450edef68
2010-09-02 15:16:56 +00:00
Bryan Duxbury
010f1e09d0 THRIFT-756. cpp: Exposing TSocket(int) constructor to public
This patch changes the raw socket handle constructor from protected to public.

Patch: Rajat Goel

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991785 13f79535-47bb-0310-9956-ffa450edef68
2010-09-02 00:56:53 +00:00
David Reiss
351e22b52a THRIFT-503. cpp: Move the tests built by "make check" under lib/cpp
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991246 13f79535-47bb-0310-9956-ffa450edef68
2010-08-31 16:51:19 +00:00
David Reiss
2b45589aa3 THRIFT-500. Remove unnecessary "ACLOCAL_AMFLAGS" line from lib/cpp/Makefile.am
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991242 13f79535-47bb-0310-9956-ffa450edef68
2010-08-31 16:51:11 +00:00
Bryan Duxbury
184d26237a THRIFT-851. php: php extension fails to compile on centos 5.x
This patch introduces an approach that is compatbile with both centos and Mac.

Patch: Todd Lipcon

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@986410 13f79535-47bb-0310-9956-ffa450edef68
2010-08-17 17:43:58 +00:00
David Reiss
cdde1854e7 THRIFT-247. Commit files missing from r985031
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@985068 13f79535-47bb-0310-9956-ffa450edef68
2010-08-13 02:06:08 +00:00
David Reiss
112e30985b THRIFT-247. cpp: Basic THttpServer implementation for C++
This does not integrate with any existing HTTP server.  Rather, it is a
transport that parses HTTP requests to allow any of the blocking
socket-based servers to handle HTTP.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@985031 13f79535-47bb-0310-9956-ffa450edef68
2010-08-12 23:03:29 +00:00
Bryan Duxbury
7ba364f7d8 revert unintentional partial commit of THRIFT-247
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@980204 13f79535-47bb-0310-9956-ffa450edef68
2010-07-28 20:45:37 +00:00
Bryan Duxbury
23f2348fae add ASL to a handful of files
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@980145 13f79535-47bb-0310-9956-ffa450edef68
2010-07-28 18:23:22 +00:00
David Reiss
318a328aec THRIFT-736. cpp: Check for availability of pthread_mutex_timedlock
r920679 introduced a call to pthread_mutex_timedlock, which is not
available on all UNIX variants.  In particular, it is missing on Mac OS.
Add a preprocessor check for the relevant feature macro.  If it fails,
just use a trylock.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@925940 13f79535-47bb-0310-9956-ffa450edef68
2010-03-22 02:34:57 +00:00
David Reiss
5f013bb45d cpp: Fix build problems introduced by r920682
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@921591 13f79535-47bb-0310-9956-ffa450edef68
2010-03-10 22:11:26 +00:00
David Reiss
767c1a90fe cpp: Minor TSocketPool cleanups
- Make sure the underlying socket is always closed.
- Don't reconnect on repeated calls to open.
- Move some code outside of a try block.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920691 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:28 +00:00
David Reiss
450c240592 cpp: Make an implicit virtual declaration explicit
This changes nothing since it's already declared virtual in the parent,
but this is clearer.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920690 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:26 +00:00
David Reiss
472fffb375 cpp: Don't leak memory on realloc failure in TNonblockingServer
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920689 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:24 +00:00
David Reiss
ccd4bdb2ae cpp: Implement peek() for TFileTransport
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920688 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:21 +00:00
David Reiss
336c29dbbe cpp: Prevent TFileTransport seekToEnd from leaking memory
In seekToEnd we loop on readEvent to skip through the last chunk, but
the complete events returned are disowned by readState_ and therefore
must be freed by the caller.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920687 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:19 +00:00
David Reiss
8af018bf13 cpp: Prevent TFileTransport from throwing uncaught exceptions
FilleTransport::writerThread throws exceptions. This function is run
inside the writer thread, so these exceptions are not caught. When these
exceptions happen, the system aborts.

The fix is to first eliminate all the throw commands inside this function. In
addition, add some error recovery logic into the code: whenever an IO error
happens, we enter into an error recovery mode. Go to sleep for a few seconds
then try to reopen the file.

Note: Currently, when errors happen, we drop events.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920686 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:17 +00:00
David Reiss
1c20c871d2 cpp: Add setLowRTO to TSocket
low tcp RTO might mitigate TCP incast problems. Adding the setLowRTO
function to TSocket allows us to experiment with a solution.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920685 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:14 +00:00
David Reiss
71a1530c74 cpp: Fix memory corruption bug in TBufferedTransport::borrowSlow()
On one code path, the code would read data past the end of its buffer.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920684 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:12 +00:00
David Reiss
eee98bede4 cpp: Disable IPV6_V6ONLY only if the socket is an AF_INET6 socket
Some systems may disable IPV6 completely.  Ensure that we only disable
IPV6_V6ONLY if the socket is AF_INET6

No longer see the warning:

Thrift: Wed Jul 22 18:08:36 2009 TServerSocket::listen() IPV6_V6ONLY Protocol not available

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920683 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:10 +00:00
David Reiss
ac110e4f1c cpp: Eliminate circular dependency between thrift libraries
Previously, Thrift.cpp contained TApplicationException, which was using
TProtocol methods, defined in TProtocol.h.  This caused a circular
dependency since libprotocol depends on Thrift.h.  This change moves
TApplicationException into its own file.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920682 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:07 +00:00
David Reiss
7a2065d3db cpp: Add profiling hooks to Mutex, ReadWriteMutex() classes
Extend the Thrift C++ Concurrency library by allowing a user to register
a callback and a sample rate for lock primitive contention profiling.
The callback will be invoked approximately once every sampleRate calls
to Mutex::lock(), Mutex::timedlock(), ReadWriteLock::acquireRead(), or
ReadWriteLock::acquireWrite().

The callback receives a pointer to the mutex responsible and the time
waited on the lock in micros (whether the lock was successfuly acquire
or not).  The user can then implement a registry of his choice to
log/collect this data as needed.

This can all be easily compiled out if it harms performance.  By
default, there is no profiling callback, so the overhead is minimal
(one branch).

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920681 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:04 +00:00
David Reiss
4cc0755b33 cpp: Fix a race/deadlock in ThreadManager
When removing a task from the pending queue, we were only notifying a
blocked thread waiting to enqueue a task if the number of pending tasks
was exactly one less than the limit.  However, if two tasks are finished
at about the same time, this can result in two spots being freed up with
only one notify.  With this change, we always notify on task completion,
eliminating the race/deadlock.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920680 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:01 +00:00
David Reiss
4e19f1914e cpp: non-blocking add for ThreadManager
It's rare for the ThreadManager mutex to be contended, but it is
possible.  For nonblocking applications, it is necessary to have a
strict timeout for the lock acquisition.  With this change, that timeout
is enforced.  Also add timeout parameters to Mutex::lock and
Guard::Guard to support this feature.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920679 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:59 +00:00
David Reiss
6c1ee214c4 cpp: Extend FunctionRunner to support periodic calls (in a thread)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920678 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:56 +00:00
David Reiss
a1a15112fe cpp: TSocket: call a second gettimeofday only for error checking
Previously, we called gettimeofday twice for every send, which is
costly.  Now, we only make the second call if send fails with EAGAIN.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920677 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:54 +00:00
David Reiss
eed92991cf cpp: TSocketPool: Optimize the case of a single server in the pool.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920676 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:52 +00:00
David Reiss
8106ba617a cpp: TSocketPool: make it possible to add servers by struct
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920675 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:50 +00:00
David Reiss
9c22ba4103 cpp: TTransport: set END_OF_FILE TException code if read returns 0
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920674 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:47 +00:00
David Reiss
068f4169b9 cpp: TNonblockingServer: Allow unrun tasks to expire after a time limit
Enhance ThreadManager to allow a expiration time interval to be assigned
to tasks, and expire those tasks after that time limit has passed.
Enhance TNonblockingServer to utilize this capability so it can be used
for overload resilience.

Note: expired entries are only removed from the queue head, so the
mechanism in ThreadManager may not do what you expect if you have
heterogeneous expiration times. That's not an issue with
TNonblockingServer (which will give all tasks the same limit) and might
not be in other cases where most tasks have the same limit and the rest
execute quickly. A full-up timeout queue would be more complex and have
greater overhead than that used here. It's unnecessary for the task at
hand so I didn't go that route...

The TNonblocking interface is simple: a setTaskExpireTime() accepts a
64-bit millisecond argument. 0 means infinite. A getTaskExpireTime()
accessor completes the interface.

The ThreadManager interface involves an added argument to add() for the
expiration interval and a setExpireCallback() function for setting a
callback that is called for expired tasks (for this project this is
necessary to shut down the associated connection).

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920673 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:45 +00:00
David Reiss
58e4d2c6e3 cpp: Log unexpected exceptions in TThreadPoolServer
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920672 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:43 +00:00
David Reiss
450e35d2a3 cpp: Fix max TCP port number
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920671 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:41 +00:00
David Reiss
9e8073c5cd Eliminate some trailing whitespace
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920670 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:39 +00:00
David Reiss
e96fa5502f cpp: Add enum and constructor to RWGuard to make read/write more visible
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920669 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:37 +00:00
David Reiss
83b8fdac0f cpp: Fix for task completion notification deadlock under heavy server load
Along with insuring that the event loop is able to see task completion
notifications, we need to process pending notifications as soon as they
are available to avoid filling the notification pipe (the pipe can hold
512 notifications).

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920668 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:34 +00:00
David Reiss
a0dbfefbf3 cpp: TNonBlockingServer: Use separate monitor for max queue
We were using the same monitor for max queue size and empty queue, this
meant the notifies might be going to the wrong place.

This change significantly reduces the time spent in futex calls in
loaded servers.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920667 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:32 +00:00
David Reiss
b9db49c677 cpp: Let Monitors share Mutex instances
- Let Monitor objects share a Mutex() instance so that more than one
  condition can be implemented on top of a single mutex protecting an
  important data structure.
- Make Mutex and Monitor noncopyable
- Add an accessor to Mutex() so the underlying pthread_mutex_t* can be
  retrieved for passing to pthread_condwait
- Change Monitor to use the actual Mutex class instead of creating a
  naked pthread_mutex_t on its own
- Add new constructors to Monitor

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920666 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:30 +00:00
David Reiss
28e88ecac1 cpp: Exit TNonBlockingServer on memmory allocation failure
setrlimit causes bad_alloc exceptions, but undefined behavior occurs if
we don't exit.  It is not typical for libraries to call exit, but it is
not clear what other behavior is possible.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920665 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:27 +00:00
David Reiss
01fe15322f cpp: TNonBlockingServer overload handling and optimizations
- Establish a mechanism for TNonBlockingServer to handle overloads by
  limiting the number of connections accepted or in-process.

- Provide a framework for further work in handling server overloads.

- Limit memory consumption of connection object pool.

- Drop connections when overloaded.

- Add overload-handling behavior allowing pending tasks to be dropped
  from the front of the task queue (short of the ability to terminate
  running tasks, these are the oldest tasks in the system and thus the
  most likely to be beyond their freshness date).  This reduces the
  chance of spending valuable CPU time processing a request that the
  client has already timed out.

- Uses a single persistent pipe() to communicate task completion instead
  of constructing and monitoring a new socketpair() for every task in
  the system.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920664 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:25 +00:00
David Reiss
4ae8780c5c THRIFT-706. cpp: Fix memory leak of string_buf_ in TCompactProtocol
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920597 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 00:49:14 +00:00
David Reiss
3bb5e0581a THRIFT-683. Remove profanity
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@902941 13f79535-47bb-0310-9956-ffa450edef68
2010-01-25 19:31:31 +00:00
David Reiss
9b90344445 THRIFT-606. cpp: Fix build on Solaris Nevada
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@827890 13f79535-47bb-0310-9956-ffa450edef68
2009-10-21 05:51:28 +00:00
David Reiss
3e7fca421e THRIFT-587. cpp: Properly set addrLen before accept calls
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@816850 13f79535-47bb-0310-9956-ffa450edef68
2009-09-19 01:59:13 +00:00
David Reiss
ffff2b3576 THRIFT-214. cpp: Qualify another cast
r722337 only fixed one occurrence of this issue.
Not sure why this one hasn't been a problem before,
but it is breaking compilation on Mac OS 10.6.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@810150 13f79535-47bb-0310-9956-ffa450edef68
2009-09-01 18:03:07 +00:00
David Reiss
3029786ce1 THRIFT-555. cpp: Fix macro defintions for TCompact on non-GNU big endian
We were defining ntolell and letonll, but we were only using
htolell and letohll.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@801293 13f79535-47bb-0310-9956-ffa450edef68
2009-08-05 16:42:59 +00:00
David Reiss
52687eb3b9 THRIFT-469. cpp: Fix a bug in TimerManager::add
The old code didn't notify waiters when the inserted task's timeout
was less than the current timeout because it didn't check the task map
to find the lowest timeout until after the new task was inserted.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@781630 13f79535-47bb-0310-9956-ffa450edef68
2009-06-04 00:32:57 +00:00