evilsocket / opensnitch

OpenSnitch is a GNU/Linux interactive application firewall inspired by Little Snitch.
GNU General Public License v3.0
9.88k stars 490 forks source link

Maximum days of events to keep is not working (no events are removed) #844

Closed BetweenTheKeyboardAndChair closed 1 year ago

BetweenTheKeyboardAndChair commented 1 year ago

Bug: Old events are not being removed from the events UI tab.

The UI setting preferences for the database are: Database type: In memory

System info: Ubuntu 20.04.1 LTS (focal), ucin 5.4.0-135-generic opensnitch/now 1.6.0-rc.4-1 amd64 [installed,local] python3-opensnitch-ui/now 1.6.0-rc.4-1 all [installed,local] protobuf: 3.6.1 grpc: 1.37.1

To Reproduce Start opensnitch and the UI, and let it run. No events have been removed since the process was started 2 weeks ago. i.e. If I reverse sort events by time on the events tab, I see events from 1/26/22.

gustavo-iniguez-goya commented 1 year ago

Hi @BetweenTheKeyboardAndChair ,

I've been analyzing this issue, and I've found a solution. I'll test it for a couple of days to see if there's any downside.

The problem is how QsqlDatabase works from different threads:

A connection can only be used from within the thread that created it.

In order to access a database from different threads you create a new QsqlDatabase connection to the DB specifying the DB name/file. With DBs written to the disk, the database file/name is always the same (say /tmp/file.db).

But with in-memory databases, whenever you create a new connection with :memory:, it always create a new in-memory DB, so the DB is empty for the cleaner task, and that's why it was not deleting old events.