[Mono-bugs] [Bug 77785][Nor] Changed - SQLServerSessionState cannot update session when the connection is closed by the server

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Mar 14 06:04:33 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by informatique.internet at fiducial.fr.

http://bugzilla.ximian.com/show_bug.cgi?id=77785

--- shadow/77785	2006-03-14 06:03:30.000000000 -0500
+++ shadow/77785.tmp.16799	2006-03-14 06:04:33.000000000 -0500
@@ -1,14 +1,14 @@
 Bug#: 77785
 Product: Mono: Class Libraries
 Version: 1.1
-OS: 
+OS: unknown
 OS Details: 
 Status: NEW   
 Resolution: 
-Severity: 
+Severity: Unknown
 Priority: Normal
 Component: Sys.Web.Services
 AssignedTo: lluis at ximian.com                            
 ReportedBy: informatique.internet at fiducial.fr               
 QAContact: mono-bugs at ximian.com
 TargetMilestone: ---
@@ -29,6 +29,131 @@
 
 How often does this happen? 
 Always
 
 Additional Information:
 There's no test on the connection before Loading the session
+
+------- Additional Comments From informatique.internet at fiducial.fr  2006-03-14 06:04 -------
+I've made a patch to solve this issue :
+Index: System.Web.SessionState/SessionSQLServerHandler.cs
+===================================================================
+--- System.Web.SessionState/SessionSQLServerHandler.cs  (révision 57943)
++++ System.Web.SessionState/SessionSQLServerHandler.cs  (copie de travail)
+@@ -196,11 +196,21 @@
+
+                        command.CommandText = selectCommand;
+                        command.Parameters.Add (CreateParam (command,
+DbType.String, "SessionID", id));
+-
+-                       using (IDataReader reader =
+command.ExecuteReader ()) {
++                       IDataReader reader=null;
++                       try{
++                        reader = command.ExecuteReader ();
++                       }
++                       catch
++                       {
++                               try{
++                                       cnc.Close();
++                               }catch{}
++                               cnc.Open();
++                               reader = command.ExecuteReader ();
++                       }
+                                if (!reader.Read ())
+                                        return null;
+-
++
+                                SessionDictionary dict;
+                                HttpStaticObjectsCollection sobjs;
+
+@@ -208,9 +218,12 @@
+                                sobjs =
+HttpStaticObjectsCollection.FromByteArray (ReadBytes (reader,
+reader.FieldCount-2));
+
+                                session = new HttpSessionState (id,
+dict, sobjs, 100, false, config.CookieLess,
+-                                              
+SessionStateMode.SQLServer, read_only);
++                                                                  
+SessionStateMode.SQLServer, read_only);
++                       reader.Close();
++                       reader.Dispose();
++
+                                return session;
+-                       }
++
+                }
+
+                private void InsertSession (HttpSessionState session,
+int timeout)
+@@ -229,8 +242,17 @@
+                                                  
+session.StaticObjects.ToByteArray ()));
+                        param.Add (CreateParam (command,
+DbType.Binary, "SessionData",
+                                                  
+session.SessionDictionary.ToByteArray ()));
+-
+-                       command.ExecuteNonQuery ();
++                       try{
++                               command.ExecuteNonQuery ();
++                       }
++                       catch
++                       {
++                               try{
++                                       cnc.Close();
++                               }catch{}
++                               cnc.Open();
++                               command.ExecuteNonQuery ();
++                       }
+                }
+
+                private void UpdateSession (string id,
+SessionDictionary dict)
+@@ -245,7 +267,17 @@
+                        param.Add (CreateParam (command,
+DbType.Binary, "SessionData",
+                                                               
+dict.ToByteArray ()));
+
+-                       command.ExecuteNonQuery ();
++                       try{
++                               command.ExecuteNonQuery ();
++                       }
++                       catch
++                       {
++                               try{
++                                       cnc.Close();
++                               }catch{}
++                               cnc.Open();
++                               command.ExecuteNonQuery ();
++                       }
+                }
+
+                private void DeleteSession (string id)
+@@ -256,7 +288,17 @@
+                        command.CommandText = deleteCommand;
+                        param = command.Parameters;
+                        param.Add (CreateParam (command,
+DbType.String, "SessionID", id));
+-                       command.ExecuteNonQuery ();
++                       try{
++                               command.ExecuteNonQuery ();
++                       }
++                       catch
++                       {
++                               try{
++                                       cnc.Close();
++                               }catch{}
++                               cnc.Open();
++                               command.ExecuteNonQuery ();
++                       }
+                }
+
+                private IDataParameter CreateParam (IDbCommand
+command, DbType type,
+
+
+Could someone check it and commit?
+Thanks


More information about the mono-bugs mailing list