Date: Friday, February 9, 2007 @ 17:19:34
Author: gilles
Path: /cvsroot/carob/carob/src
Modified: Connection.cpp (1.111 -> 1.112)
Fixed bug in tryToReconnect() where were deleting the socket before calling
forceControllerDown() (which sets the socket cancel flag)
FO_CATCH_NTIMES now prints a log to be able to easily see where IOException
occured (it will be printed with the name of the function that uses it)
Minor formatting + logging clean-up
----------------+
Connection.cpp | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
Index: carob/src/Connection.cpp
diff -u carob/src/Connection.cpp:1.111 carob/src/Connection.cpp:1.112
--- carob/src/Connection.cpp:1.111 Wed Feb 7 16:32:33 2007
+++ carob/src/Connection.cpp Fri Feb 9 17:19:34 2007
@@ -73,6 +73,8 @@
}\
catch (const SocketIOException& sioe)\
{\
+ if (isInfoEnabled())\
+ logInfo(fctName, L"SocketIOException received");\
::sleep(static_cast<int>(foCnt*0.5)); /* sleep incrementally */\
reconnectOrDie();\
/* All controllers down? Maybe not, maybe it is OUR network \
@@ -319,10 +321,14 @@
buffer << reason;
logError(fctName, buffer.str());
- // Brutally close network socket FIRST, just like in tryToReconnect()
- try {
+ // Brutally close network socket FIRST, so other concurrent close() will not
+ // try to do the job twice
+ try
+ {
this->closeSocket();
- } catch (const SocketIOException& sioe) {
+ }
+ catch (const SocketIOException& sioe)
+ {
std::wostringstream buffer;
buffer << L"failed to force ->closeSocket(), probably already closed? " <<
sioe.description();
logError(fctName, buffer.str());
@@ -476,6 +482,7 @@
void Connection::setReadOnly(bool readOnlyPrm) throw (SocketIOException,
DriverException, UnexpectedException)
{
+ const wchar_t fctName[] = L"Connection::setReadOnly";
checkIfConnected();
FO_TRY_NTIMES(RECONNECT_RETRIES)
sendCommand(*driverSocketPtr, SetReadOnly);
@@ -1235,13 +1242,11 @@
void Connection::reconnectOrDie() throw (ConnectionException,
DriverException, UnexpectedException)
{
- const wchar_t fctName[] = L"Connection::reconnectOrDie";
bool reconnected = false;
while (!reconnected)
{
try
{
- logWarn(fctName, L"tryToReconnect()");
tryToReconnect();
reconnected = true;
}
@@ -1274,16 +1279,18 @@
if (isDebugEnabled())
logDebug(fctName, L"Closing socket of lost connection");
- // Brutally close network socket FIRST, just like in
corruptedConnectionClose()
- closeSocket();
-
// inform controller pool of the failure: even if the info came from the
// controller pool (ie. controller pool closed our socket), it is safe to
tell
// him again about the failure
+ // This must be done *before* closeSocket because forceControllerDown() will
+ // switch the socket to cancelled state
if (isDebugEnabled())
logDebug(fctName, L"Controller " +
static_cast<wstring>(connected_controller)
+ L" is not responding, suspecting it of failure");
controller_pool.forceControllerDown(connected_controller);
+
+ // It is now safe to close network socket
+ closeSocket();
// ...And try next one in the list
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits