diff options
Diffstat (limited to 'plugins/Dbx_mdb')
-rw-r--r-- | plugins/Dbx_mdb/src/dbevents.cpp | 43 | ||||
-rw-r--r-- | plugins/Dbx_mdb/src/dbintf.h | 2 |
2 files changed, 26 insertions, 19 deletions
diff --git a/plugins/Dbx_mdb/src/dbevents.cpp b/plugins/Dbx_mdb/src/dbevents.cpp index 2e22931c47..ee9d37ccd3 100644 --- a/plugins/Dbx_mdb/src/dbevents.cpp +++ b/plugins/Dbx_mdb/src/dbevents.cpp @@ -276,34 +276,41 @@ STDMETHODIMP_(BOOL) CDbxMdb::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) return -1;
mir_cslockfull lck(m_csDbAccess);
- txn_ptr txn(m_pMdbEnv);
+ DWORD wRetVal = 0;
- MDB_val key = { sizeof(MEVENT), &hDbEvent }, data;
- if (mdb_get(txn, m_dbEvents, &key, &data) != MDB_SUCCESS)
- return 0;
+ for (;; Remap())
+ {
+ txn_ptr txn(m_pMdbEnv);
- DBEvent *dbe = (DBEvent*)data.mv_data;
- if (dbe->dwSignature != DBEVENT_SIGNATURE)
- return -1;
+ MDB_val key = { sizeof(MEVENT), &hDbEvent }, data;
+ MDB_CHECK(mdb_get(txn, m_dbEvents, &key, &data), 0);
+
+ DBEvent *dbe = (DBEvent*)data.mv_data;
+ if (dbe->dwSignature != DBEVENT_SIGNATURE)
+ return -1;
+
+ if (dbe->markedRead())
+ return dbe->flags;
- if (dbe->markedRead())
- return dbe->flags;
+ DBEventSortingKey key2 = { hDbEvent, dbe->timestamp, contactID };
- DBEventSortingKey key2 = { hDbEvent, dbe->timestamp, contactID };
+ dbe->flags |= DBEF_READ;
+ MDB_CHECK(mdb_put(txn, m_dbEvents, &key, &data, 0), -1);
- dbe->flags |= DBEF_READ;
- mdb_put(txn, m_dbEvents, &key, &data, 0);
+ FindNextUnread(txn, cc, key2);
+ key.mv_size = sizeof(MCONTACT); key.mv_data = &contactID;
+ data.mv_data = &cc->dbc; data.mv_size = sizeof(cc->dbc);
+ MDB_CHECK(mdb_put(txn, m_dbContacts, &key, &data, 0), -1);
+ wRetVal = dbe->flags;
- FindNextUnread(txn, cc, key2);
- key.mv_size = sizeof(MCONTACT); key.mv_data = &contactID;
- data.mv_data = &cc->dbc; data.mv_size = sizeof(cc->dbc);
- mdb_put(txn, m_dbContacts, &key, &data, 0);
- txn.commit();
+ if (txn.commit())
+ break;;
+ }
lck.unlock();
NotifyEventHooks(hEventMarkedRead, contactID, (LPARAM)hDbEvent);
- return dbe->flags;
+ return wRetVal;
}
STDMETHODIMP_(MCONTACT) CDbxMdb::GetEventContact(MEVENT hDbEvent)
diff --git a/plugins/Dbx_mdb/src/dbintf.h b/plugins/Dbx_mdb/src/dbintf.h index 2c95b6413d..f744b37d96 100644 --- a/plugins/Dbx_mdb/src/dbintf.h +++ b/plugins/Dbx_mdb/src/dbintf.h @@ -259,7 +259,7 @@ protected: MDB_dbi m_dbContacts;
MDB_cursor *m_curContacts;
- int m_contactCount, m_dwMaxContactId;
+ DWORD m_contactCount, m_dwMaxContactId;
void GatherContactHistory(MCONTACT hContact, LIST<EventItem> &items);
|