mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-05 02:29:28 +02:00
wake locks should be handled by the caller
This commit is contained in:
parent
ce1da0b41d
commit
2f9e9f278c
6 changed files with 2 additions and 61 deletions
|
@ -65,7 +65,6 @@ static uintptr_t receive_event(mrmailbox_t* mailbox, int event, uintptr_t data1,
|
||||||
{
|
{
|
||||||
case MR_EVENT_GET_STRING:
|
case MR_EVENT_GET_STRING:
|
||||||
case MR_EVENT_GET_QUANTITY_STRING:
|
case MR_EVENT_GET_QUANTITY_STRING:
|
||||||
case MR_EVENT_WAKE_LOCK:
|
|
||||||
break; /* do not show the event as this would fill the screen */
|
break; /* do not show the event as this would fill the screen */
|
||||||
|
|
||||||
case MR_EVENT_INFO:
|
case MR_EVENT_INFO:
|
||||||
|
|
|
@ -322,21 +322,6 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define MR_EVENT_HTTP_GET 2100
|
#define MR_EVENT_HTTP_GET 2100
|
||||||
|
|
||||||
/**
|
|
||||||
* Acquire or release a wakelock.
|
|
||||||
*
|
|
||||||
* The core surrounds critical functions that should not be killed by the operating system with wakelocks.
|
|
||||||
* Before a critical function _MR_EVENT_WAKE_LOCK with data1=1_ is called, when it finishes, _MR_EVENT_WAKE_LOCK with data1=0_ is called.
|
|
||||||
* If you do not need this functionality, just ignore this event.
|
|
||||||
*
|
|
||||||
* @param data1 1=acquire wakelock, 0=release wakelock, the core does not make nested or unsynchronized calls
|
|
||||||
*
|
|
||||||
* @param data2 0
|
|
||||||
*
|
|
||||||
* @return 0
|
|
||||||
*/
|
|
||||||
#define MR_EVENT_WAKE_LOCK 2110
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* /extern "C" */
|
} /* /extern "C" */
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
#include "mrosnative.h"
|
#include "mrosnative.h"
|
||||||
#include "mrloginparam.h"
|
#include "mrloginparam.h"
|
||||||
|
|
||||||
#define LOCK_HANDLE pthread_mutex_lock(&ths->m_hEtpanmutex); mrmailbox_wake_lock(ths->m_mailbox); handle_locked = 1;
|
#define LOCK_HANDLE pthread_mutex_lock(&ths->m_hEtpanmutex); handle_locked = 1;
|
||||||
#define UNLOCK_HANDLE if( handle_locked ) { mrmailbox_wake_unlock(ths->m_mailbox); pthread_mutex_unlock(&ths->m_hEtpanmutex); handle_locked = 0; }
|
#define UNLOCK_HANDLE if( handle_locked ) { pthread_mutex_unlock(&ths->m_hEtpanmutex); handle_locked = 0; }
|
||||||
|
|
||||||
#define BLOCK_IDLE pthread_mutex_lock(&ths->m_idlemutex); idle_blocked = 1;
|
#define BLOCK_IDLE pthread_mutex_lock(&ths->m_idlemutex); idle_blocked = 1;
|
||||||
#define UNBLOCK_IDLE if( idle_blocked ) { pthread_mutex_unlock(&ths->m_idlemutex); idle_blocked = 0; }
|
#define UNBLOCK_IDLE if( idle_blocked ) { pthread_mutex_unlock(&ths->m_idlemutex); idle_blocked = 0; }
|
||||||
|
|
|
@ -63,9 +63,6 @@ struct _mrmailbox
|
||||||
|
|
||||||
uint32_t m_cmdline_sel_chat_id; /**< Internal */
|
uint32_t m_cmdline_sel_chat_id; /**< Internal */
|
||||||
|
|
||||||
int m_wake_lock; /**< Internal */
|
|
||||||
pthread_mutex_t m_wake_lock_critical; /**< Internal */
|
|
||||||
|
|
||||||
int m_e2ee_enabled; /**< Internal */
|
int m_e2ee_enabled; /**< Internal */
|
||||||
|
|
||||||
#define MR_LOG_RINGBUF_SIZE 200
|
#define MR_LOG_RINGBUF_SIZE 200
|
||||||
|
@ -91,8 +88,6 @@ void mrmailbox_receive_imf (mrmailbox_t*,
|
||||||
uint32_t mrmailbox_send_msg_object (mrmailbox_t*, uint32_t chat_id, mrmsg_t*);
|
uint32_t mrmailbox_send_msg_object (mrmailbox_t*, uint32_t chat_id, mrmsg_t*);
|
||||||
void mrmailbox_ll_connect_to_imap (mrmailbox_t*, mrjob_t*);
|
void mrmailbox_ll_connect_to_imap (mrmailbox_t*, mrjob_t*);
|
||||||
void mrmailbox_ll_disconnect (mrmailbox_t*, mrjob_t*);
|
void mrmailbox_ll_disconnect (mrmailbox_t*, mrjob_t*);
|
||||||
void mrmailbox_wake_lock (mrmailbox_t*);
|
|
||||||
void mrmailbox_wake_unlock (mrmailbox_t*);
|
|
||||||
int mrmailbox_get_archived_count__ (mrmailbox_t*);
|
int mrmailbox_get_archived_count__ (mrmailbox_t*);
|
||||||
size_t mrmailbox_get_real_contact_cnt__ (mrmailbox_t*);
|
size_t mrmailbox_get_real_contact_cnt__ (mrmailbox_t*);
|
||||||
uint32_t mrmailbox_add_or_lookup_contact__ (mrmailbox_t*, const char* display_name /*can be NULL*/, const char* addr_spec, int origin, int* sth_modified);
|
uint32_t mrmailbox_add_or_lookup_contact__ (mrmailbox_t*, const char* display_name /*can be NULL*/, const char* addr_spec, int origin, int* sth_modified);
|
||||||
|
|
|
@ -108,8 +108,6 @@ mrmailbox_t* mrmailbox_new(mrmailboxcb_t cb, void* userdata, const char* os_name
|
||||||
|
|
||||||
pthread_mutex_init(&ths->m_log_ringbuf_critical, NULL);
|
pthread_mutex_init(&ths->m_log_ringbuf_critical, NULL);
|
||||||
|
|
||||||
pthread_mutex_init(&ths->m_wake_lock_critical, NULL);
|
|
||||||
|
|
||||||
ths->m_magic = MR_MAILBOX_MAGIC;
|
ths->m_magic = MR_MAILBOX_MAGIC;
|
||||||
ths->m_sql = mrsqlite3_new(ths);
|
ths->m_sql = mrsqlite3_new(ths);
|
||||||
ths->m_cb = cb? cb : cb_dummy;
|
ths->m_cb = cb? cb : cb_dummy;
|
||||||
|
@ -173,7 +171,6 @@ void mrmailbox_unref(mrmailbox_t* mailbox)
|
||||||
mrimap_unref(mailbox->m_imap);
|
mrimap_unref(mailbox->m_imap);
|
||||||
mrsmtp_unref(mailbox->m_smtp);
|
mrsmtp_unref(mailbox->m_smtp);
|
||||||
mrsqlite3_unref(mailbox->m_sql);
|
mrsqlite3_unref(mailbox->m_sql);
|
||||||
pthread_mutex_destroy(&mailbox->m_wake_lock_critical);
|
|
||||||
|
|
||||||
pthread_mutex_destroy(&mailbox->m_log_ringbuf_critical);
|
pthread_mutex_destroy(&mailbox->m_log_ringbuf_critical);
|
||||||
for( int i = 0; i < MR_LOG_RINGBUF_SIZE; i++ ) {
|
for( int i = 0; i < MR_LOG_RINGBUF_SIZE; i++ ) {
|
||||||
|
@ -359,37 +356,6 @@ char* mrmailbox_get_blobdir(mrmailbox_t* mailbox)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mrmailbox_wake_lock(mrmailbox_t* mailbox)
|
|
||||||
{
|
|
||||||
if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pthread_mutex_lock(&mailbox->m_wake_lock_critical);
|
|
||||||
mailbox->m_wake_lock++;
|
|
||||||
if( mailbox->m_wake_lock == 1 ) {
|
|
||||||
mailbox->m_cb(mailbox, MR_EVENT_WAKE_LOCK, 1, 0);
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&mailbox->m_wake_lock_critical);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void mrmailbox_wake_unlock(mrmailbox_t* mailbox)
|
|
||||||
{
|
|
||||||
if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pthread_mutex_lock(&mailbox->m_wake_lock_critical);
|
|
||||||
if( mailbox->m_wake_lock == 1 ) {
|
|
||||||
mailbox->m_cb(mailbox, MR_EVENT_WAKE_LOCK, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mailbox->m_wake_lock > 0 ) {
|
|
||||||
mailbox->m_wake_lock--;
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&mailbox->m_wake_lock_critical);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* INI-handling, Information
|
* INI-handling, Information
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
|
@ -695,8 +695,6 @@ void mrsqlite3_lock(mrsqlite3_t* ths) /* wait and lock */
|
||||||
#ifdef MR_USE_LOCK_DEBUG
|
#ifdef MR_USE_LOCK_DEBUG
|
||||||
mrmailbox_log_info(ths->m_mailbox, 0, "{{{ LOCK AT %s#L%i after %.3f ms", filename, linenum, (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
|
mrmailbox_log_info(ths->m_mailbox, 0, "{{{ LOCK AT %s#L%i after %.3f ms", filename, linenum, (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//mrmailbox_wake_lock(ths->m_mailbox);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -706,8 +704,6 @@ void mrsqlite3_unlockNdebug(mrsqlite3_t* ths, const char* filename, int linenum)
|
||||||
void mrsqlite3_unlock(mrsqlite3_t* ths)
|
void mrsqlite3_unlock(mrsqlite3_t* ths)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
//mrmailbox_wake_unlock(ths->m_mailbox);
|
|
||||||
|
|
||||||
#ifdef MR_USE_LOCK_DEBUG
|
#ifdef MR_USE_LOCK_DEBUG
|
||||||
mrmailbox_log_info(ths->m_mailbox, 0, " UNLOCK AT %s#L%i }}}", filename, linenum);
|
mrmailbox_log_info(ths->m_mailbox, 0, " UNLOCK AT %s#L%i }}}", filename, linenum);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue