summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Dbx_kv/src/dbevents.cpp14
-rw-r--r--plugins/Dbx_kv/src/dbintf.cpp2
-rw-r--r--plugins/Dbx_mdb/src/dbevents.cpp10
3 files changed, 22 insertions, 4 deletions
diff --git a/plugins/Dbx_kv/src/dbevents.cpp b/plugins/Dbx_kv/src/dbevents.cpp
index 466a732189..72a0f239e7 100644
--- a/plugins/Dbx_kv/src/dbevents.cpp
+++ b/plugins/Dbx_kv/src/dbevents.cpp
@@ -115,6 +115,8 @@ STDMETHODIMP_(MEVENT) CDbxKV::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei)
STDMETHODIMP_(BOOL) CDbxKV::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent)
{
+ if (hDbEvent == 0) return INVALID_CONTACT_ID;
+
DBCachedContact *cc = m_cache->GetCachedContact(contactID);
if (cc == NULL || cc->dbc.dwEventCount == 0)
return 1;
@@ -163,7 +165,7 @@ STDMETHODIMP_(LONG) CDbxKV::GetBlobSize(MEVENT hDbEvent)
STDMETHODIMP_(BOOL) CDbxKV::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei)
{
- if (dbei == NULL || dbei->cbSize != sizeof(DBEVENTINFO)) return 1;
+ if (hDbEvent == 0 || dbei == NULL || dbei->cbSize != sizeof(DBEVENTINFO)) return 1;
if (dbei->cbBlob > 0 && dbei->pBlob == NULL) {
dbei->cbBlob = 0;
return 1;
@@ -227,6 +229,8 @@ void CDbxKV::FindNextUnread(DBCachedContact *cc, DBEventSortingKey &key2)
STDMETHODIMP_(BOOL) CDbxKV::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent)
{
+ if (hDbEvent == 0) return -1;
+
DBCachedContact *cc = m_cache->GetCachedContact(contactID);
if (cc == NULL)
return -1;
@@ -259,10 +263,12 @@ STDMETHODIMP_(BOOL) CDbxKV::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent)
STDMETHODIMP_(MCONTACT) CDbxKV::GetEventContact(MEVENT hDbEvent)
{
+ if (hDbEvent == 0) return INVALID_CONTACT_ID;
+
ham_record_t rec = { 0 };
ham_key_t key = { sizeof(MEVENT), &hDbEvent };
if (ham_db_find(m_dbEvents, NULL, &key, &rec, HAM_FIND_EXACT_MATCH) != HAM_SUCCESS)
- return 0;
+ return INVALID_CONTACT_ID;
DBEvent *dbe = (DBEvent*)rec.data;
return (dbe->dwSignature == DBEVENT_SIGNATURE) ? dbe->contactID : INVALID_CONTACT_ID;
@@ -304,6 +310,8 @@ STDMETHODIMP_(MEVENT) CDbxKV::FindLastEvent(MCONTACT contactID)
STDMETHODIMP_(MEVENT) CDbxKV::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent)
{
+ if (hDbEvent == 0) return m_evLast = 0;
+
DWORD ts;
ham_record_t rec = { 0 };
@@ -327,6 +335,8 @@ STDMETHODIMP_(MEVENT) CDbxKV::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent)
STDMETHODIMP_(MEVENT) CDbxKV::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent)
{
+ if (hDbEvent == 0) return m_evLast = 0;
+
DWORD ts;
ham_record_t rec = { 0 };
diff --git a/plugins/Dbx_kv/src/dbintf.cpp b/plugins/Dbx_kv/src/dbintf.cpp
index 0b323a125a..aa4c7ac775 100644
--- a/plugins/Dbx_kv/src/dbintf.cpp
+++ b/plugins/Dbx_kv/src/dbintf.cpp
@@ -177,7 +177,7 @@ int CDbxKV::Load(bool bSkipInit)
int CDbxKV::Create(void)
{
- int flags = HAM_ENABLE_FSYNC | HAM_DISABLE_RECOVERY;
+ int flags = HAM_ENABLE_FSYNC | HAM_ENABLE_RECOVERY | HAM_ENABLE_FSYNC;
if (ham_env_create(&m_pMdbEnv, _T2A(m_tszProfileName), flags, 0664, NULL) != HAM_SUCCESS)
return EGROKPRF_CANTREAD;
diff --git a/plugins/Dbx_mdb/src/dbevents.cpp b/plugins/Dbx_mdb/src/dbevents.cpp
index c0a507f5d3..d42975e698 100644
--- a/plugins/Dbx_mdb/src/dbevents.cpp
+++ b/plugins/Dbx_mdb/src/dbevents.cpp
@@ -247,6 +247,8 @@ void CDbxMdb::FindNextUnread(const txn_ptr &txn, DBCachedContact *cc, DBEventSor
STDMETHODIMP_(BOOL) CDbxMdb::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent)
{
+ if (hDbEvent == 0) return -1;
+
DBCachedContact *cc = m_cache->GetCachedContact(contactID);
if (cc == NULL)
return -1;
@@ -284,12 +286,14 @@ STDMETHODIMP_(BOOL) CDbxMdb::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent)
STDMETHODIMP_(MCONTACT) CDbxMdb::GetEventContact(MEVENT hDbEvent)
{
+ if (hDbEvent == 0) return INVALID_CONTACT_ID;
+
mir_cslock lck(m_csDbAccess);
txn_ptr txn(m_pMdbEnv, true);
MDB_val key = { sizeof(MEVENT), &hDbEvent }, data;
if (mdb_get(txn, m_dbEvents, &key, &data) != MDB_SUCCESS)
- return 0;
+ return INVALID_CONTACT_ID;
DBEvent *dbe = (DBEvent*)data.mv_data;
return (dbe->dwSignature == DBEVENT_SIGNATURE) ? dbe->contactID : INVALID_CONTACT_ID;
@@ -339,6 +343,8 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindLastEvent(MCONTACT contactID)
STDMETHODIMP_(MEVENT) CDbxMdb::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent)
{
+ if (hDbEvent == 0) return m_evLast = 0;
+
MDB_val data;
DWORD ts;
@@ -370,6 +376,8 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent
STDMETHODIMP_(MEVENT) CDbxMdb::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent)
{
+ if (hDbEvent == 0) return m_evLast = 0;
+
MDB_val data;
DWORD ts;