mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 16:55:10 +00:00
[FIX/WIP] Fix concurrency problem with LMDB
This commit is contained in:
parent
6135cc1989
commit
b4cfd679ee
1 changed files with 13 additions and 10 deletions
|
|
@ -245,28 +245,31 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
|
|||
|
||||
bool direct = false;
|
||||
|
||||
chat_id = ParseeGetFromRoomID(data, id);
|
||||
|
||||
ref = DbLock(data->db, 3, "rooms", id, "data");
|
||||
json = DbJson(ref);
|
||||
direct = JsonValueAsBoolean(HashMapGet(json, "is_direct"));
|
||||
|
||||
if (ParseeIsPuppet(data->config, m_sender) ||
|
||||
ParseeManageBan(data, m_sender, id))
|
||||
{
|
||||
DbUnlock(data->db, ref);
|
||||
Free(chat_id);
|
||||
Free(reply_id);
|
||||
Free(xepd);
|
||||
Free(unedited_id);
|
||||
return;
|
||||
}
|
||||
|
||||
chat_id = ParseeGetFromRoomID(data, id);
|
||||
|
||||
/* TODO: This ref should be marked as read-only,
|
||||
* as LMDB doesn't seem to like having two concurrent RW
|
||||
* transactions running. */
|
||||
ref = DbLock(data->db, 3, "rooms", id, "data");
|
||||
json = JsonDuplicate(DbJson(ref));
|
||||
direct = JsonValueAsBoolean(HashMapGet(json, "is_direct"));
|
||||
DbUnlock(data->db, ref);
|
||||
ref = NULL;
|
||||
|
||||
if (!direct && !chat_id)
|
||||
{
|
||||
ParseeBotHandler(data, event);
|
||||
|
||||
DbUnlock(data->db, ref);
|
||||
JsonFree(json);
|
||||
Free(chat_id);
|
||||
Free(reply_id);
|
||||
Free(xepd);
|
||||
|
|
@ -362,7 +365,7 @@ end:
|
|||
Free(unauth);
|
||||
Free(unedited_id);
|
||||
|
||||
DbUnlock(data->db, ref);
|
||||
JsonFree(json);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue