Browse Source

Merge pull request #128 from Dunemaster/fixSASLwindows

Crash because of uninitialized critical session (When using SASL)
pull/2/merge
Hoà V. DINH 8 years ago
parent
commit
732faa9493
5 changed files with 42 additions and 6 deletions
  1. +2
    -0
      .gitignore
  2. +6
    -3
      src/data-types/mailsasl.c
  3. +9
    -0
      src/data-types/mailsasl.h
  4. +16
    -0
      src/data-types/mailsasl_private.h
  5. +9
    -3
      src/windows/win_init.cpp

+ 2
- 0
.gitignore View File

@ -30,6 +30,8 @@ xcuserdata/
/Makefile.in
/autom4te.cache/
/build-windows/include/libetpan
/build-windows/Release
/build-windows/Release_ssl
/build-windows/Debug
/build-windows/Debug_ssl
/build-windows/libetpan/Debug


+ 6
- 3
src/data-types/mailsasl.c View File

@ -42,15 +42,18 @@ static int sasl_lock_init_done = 0;
static int sasl_use_count = 0;
#ifdef LIBETPAN_REENTRANT
void mailsasl_init_lock(){
#if defined(HAVE_PTHREAD_H) && !defined(IGNORE_PTHREAD_H)
// nothing to do
#elif (defined WIN32)
void mailsasl_init_lock(){
static int mainsasl_init_lock_done = 0;
static int volatile mainsasl_init_lock_done = 0;
if (InterlockedExchange(&mainsasl_init_lock_done, 1) == 0){
InitializeCriticalSection(&sasl_lock);
}
}
#endif
}
#endif
void mailsasl_external_ref(void)


+ 9
- 0
src/data-types/mailsasl.h View File

@ -2,10 +2,19 @@
#define MAILSASL_H
#ifdef __cplusplus
extern"C"{
#endif
/* if Cyrus-SASL is used outside of libetpan */
void mailsasl_external_ref(void);
void mailsasl_ref(void);
void mailsasl_unref(void);
#ifdef __cplusplus
}
#endif
#endif

+ 16
- 0
src/data-types/mailsasl_private.h View File

@ -0,0 +1,16 @@
#ifndef MAILSASL_PRIVATE_H
#define MAILSASL_PRIVATE_H
#ifdef __cplusplus
extern"C"{
#endif
extern void mailsasl_init_lock(void);
#ifdef __cplusplus
}
#endif
#endif

+ 9
- 3
src/windows/win_init.cpp View File

@ -12,22 +12,28 @@ Special class, initializers for windows
#ifdef _MSC_VER
#include "mailstream_ssl_private.h"
#include "mmapstring_private.h"
#include "mailsasl_private.h"
#endif
class win_init {
public:
win_init() {
wsocket_init();
#ifdef _MSC_VER
/* Initialise Mutexs */
/* Initialize Mutexes */
mmapstring_init_lock();
#ifdef USE_SSL
mailstream_ssl_init_lock();
#endif
#ifdef USE_SASL
mailsasl_init_lock();
#endif
}
~win_init() {
WSACleanup();


Loading…
Cancel
Save