Skip to content

Commit

Permalink
Unregister the update hook when closing the connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderTaeschner authored and bricelam committed Jan 24, 2018
1 parent a94aaf2 commit af506c4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Microsoft.Data.Sqlite.Core/SqliteConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,12 @@ public override void Open()

SetState(ConnectionState.Open);

raw.sqlite3_update_hook(
_db,
(_, type, database, table, rowid)
=> OnUpdate(new UpdateEventArgs((UpdateEventType)type, database, table, rowid)),
null);
raw.sqlite3_update_hook(_db, UpdateHook, null);
}

private void UpdateHook(object user_data, int type, string database, string table, long rowid)
=> OnUpdate(new UpdateEventArgs((UpdateEventType)type, database, table, rowid));

/// <summary>
/// Closes the connection to the database. Open transactions are rolled back.
/// </summary>
Expand All @@ -241,6 +240,8 @@ public override void Close()
return;
}

raw.sqlite3_update_hook(_db, null, null);

Transaction?.Dispose();

foreach (var reference in _commands)
Expand Down

0 comments on commit af506c4

Please sign in to comment.