summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2004-02-20 17:44:41 +0000
committerMarc Laukien <marc@zeroc.com>2004-02-20 17:44:41 +0000
commitf86bb34ec33de67fcc569d1f8cf6df2a6b7af6ad (patch)
tree520786ae72c4376b505f21f8adf9f5ea522cf9bf /cpp/src
parentWin32 fixes (diff)
downloadice-f86bb34ec33de67fcc569d1f8cf6df2a6b7af6ad.tar.bz2
ice-f86bb34ec33de67fcc569d1f8cf6df2a6b7af6ad.tar.xz
ice-f86bb34ec33de67fcc569d1f8cf6df2a6b7af6ad.zip
C++ -> Java
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Application.cpp42
-rw-r--r--cpp/src/Ice/Connection.cpp87
-rw-r--r--cpp/src/Ice/Connection.h5
-rw-r--r--cpp/src/Ice/Incoming.cpp4
-rw-r--r--cpp/src/Ice/IncomingAsync.cpp4
-rw-r--r--cpp/src/Ice/Instance.cpp7
-rw-r--r--cpp/src/Ice/Outgoing.cpp18
-rw-r--r--cpp/src/slice2cpp/Gen.cpp10
-rw-r--r--cpp/src/slice2java/Gen.cpp48
9 files changed, 63 insertions, 162 deletions
diff --git a/cpp/src/Ice/Application.cpp b/cpp/src/Ice/Application.cpp
index cb2bb9716a3..7d01726d313 100644
--- a/cpp/src/Ice/Application.cpp
+++ b/cpp/src/Ice/Application.cpp
@@ -42,7 +42,7 @@ const DWORD SIGHUP = CTRL_LOGOFF_EVENT;
#endif
//
-// CtrlCHandler callbacks
+// CtrlCHandler callbacks.
//
static void holdInterruptCallback(int signal)
@@ -55,7 +55,8 @@ static void holdInterruptCallback(int signal)
}
}
- // Use the current callback to process this (old) signal
+ //
+ // Use the current callback to process this (old) signal.
//
CtrlCHandlerCallback callback = _ctrlCHandler->getCallback();
if(callback != 0)
@@ -192,7 +193,7 @@ Ice::Application::main(int argc, char* argv[], const char* configFile)
}
//
- // Ignore signals for a little while
+ // Ignore signals for a little while.
//
_ctrlCHandler.reset(new IceUtil::CtrlCHandler);
@@ -213,10 +214,9 @@ Ice::Application::main(int argc, char* argv[], const char* configFile)
cerr << _appName << ": " << ex << endl;
status = EXIT_FAILURE;
}
- /*
catch(const std::exception& ex)
{
- cerr << _appName << ": std::exception5: " << ex.what() << endl;
+ cerr << _appName << ": std::exception: " << ex.what() << endl;
status = EXIT_FAILURE;
assert(0);
}
@@ -225,7 +225,7 @@ Ice::Application::main(int argc, char* argv[], const char* configFile)
cerr << _appName << ": " << msg << endl;
status = EXIT_FAILURE;
}
- catch(const char * msg)
+ catch(const char* msg)
{
cerr << _appName << ": " << msg << endl;
status = EXIT_FAILURE;
@@ -235,14 +235,13 @@ Ice::Application::main(int argc, char* argv[], const char* configFile)
cerr << _appName << ": unknown exception" << endl;
status = EXIT_FAILURE;
}
- */
if(_communicator)
{
//
- // We don't want to handle signals anymore
+ // We don't want to handle signals anymore.
//
- ignoreInterrupt(); // will release any signal still held
+ ignoreInterrupt(); // Will release any signal still held.
_ctrlCHandler.reset();
try
@@ -254,26 +253,7 @@ Ice::Application::main(int argc, char* argv[], const char* configFile)
cerr << _appName << ": " << ex << endl;
status = EXIT_FAILURE;
}
- catch(const std::exception& ex)
- {
- cerr << _appName << ": std::exception: " << ex.what() << endl;
- status = EXIT_FAILURE;
- }
- catch(const std::string& msg)
- {
- cerr << _appName << ": " << msg << endl;
- status = EXIT_FAILURE;
- }
- catch(const char * msg)
- {
- cerr << _appName << ": " << msg << endl;
- status = EXIT_FAILURE;
- }
- catch(...)
- {
- cerr << _appName << ": unknown exception" << endl;
- status = EXIT_FAILURE;
- }
+
_communicator = 0;
}
@@ -372,17 +352,19 @@ Ice::Application::releaseInterrupt()
StaticMutex::Lock lock(_mutex);
if(_ctrlCHandler->getCallback() == holdInterruptCallback)
{
+ //
// Note that it's very possible no signal is held;
// in this case the callback is just replaced and
// setting _released to true and signalling _condVar
// do no harm.
+ //
_released = true;
_ctrlCHandler->setCallback(_previousCallback);
lock.release();
_condVar->signal();
}
- // else nothing to release
+ // Else nothing to release.
}
bool
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp
index bfb0fbcff39..39e4f3772c3 100644
--- a/cpp/src/Ice/Connection.cpp
+++ b/cpp/src/Ice/Connection.cpp
@@ -343,9 +343,11 @@ IceInternal::Connection::monitor()
if(_acmTimeout > 0 &&
_requests.empty() &&
_asyncRequests.empty() &&
- _batchStream.b.empty() &&
+ !_batchStreamInUse &&
_dispatchCount == 0)
{
+ assert(_batchStream.b.empty());
+
if(IceUtil::Time::now() >= _acmAbsoluteTimeout)
{
setState(StateClosing, ConnectionTimeoutException(__FILE__, __LINE__));
@@ -354,6 +356,9 @@ IceInternal::Connection::monitor()
}
}
+//
+// TODO: Should not be a member function of Connection.
+//
void
IceInternal::Connection::prepareRequest(BasicStream* os)
{
@@ -418,11 +423,11 @@ IceInternal::Connection::sendRequest(BasicStream* os, Outgoing* out)
try
{
IceUtil::Mutex::Lock sendSync(_sendMutex);
+
if(!_transceiver) // Has the transceiver already been closed?
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- assert(_exception.get());
- _exception->ice_throw();
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
}
bool compress;
@@ -575,11 +580,11 @@ IceInternal::Connection::sendAsyncRequest(BasicStream* os, const OutgoingAsyncPt
try
{
IceUtil::Mutex::Lock sendSync(_sendMutex);
+
if(!_transceiver) // Has the transceiver already been closed?
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
assert(_exception.get());
- _exception->ice_throw();
+ _exception->ice_throw(); // The exception is immutable at this point.
}
bool compress;
@@ -675,21 +680,21 @@ IceInternal::Connection::sendAsyncRequest(BasicStream* os, const OutgoingAsyncPt
void
IceInternal::Connection::prepareBatchRequest(BasicStream* os)
{
- lock();
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
//
// Wait if flushing is currently in progress.
//
- while(_batchFlushInProgress)
+ while(_batchStreamInUse && !_exception.get())
{
wait();
}
if(_exception.get())
{
- unlock();
_exception->ice_throw();
}
+
assert(_state > StateNotValidated);
assert(_state < StateClosing);
@@ -702,44 +707,41 @@ IceInternal::Connection::prepareBatchRequest(BasicStream* os)
catch(const LocalException& ex)
{
setState(StateClosed, ex);
- unlock();
ex.ice_throw();
}
}
+ _batchStreamInUse = true;
_batchStream.swap(*os);
//
- // The Connection and _batchStream now belongs to the caller,
- // until finishBatchRequest() or abortBatchRequest() is called.
+ // _batchStream now belongs to the caller, until
+ // finishBatchRequest() is called.
//
}
void
IceInternal::Connection::finishBatchRequest(BasicStream* os)
{
- assert(!_batchFlushInProgress);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
if(_exception.get())
{
- unlock();
_exception->ice_throw();
}
+
assert(_state > StateNotValidated);
assert(_state < StateClosing);
_batchStream.swap(*os); // Get the batch stream back.
++_batchRequestNum; // Increment the number of requests in the batch.
- unlock(); // Give the Connection back.
-}
-
-void
-IceInternal::Connection::abortBatchRequest()
-{
- assert(!_batchFlushInProgress);
- setState(StateClosed, AbortBatchRequestException(__FILE__, __LINE__));
- unlock(); // Give the Connection back.
+ //
+ // Give the Connection back.
+ //
+ assert(_batchStreamInUse);
+ _batchStreamInUse = false;
+ notifyAll();
}
void
@@ -748,20 +750,13 @@ IceInternal::Connection::flushBatchRequest()
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- //
- // Wait if flushing is currently in progress.
- //
- while(_batchFlushInProgress)
+ while(_batchStreamInUse && !_exception.get())
{
wait();
}
if(_exception.get())
{
- //
- // Since batch requests are all oneways (or datagrams), we
- // must report the exception to the caller.
- //
_exception->ice_throw();
}
@@ -784,17 +779,17 @@ IceInternal::Connection::flushBatchRequest()
// Prevent that new batch requests are added while we are
// flushing.
//
- _batchFlushInProgress = true;
+ _batchStreamInUse = true;
}
try
{
IceUtil::Mutex::Lock sendSync(_sendMutex);
+
if(!_transceiver) // Has the transceiver already been closed?
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
assert(_exception.get());
- _exception->ice_throw();
+ _exception->ice_throw(); // The exception is immutable at this point.
}
//
@@ -866,16 +861,6 @@ IceInternal::Connection::flushBatchRequest()
assert(_exception.get());
//
- // Reset the batch stream, and notify that flushing is over.
- //
- BasicStream dummy(_instance.get());
- _batchStream.swap(dummy);
- assert(_batchStream.b.empty());
- _batchRequestNum = 0;
- _batchFlushInProgress = false;
- notifyAll();
-
- //
// Since batch requests are all oneways (or datagrams), we
// must report the exception to the caller.
//
@@ -892,7 +877,7 @@ IceInternal::Connection::flushBatchRequest()
_batchStream.swap(dummy);
assert(_batchStream.b.empty());
_batchRequestNum = 0;
- _batchFlushInProgress = false;
+ _batchStreamInUse = false;
notifyAll();
}
}
@@ -903,11 +888,11 @@ IceInternal::Connection::sendResponse(BasicStream* os, Byte compressFlag)
try
{
IceUtil::Mutex::Lock sendSync(_sendMutex);
+
if(!_transceiver) // Has the transceiver already been closed?
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
assert(_exception.get());
- _exception->ice_throw();
+ _exception->ice_throw(); // The exception is immutable at this point.
}
bool compress;
@@ -1197,7 +1182,6 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
try
{
-
switch(messageType)
{
case requestMsg:
@@ -1484,7 +1468,7 @@ IceInternal::Connection::exception(const LocalException& ex)
string
IceInternal::Connection::toString() const
{
- return _desc;
+ return _desc; // No mutex lock, _desc is immutable.
}
bool
@@ -1526,8 +1510,8 @@ IceInternal::Connection::Connection(const InstancePtr& instance,
_requestsHint(_requests.end()),
_asyncRequestsHint(_asyncRequests.end()),
_batchStream(_instance.get()),
+ _batchStreamInUse(false),
_batchRequestNum(0),
- _batchFlushInProgress(false),
_dispatchCount(0),
_state(StateNotValidated),
_stateTime(IceUtil::Time::now())
@@ -1718,7 +1702,7 @@ IceInternal::Connection::setState(State state)
// close the transceiver.
//
IceUtil::Mutex::Lock sendSync(_sendMutex);
-
+
try
{
_transceiver->close();
@@ -1728,7 +1712,6 @@ IceInternal::Connection::setState(State state)
// Here we ignore any exceptions in close().
}
- assert(_transceiver);
_transceiver = 0;
//notifyAll(); // We notify already below.
}
diff --git a/cpp/src/Ice/Connection.h b/cpp/src/Ice/Connection.h
index e984900eff0..e8a3eba7882 100644
--- a/cpp/src/Ice/Connection.h
+++ b/cpp/src/Ice/Connection.h
@@ -71,7 +71,6 @@ public:
void prepareBatchRequest(BasicStream*);
void finishBatchRequest(BasicStream*);
- void abortBatchRequest();
void flushBatchRequest();
void sendResponse(BasicStream*, Ice::Byte);
@@ -159,13 +158,13 @@ private:
std::auto_ptr<Ice::LocalException> _exception;
BasicStream _batchStream;
+ bool _batchStreamInUse;
int _batchRequestNum;
- bool _batchFlushInProgress;
int _dispatchCount;
State _state; // The current state.
- IceUtil::Time _stateTime; // The time when the state was changed the last time.
+ IceUtil::Time _stateTime; // The last time when the state was changed.
//
// We have a separate mutex for sending, so that we don't block
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index f282cedb669..6610a8e5e59 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -319,7 +319,7 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
{
if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- __warning(string("std::exception3: ") + ex.what());
+ __warning(string("std::exception: ") + ex.what());
}
if(_response)
@@ -328,7 +328,7 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
_os.b.resize(headerSize + 4); // Dispatch status position.
_os.write(static_cast<Byte>(DispatchUnknownException));
ostringstream str;
- str << "std::exception4: " << ex.what();
+ str << "std::exception: " << ex.what();
_os.write(str.str());
}
diff --git a/cpp/src/Ice/IncomingAsync.cpp b/cpp/src/Ice/IncomingAsync.cpp
index 55999e70949..80cdc47997c 100644
--- a/cpp/src/Ice/IncomingAsync.cpp
+++ b/cpp/src/Ice/IncomingAsync.cpp
@@ -182,7 +182,7 @@ IceInternal::IncomingAsync::__exception(const std::exception& ex)
if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- __warning(string("std::exception1: ") + ex.what());
+ __warning(string("std::exception: ") + ex.what());
}
if(_response)
@@ -191,7 +191,7 @@ IceInternal::IncomingAsync::__exception(const std::exception& ex)
_os.b.resize(headerSize + 4); // Dispatch status position.
_os.write(static_cast<Byte>(DispatchUnknownException));
ostringstream str;
- str << "std::exception2: " << ex.what();
+ str << "std::exception: " << ex.what();
_os.write(str.str());
}
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 0b3756b7e5e..57fba4dfdb8 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -505,9 +505,12 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Prope
Int num = _properties->getPropertyAsIntWithDefault("Ice.ConnectionIdleTime", 60);
if(num < 0)
{
- num = 0;
+ const_cast<Int&>(_connectionIdleTime) = 0;
+ }
+ else
+ {
+ const_cast<Int&>(_connectionIdleTime) = num;
}
- const_cast<Int&>(_connectionIdleTime) = num;
}
_routerManager = new RouterManager;
diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp
index 72cd38182cf..4b08b722afd 100644
--- a/cpp/src/Ice/Outgoing.cpp
+++ b/cpp/src/Ice/Outgoing.cpp
@@ -85,15 +85,6 @@ IceInternal::Outgoing::Outgoing(Connection* connection, Reference* ref, const st
_os.startWriteEncaps();
}
-IceInternal::Outgoing::~Outgoing()
-{
- if(_state == StateUnsent &&
- (_reference->mode == Reference::ModeBatchOneway || _reference->mode == Reference::ModeBatchDatagram))
- {
- _connection->abortBatchRequest();
- }
-}
-
bool
IceInternal::Outgoing::invoke()
{
@@ -230,15 +221,8 @@ IceInternal::Outgoing::invoke()
//
// For batch oneways and datagrams, the same rules as for
// regular oneways and datagrams (see comment above)
- // apply, except that we must set the state to
- // StateInProgress before calling finishBatchRequest.
- // Otherwise if finishBatchRequest raises an exception,
- // the destructor of this class will call
- // abortBatchRequest, and calling both finishBatchRequest
- // and abortBatchRequest for the same request is not
- // permissible.
+ // apply.
//
- _state = StateInProgress;
_connection->finishBatchRequest(&_os);
break;
}
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index acb44b529af..de76e3677eb 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -646,10 +646,6 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
string scoped = fixKwd(p->scoped());
string scope = fixKwd(p->scope());
- //
- // TODO: ice_marshal/ice_unmarshal, __write/__read can be
- // moved into the helper.
- //
H << sp << nl << "class __U__" << name << " { };";
H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "&, __U__" << name
<< ");";
@@ -672,6 +668,8 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
C << nl << "::Ice::Int sz;";
C << nl << "__is->readSize(sz);";
//
+ // TODO:
+ //
// ML: Don't use v.resize(sz) or v.reserve(sz) here, as it
// cannot be checked whether sz is a reasonable value.
//
@@ -716,10 +714,6 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
string scoped = fixKwd(p->scoped());
string scope = fixKwd(p->scope());
- //
- // TODO: ice_marshal/ice_unmarshal, __write/__read can be
- // moved into the helper.
- //
H << sp << nl << "class __U__" << name << " { };";
H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name
<< "&, __U__" << name << ");";
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index f6ff122b56d..ac94bc5926e 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -2344,6 +2344,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sp;
out << nl << "public void" << nl << opName << "_async(" << paramsAMI << ", java.util.Map __context)";
out << sb;
+ /*
out << nl << "int __cnt = 0;";
out << nl << "while(true)";
out << sb;
@@ -2362,6 +2363,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << nl << "__cnt = __handleException(__ex, __cnt);";
out << eb;
out << eb;
+ */
out << eb;
}
}
@@ -3007,14 +3009,6 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
out << "java.util.Map __context)";
writeDelegateThrowsClause(package, throws);
out << ';';
-
- if(p->hasMetaData("ami") || op->hasMetaData("ami"))
- {
- string paramsAMI = getParamsAsync(op, package, false);
-
- out << sp;
- out << nl << "void " << opName << "_async(" << paramsAMI << ", java.util.Map __context);";
- }
}
out << eb;
@@ -3180,33 +3174,6 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
out << nl << "reclaimOutgoing(__out);";
out << eb;
out << eb;
-
- if(p->hasMetaData("ami") || op->hasMetaData("ami"))
- {
- string paramsAMI = getParamsAsync(op, package, false);
-
- out << sp;
- out << nl << "public void" << nl << opName << "_async(" << paramsAMI << ", java.util.Map __context)";
- out << sb;
-
- out << nl << "__cb.__setup(__connection, __reference, \"" << op->name() << "\", " << sliceModeToIceMode(op)
- << ", __context);";
- if(!inParams.empty())
- {
- out << nl << "IceInternal.BasicStream __os = __cb.__os();";
- }
- iter = 0;
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- writeMarshalUnmarshalCode(out, package, q->first, fixKwd(q->second), true, iter);
- }
- if(op->sendsClasses())
- {
- out << nl << "__os.writePendingObjects();";
- }
- out << nl << "__cb.__invoke();";
- out << eb;
- }
}
out << eb;
@@ -3328,17 +3295,6 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
out << eb;
}
out << eb;
-
- if(p->hasMetaData("ami") || op->hasMetaData("ami"))
- {
- string paramsAMI = getParamsAsync(op, package, false);
-
- out << sp;
- out << nl << "public void" << nl << opName << "_async(" << paramsAMI << ", java.util.Map __context)";
- out << sb;
- out << nl << "throw new Ice.CollocationOptimizationException();";
- out << eb;
- }
}
out << eb;