Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add decision- and blocking-functions to repl, cleanup #2258

Merged
merged 4 commits into from
Feb 22, 2021

Conversation

r10s
Copy link
Member

@r10s r10s commented Feb 22, 2021

this pr adds some missing functionality to the repl tool to make testing easier.

moreover, this pr deprecates dc_get_blocked_cnt() - as far as i see, this was not really used anywhere, just for a test in node (therefore, it is still there, not yet removed ;)
getting rid of this functions makes upcoming changes wrt blocking easier as there is only one function left to deal with blocked contacts.

r10s added 3 commits February 22, 2021 12:39
instead, the size returned by get_blocked_contacts() should be checked,
this is safer and allows easier adaption of blocking rules.

ui or python seems not to use dc_get_blocked_cnt(),
however, there is one test in node,
therefore, the function will continue working for now
(by just returning Contact::get_all_blocked().len() then)
@r10s r10s requested review from link2xt and Hocuri February 22, 2021 12:41
@r10s r10s merged commit 6d93d7a into master Feb 22, 2021
@r10s r10s deleted the cleanup-blocking-and-repl branch February 22, 2021 13:58
link2xt added a commit that referenced this pull request Mar 27, 2021
They have been accidentally reverted during sqlx rebasing
link2xt added a commit that referenced this pull request Mar 27, 2021
They have been accidentally reverted during sqlx rebasing
dignifiedquire added a commit that referenced this pull request Apr 6, 2021
* refactor: move sql into own mod

* refactor: resultify sql interface

* fixup

* start usage of sqlx

* compile again

* migrate exists

* migrate query_row and query_row_optional

* migrate table_exists

* migrate with_conn

* migrate rowid

* migrate most of query_map

* finish query_map migration

* remove rusqlite and fixup examples

* improve migrations and ensure closing

* fix rust tests

* wip

* fixup rebase and get things to compile

* start fixing tests

* use sqlx fork

* debugging

* fix receive imf insert

* fix message loading

* fix grpid bug

* exists() expects COUNT() in sql-statement

* fix two more exists() statements

* fix test_audit_log_view_without_daymarker

* Fix clippy warnings

* fix test_fetch_existing

dc_get_config() must never return NULL, instead return ""

* ffi: make render_info accept non-option BTreeMap

* fix a typo

* Restore changes from PR #2258

They have been accidentally reverted during sqlx rebasing

* Remove useless cast that was not there before switch to sqlx

* Split long query into several lines so rustfmt does not fail

* Remove outdated comment

DC_CONTACT_ID_SELF is bound into the query now.

* Split long lines to make rustfmt work

* Restore accidentally removed part of PR #2132

* Make rustfmt work

* Use exists() instead of count() in is_group_explicitly_left

* Make rustfmt work

* Fix a typo ("foreing")

* Fix rustfmt

* Fix formatting

* Replace 0x100 constant with Origin::IncomingReplyTo

* Replace constant 100 with Chattype::Single

* Remove commented out code

* peerstate: make rustfmt work

* Move the code to make msg immutable

* do not re-use bind parameters

sqlx does not bind the first `?` implicitly to `?1`,
therefore the sql-statement fails.

we could use `?1` several times, however,
i did not find good documentation about that,
and even if that works now, that could fail with other db
or even with sqlite in newer versions.

therefore, we just bind every parameter explicitly.

* Do not use read only sqlite mode

* Factor out database pool creation

* Open reader pool in readonly mode if database is opened in readonly mode

* Add a test for reopening the database

* sql::table_exists: drain response stream to avoid breaking connection

* Drain the stream in Sql.col_exists

* sqlx: fix failing TestOnlineAccount::test_saved_mime_on_received_message (#2323)

* add failing tests for save_mime_headers

* fix saving mime

if an encrypted message is received,
and we do not have the decoded data,
for whatever reason, save the raw data.

* let dc_get_mime_headers return NULL on empty string

* let test_save_mime_headers_*() tests return anyhow::Result<()>

* make clippy happy

* Remove 5 unwraps

* Remove another unwrap

* Replace {:?} with {:#} for error handling

* Remove all dbg! statements

* set max_connections=10 (default), show num_cpus in get_info()

setting the number of connections
to the number of cpus seems to be to low in general:

- on a mac i5 from 2017, that would result in 4 connections
- on an iphone7, that would result in only 2 connections

the sqlx-default is 10 connections,
so, this pr uses that default (plus 1 connection for the writer tag).

on the iphone7, that change was directly noticable -
sqlx with 2 connections feelt not much faster that rusqlite with 10 connections,
however, using sqlx with the 10+1 connection was a real boost,
at least at a first glance :)

might be, fewer connections would be sufficient as well,
however, i do not see much reasons not to go with the default here.

* Disable sqlx statement cache

This is a workaround for launchbadge/sqlx#1147

Draining statement results is no longer needed.

* Make clippy happy

* Do not pass NULL to mime_headers column nor expect it from there. Treat existing NULL as "empty string".

* Increase SQL busy timeout to 100 seconds

No need to abort the connection if all connections are stalled for 10 seconds.

This did not happen, just to make sure each timeout is a result of an actual deadlock.

* README: specify log target to get rid of sqlx query logging

* Remove 3 unwrap()'s

* Remove two more unwrap()'s

Co-authored-by: B. Petersen <r10s@b44t.com>
Co-authored-by: Hocuri <hocuri@gmx.de>
Co-authored-by: link2xt <link2xt@testrun.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants