mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-06 03:50:08 +02:00
remove unneeded locking in smpt-thread
This commit is contained in:
parent
aafb6b5915
commit
ff5c0a4eae
2 changed files with 3 additions and 24 deletions
24
src/mrsmtp.c
24
src/mrsmtp.c
|
@ -30,10 +30,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define LOCK_SMTP pthread_mutex_lock(&ths->m_mutex); smtp_locked = 1;
|
|
||||||
#define UNLOCK_SMTP if( smtp_locked ) { pthread_mutex_unlock(&ths->m_mutex); smtp_locked = 0; }
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Main interface
|
* Main interface
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
@ -49,7 +45,6 @@ mrsmtp_t* mrsmtp_new(mrmailbox_t* mailbox)
|
||||||
ths->m_log_connect_errors = 1;
|
ths->m_log_connect_errors = 1;
|
||||||
|
|
||||||
ths->m_mailbox = mailbox; /* should be used for logging only */
|
ths->m_mailbox = mailbox; /* should be used for logging only */
|
||||||
pthread_mutex_init(&ths->m_mutex, NULL);
|
|
||||||
return ths;
|
return ths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +55,6 @@ void mrsmtp_unref(mrsmtp_t* ths)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mrsmtp_disconnect(ths);
|
mrsmtp_disconnect(ths);
|
||||||
pthread_mutex_destroy(&ths->m_mutex);
|
|
||||||
free(ths->m_from);
|
free(ths->m_from);
|
||||||
free(ths);
|
free(ths);
|
||||||
}
|
}
|
||||||
|
@ -98,15 +92,13 @@ static void logger(mailsmtp* smtp, int log_type, const char* buffer__, size_t si
|
||||||
|
|
||||||
int mrsmtp_connect(mrsmtp_t* ths, const mrloginparam_t* lp)
|
int mrsmtp_connect(mrsmtp_t* ths, const mrloginparam_t* lp)
|
||||||
{
|
{
|
||||||
int success = 0, smtp_locked = 0;
|
int success = 0;
|
||||||
int r, try_esmtp;
|
int r, try_esmtp;
|
||||||
|
|
||||||
if( ths == NULL || lp == NULL ) {
|
if( ths == NULL || lp == NULL ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCK_SMTP
|
|
||||||
|
|
||||||
if( ths->m_mailbox->m_cb(ths->m_mailbox, MR_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
|
if( ths->m_mailbox->m_cb(ths->m_mailbox, MR_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
|
||||||
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, MR_ERR_NONETWORK, NULL);
|
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, MR_ERR_NONETWORK, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -235,29 +227,21 @@ cleanup:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UNLOCK_SMTP
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mrsmtp_disconnect(mrsmtp_t* ths)
|
void mrsmtp_disconnect(mrsmtp_t* ths)
|
||||||
{
|
{
|
||||||
int smtp_locked = 0;
|
|
||||||
|
|
||||||
if( ths == NULL ) {
|
if( ths == NULL ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCK_SMTP
|
|
||||||
|
|
||||||
if( ths->m_hEtpan ) {
|
if( ths->m_hEtpan ) {
|
||||||
//mailsmtp_quit(ths->m_hEtpan); -- ?
|
//mailsmtp_quit(ths->m_hEtpan); -- ?
|
||||||
mailsmtp_free(ths->m_hEtpan);
|
mailsmtp_free(ths->m_hEtpan);
|
||||||
ths->m_hEtpan = NULL;
|
ths->m_hEtpan = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNLOCK_SMTP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -268,7 +252,7 @@ void mrsmtp_disconnect(mrsmtp_t* ths)
|
||||||
|
|
||||||
int mrsmtp_send_msg(mrsmtp_t* ths, const clist* recipients, const char* data_not_terminated, size_t data_bytes)
|
int mrsmtp_send_msg(mrsmtp_t* ths, const clist* recipients, const char* data_not_terminated, size_t data_bytes)
|
||||||
{
|
{
|
||||||
int success = 0, r, smtp_locked = 0;
|
int success = 0, r;
|
||||||
clistiter* iter;
|
clistiter* iter;
|
||||||
|
|
||||||
if( ths == NULL ) {
|
if( ths == NULL ) {
|
||||||
|
@ -279,8 +263,6 @@ int mrsmtp_send_msg(mrsmtp_t* ths, const clist* recipients, const char* data_not
|
||||||
return 1; /* "null message" send */
|
return 1; /* "null message" send */
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCK_SMTP
|
|
||||||
|
|
||||||
if( ths->m_hEtpan==NULL ) {
|
if( ths->m_hEtpan==NULL ) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -325,8 +307,6 @@ int mrsmtp_send_msg(mrsmtp_t* ths, const clist* recipients, const char* data_not
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
||||||
UNLOCK_SMTP
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ typedef struct mrsmtp_t
|
||||||
mailsmtp* m_hEtpan;
|
mailsmtp* m_hEtpan;
|
||||||
char* m_from;
|
char* m_from;
|
||||||
int m_esmtp;
|
int m_esmtp;
|
||||||
pthread_mutex_t m_mutex;
|
|
||||||
|
|
||||||
int m_log_connect_errors;
|
int m_log_connect_errors;
|
||||||
int m_log_usual_error;
|
int m_log_usual_error;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue