mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 15:05:11 +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;
|
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) ||
|
if (ParseeIsPuppet(data->config, m_sender) ||
|
||||||
ParseeManageBan(data, m_sender, id))
|
ParseeManageBan(data, m_sender, id))
|
||||||
{
|
{
|
||||||
DbUnlock(data->db, ref);
|
|
||||||
Free(chat_id);
|
|
||||||
Free(reply_id);
|
Free(reply_id);
|
||||||
Free(xepd);
|
Free(xepd);
|
||||||
Free(unedited_id);
|
Free(unedited_id);
|
||||||
return;
|
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)
|
if (!direct && !chat_id)
|
||||||
{
|
{
|
||||||
ParseeBotHandler(data, event);
|
ParseeBotHandler(data, event);
|
||||||
|
|
||||||
DbUnlock(data->db, ref);
|
JsonFree(json);
|
||||||
Free(chat_id);
|
Free(chat_id);
|
||||||
Free(reply_id);
|
Free(reply_id);
|
||||||
Free(xepd);
|
Free(xepd);
|
||||||
|
|
@ -362,7 +365,7 @@ end:
|
||||||
Free(unauth);
|
Free(unauth);
|
||||||
Free(unedited_id);
|
Free(unedited_id);
|
||||||
|
|
||||||
DbUnlock(data->db, ref);
|
JsonFree(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue