System.Data.SQLite
Check-in [6d391f764a]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Prevent NullReferenceException being raised from within SQLiteConnection.Close() due to those fields being invalidated by SQLiteEnlistment.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-5cee5409f8
Files: files | file ages | folders
SHA1: 6d391f764a9585f3cdd3424a57f0b95908d928b7
User & Date: mistachkin 2018-01-25 20:44:11
Context
2018-01-25
21:44
Merge updates from trunk. check-in: a363e907fe user: mistachkin tags: tkt-5cee5409f8
20:44
Prevent NullReferenceException being raised from within SQLiteConnection.Close() due to those fields being invalidated by SQLiteEnlistment. check-in: 6d391f764a user: mistachkin tags: tkt-5cee5409f8
19:21
Work in progress on ticket [5cee5409f8]: use the enlistment lock to protect against several race conditions between SQLiteEnlistment and SQLiteConnection. check-in: 0dc736558b user: mistachkin tags: tkt-5cee5409f8
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/SQLiteConnection.cs.

2903
2904
2905
2906
2907
2908
2909



2910
2911
2912
2913
2914
2915

2916
2917
2918
2919
2920
2921
2922



2923

2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
          null, null));

      if (_sql != null)
      {
#if !PLATFORM_COMPACTFRAMEWORK
        lock (_enlistmentSyncRoot) /* TRANSACTIONAL */
        {



          if (_enlistment != null)
          {
            // If the connection is enlisted in a transaction scope and the scope is still active,
            // we cannot truly shut down this connection until the scope has completed.  Therefore make a
            // hidden connection temporarily to hold open the connection until the scope has completed.
            SQLiteConnection cnn = new SQLiteConnection();

            cnn._sql = _sql;
            cnn._transactionLevel = _transactionLevel;
            cnn._transactionSequence = _transactionSequence;
            cnn._enlistment = _enlistment;
            cnn._connectionState = _connectionState;
            cnn._version = _version;




            _enlistment._transaction._cnn = cnn;

            _enlistment._disposeConnection = true;

            _sql = null;
            _enlistment = null;
          }
        }
#endif
        if (_sql != null)
        {
          _sql.Close(_disposing);
          _sql = null;







>
>
>
|





>



|



>
>
>
|
>
|


<







2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934

2935
2936
2937
2938
2939
2940
2941
          null, null));

      if (_sql != null)
      {
#if !PLATFORM_COMPACTFRAMEWORK
        lock (_enlistmentSyncRoot) /* TRANSACTIONAL */
        {
          SQLiteEnlistment enlistment = _enlistment;
          _enlistment = null;

          if (enlistment != null)
          {
            // If the connection is enlisted in a transaction scope and the scope is still active,
            // we cannot truly shut down this connection until the scope has completed.  Therefore make a
            // hidden connection temporarily to hold open the connection until the scope has completed.
            SQLiteConnection cnn = new SQLiteConnection();

            cnn._sql = _sql;
            cnn._transactionLevel = _transactionLevel;
            cnn._transactionSequence = _transactionSequence;
            cnn._enlistment = enlistment;
            cnn._connectionState = _connectionState;
            cnn._version = _version;

            SQLiteTransaction transaction = enlistment._transaction;

            if (transaction != null)
                transaction._cnn = cnn;

            enlistment._disposeConnection = true;

            _sql = null;

          }
        }
#endif
        if (_sql != null)
        {
          _sql.Close(_disposing);
          _sql = null;