1 message in com.mysql.lists.dotnetConnector/NET commit: r151 - in branc...
FromSent OnAttachments
rbur...@mysql.com19 Aug 2005 13:56 
Subject:Connector/NET commit: r151 - in branches/1.0/mysqlclient: . common
From:rbur...@mysql.com (rbur@mysql.com)
Date:08/19/2005 01:56:27 PM
List:com.mysql.lists.dotnet

Modified: branches/1.0/mysqlclient/Connection.cs branches/1.0/mysqlclient/command.cs branches/1.0/mysqlclient/common/SocketStream.cs branches/1.0/mysqlclient/datareader.cs Log: Now using connection.Terminate() instead of connection.Close() in situations
where we get fatal Exceptions

We are now treating all exceptions received in writing to the socket as fatal

Added the MySqlConnection.Terminate() method

datareader.cs - using Connection.Terminate. Also, added EH to the GetFieldValue
method in the case we are using SequentialAccess

nativedriver.cs -

Modified: branches/1.0/mysqlclient/Connection.cs =================================================================== --- branches/1.0/mysqlclient/Connection.cs 2005-08-19 19:25:15 UTC (rev 150) +++ branches/1.0/mysqlclient/Connection.cs 2005-08-19 20:56:48 UTC (rev 151) @@ -306,6 +306,20 @@ ChangeDatabase(settings.Database); }

+ internal void Terminate() + { + try + { + if (settings.Pooling) + MySqlPoolManager.ReleaseConnection(driver); + else + driver.Close(); + } + catch (Exception) { } + + SetState(ConnectionState.Closed); + } + /// <include file='docs/MySqlConnection.xml' path='docs/Close/*'/> public void Close() { @@ -315,12 +329,7 @@ if (dataReader != null) dataReader.Close();

- if (settings.Pooling) - MySqlPoolManager.ReleaseConnection( driver ); - else - driver.Close(); - - SetState( ConnectionState.Closed ); + Terminate(); }

IDbCommand IDbConnection.CreateCommand()

Modified: branches/1.0/mysqlclient/command.cs =================================================================== --- branches/1.0/mysqlclient/command.cs 2005-08-19 19:25:15 UTC (rev 150) +++ branches/1.0/mysqlclient/command.cs 2005-08-19 20:56:48 UTC (rev 151) @@ -353,7 +353,7 @@ } catch (MySqlException ex) { - if (ex.IsFatal) connection.Close(); + if (ex.IsFatal) connection.Terminate(); throw; }

Modified: branches/1.0/mysqlclient/common/SocketStream.cs =================================================================== --- branches/1.0/mysqlclient/common/SocketStream.cs 2005-08-19 19:25:15 UTC (rev
150) +++ branches/1.0/mysqlclient/common/SocketStream.cs 2005-08-19 20:56:48 UTC (rev
151) @@ -108,31 +108,20 @@

public override void Write(byte[] buffer, int offset, int count) { - bool shouldClose = false; try { - socket.Send(buffer, offset, count, SocketFlags.None); + if (canWrite && socket != null) + socket.Send(buffer, offset, count, SocketFlags.None); } - catch (SocketException se) + catch (Exception ex) { - if (IsFatalSocketError(se.ErrorCode)) - shouldClose = true; - else - throw; + canRead = false; + canWrite = false; + socket.Shutdown(SocketShutdown.Both); + socket.Close(); + socket = null; + throw new MySqlException(ex.Message, true, ex); } - catch (ObjectDisposedException) - { - shouldClose = true; - } - finally - { - if (shouldClose) - { - canRead = false; - canWrite = false; - socket = null; - } - } }

Modified: branches/1.0/mysqlclient/datareader.cs =================================================================== --- branches/1.0/mysqlclient/datareader.cs 2005-08-19 19:25:15 UTC (rev 150) +++ branches/1.0/mysqlclient/datareader.cs 2005-08-19 20:56:48 UTC (rev 151) @@ -140,7 +140,7 @@ if (ex.IsFatal) { connection.Reader = null; - connection.Close(); + connection.Terminate(); } throw; } @@ -663,7 +663,8 @@ } catch (MySqlException ex) { - if (ex.IsFatal) connection.Close(); + if (ex.IsFatal) + connection.Terminate(); throw; }

@@ -685,7 +686,7 @@ catch (MySqlException ex) { if (ex.IsFatal) - connection.Close(); + connection.Terminate(); else connection.SetState( ConnectionState.Open ); throw; @@ -723,7 +724,8 @@ } catch (MySqlException ex) { - if (ex.IsFatal) connection.Close(); + if (ex.IsFatal) + connection.Terminate(); throw; }

@@ -750,11 +752,23 @@ if (index < 0 || index >= fields.Length) throw new ArgumentException( "You have specified an invalid column
ordinal." );

- MySqlValue val = currentResult.ReadColumnValue(index); - if ( readCount == 0 ) - throw new MySqlException("Invalid attempt to access a field before calling
Read()"); + try + { + MySqlValue val = currentResult.ReadColumnValue(index); + if ( readCount == 0 ) + throw new MySqlException("Invalid attempt to access a field before calling
Read()");

- return val; + return val; + } + catch (MySqlException ex) + { + if (ex.IsFatal) + { + connection.Reader = null; + connection.Terminate(); + } + throw; + } }