diff options
author | Francisco Figueiredo Jr. <fxjr@mono-cvs.ximian.com> | 2008-05-05 07:37:24 +0400 |
---|---|---|
committer | Francisco Figueiredo Jr. <fxjr@mono-cvs.ximian.com> | 2008-05-05 07:37:24 +0400 |
commit | c60bc724749fd172208d5044c9bcfdeb73931214 (patch) | |
tree | ffc1f8c2ebfb2601c94d4eaaf985fd6042cb00a3 /mcs/class/Npgsql | |
parent | ef6d6ffbc44171cfd0d928b084c5ee060476e834 (diff) |
2008-05-05 Francisco Figueiredo Jr. <francisco@npgsql.org>
Fixed problems when notification thread throws exception. Not is correctly thrown. See http://pgfoundry.org/forum/message.php?msg_id=1003387 for discussion about that. Thanks Josh Cooley for patch.
svn path=/trunk/mcs/; revision=102496
Diffstat (limited to 'mcs/class/Npgsql')
-rw-r--r-- | mcs/class/Npgsql/Npgsql/NpgsqlConnector.cs | 36 | ||||
-rw-r--r-- | mcs/class/Npgsql/Npgsql/NpgsqlConnectorPool.cs | 2 |
2 files changed, 23 insertions, 15 deletions
diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlConnector.cs b/mcs/class/Npgsql/Npgsql/NpgsqlConnector.cs index fd6c391b0aa..6a3c243652a 100644 --- a/mcs/class/Npgsql/Npgsql/NpgsqlConnector.cs +++ b/mcs/class/Npgsql/Npgsql/NpgsqlConnector.cs @@ -126,6 +126,9 @@ namespace Npgsql // Counter of notification thread start/stop requests in order to internal Int16 _notificationThreadStopCount; + // exception thrown from notification thread + private Exception _notificationException; + /// <summary> @@ -839,7 +842,8 @@ namespace Npgsql internal void StopNotificationThread() { - + if (_notificationException != null) + throw _notificationException; _notificationThreadStopCount++; if (_notificationThreadStopCount == 1) // If this call was the first to increment. @@ -887,24 +891,28 @@ namespace Npgsql internal void ProcessServerMessages() { - - while(true) + try { - this.connector._notificationAutoResetEvent.WaitOne(); - - if (this.connector.Socket.Poll(1000, SelectMode.SelectRead)) + while (true) { - // reset any responses just before getting new ones - this.connector.Mediator.ResetResponses(); - this.state.ProcessBackendResponses(this.connector); - this.connector.CheckErrorsAndNotifications(); + this.connector._notificationAutoResetEvent.WaitOne(); + + if (this.connector.Socket.Poll(1000, SelectMode.SelectRead)) + { + // reset any responses just before getting new ones + this.connector.Mediator.ResetResponses(); + this.state.ProcessBackendResponses(this.connector); + this.connector.CheckErrorsAndNotifications(); + } + + this.connector._notificationAutoResetEvent.Set(); } - + } + catch (IOException ex) + { + this.connector._notificationException = ex; this.connector._notificationAutoResetEvent.Set(); } - - - } } diff --git a/mcs/class/Npgsql/Npgsql/NpgsqlConnectorPool.cs b/mcs/class/Npgsql/Npgsql/NpgsqlConnectorPool.cs index 4690c8e654f..64a2f4f98b6 100644 --- a/mcs/class/Npgsql/Npgsql/NpgsqlConnectorPool.cs +++ b/mcs/class/Npgsql/Npgsql/NpgsqlConnectorPool.cs @@ -533,7 +533,7 @@ namespace Npgsql ClearQueue(queue); - PooledConnectors[Connection.ConnectionString.ToString()] = null; + PooledConnectors.Remove(Connection.ConnectionString.ToString()); } |