From: David Reiss Date: Tue, 9 Mar 2010 05:19:27 +0000 (+0000) Subject: cpp: Exit TNonBlockingServer on memmory allocation failure X-Git-Tag: 0.3.0~94 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=28e88ecac1cab801112587068ee4fbc6de457e49;p=common%2Fthrift.git 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 --- diff --git a/lib/cpp/src/server/TNonblockingServer.cpp b/lib/cpp/src/server/TNonblockingServer.cpp index a9c1c159..26e97c96 100644 --- a/lib/cpp/src/server/TNonblockingServer.cpp +++ b/lib/cpp/src/server/TNonblockingServer.cpp @@ -62,6 +62,9 @@ class TConnection::Task: public Runnable { cerr << "TNonblockingServer client died: " << ttx.what() << endl; } catch (TException& x) { cerr << "TNonblockingServer exception: " << x.what() << endl; + } catch (bad_alloc&) { + cerr << "TNonblockingServer caught bad_alloc exception."; + exit(-1); } catch (...) { cerr << "TNonblockingServer uncaught exception." << endl; }