added critical section deletion on windows

pull/2/merge
dunemaster 2014-11-13 16:44:12 +03:00
parent 2631332406
commit c09f9cad2d
10 changed files with 60 additions and 1 deletions

View File

@ -446,6 +446,10 @@
RelativePath="..\..\src\data-types\mailsasl.c"
>
</File>
<File
RelativePath="..\..\src\data-types\mailsasl_private.h"
>
</File>
<File
RelativePath="..\..\src\data-types\mailstream.c"
>
@ -478,6 +482,10 @@
RelativePath="..\..\src\data-types\mailstream_ssl.c"
>
</File>
<File
RelativePath="..\..\src\data-types\mailstream_ssl_private.h"
>
</File>
<File
RelativePath="..\..\src\data-types\md5.c"
>
@ -486,6 +494,10 @@
RelativePath="..\..\src\data-types\mmapstring.c"
>
</File>
<File
RelativePath="..\..\src\data-types\mmapstring_private.h"
>
</File>
<File
RelativePath="..\..\src\data-types\timeutils.c"
>

View File

@ -43,7 +43,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../include/libetpan/;../include;../../src/gnu"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_MBCS"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_MBCS;USE_SSL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"

View File

@ -84,6 +84,18 @@ void mailsasl_init_lock(){
#endif
}
void mailsasl_uninit_lock(){
#if defined(HAVE_PTHREAD_H) && !defined(IGNORE_PTHREAD_H)
// nothing to do
#elif (defined WIN32)
static int volatile mainsasl_init_lock_done = 0;
if (InterlockedExchange(&mainsasl_init_lock_done, 1) == 0){
DeleteCriticalSection(&sasl_lock);
}
#endif
}
#endif
void mailsasl_external_ref(void)

View File

@ -8,6 +8,8 @@ extern"C"{
extern void mailsasl_init_lock(void);
extern void mailsasl_uninit_lock(void);
#ifdef __cplusplus
}
#endif

View File

@ -239,6 +239,16 @@ void mailstream_ssl_init_lock(void)
#endif
}
void mailstream_ssl_uninit_lock(void)
{
#if !defined (HAVE_PTHREAD_H) && defined (WIN32) && defined (USE_SSL)
static long volatile mailstream_ssl_init_lock_done = 0;
if (InterlockedExchange(&mailstream_ssl_init_lock_done, 1) == 0) {
DeleteCriticalSection(&ssl_lock);
}
#endif
}
void mailstream_gnutls_init_not_required(void)
{
}

View File

@ -39,6 +39,8 @@ extern "C"
extern void mailstream_ssl_init_lock(void);
extern void mailstream_ssl_uninit_lock(void);
#ifdef __cplusplus
}
#endif

View File

@ -98,6 +98,13 @@ void mmapstring_init_lock(void)
#endif
}
void mmapstring_uninit_lock(void)
{
#if !defined (HAVE_PTHREAD_H) && defined (WIN32)
DeleteCriticalSection(&mmapstring_lock);
#endif
}
static void mmapstring_hashtable_init(void)
{
mmapstring_hashtable = chash_new(CHASH_DEFAULTSIZE, CHASH_COPYKEY);

View File

@ -39,6 +39,8 @@ extern "C"
extern void mmapstring_init_lock(void);
extern void mmapstring_uninit_lock(void);
#ifdef __cplusplus
}
#endif

View File

@ -67,6 +67,14 @@ class win_init {
}
~win_init() {
WSACleanup();
#ifdef USE_SSL
mailstream_ssl_uninit_lock();
#endif
#ifdef USE_SASL
mailsasl_uninit_lock();
#endif
}
private:

View File

@ -242,6 +242,7 @@ int main(int argc, char **argv) {
struct mem_message message;
int r;
#if HAVE_GETOPT_LONG
int indx;
static struct option long_options[] = {
@ -316,5 +317,8 @@ int main(int argc, char **argv) {
send_message(message.data, message.len, argv);
release(&message);
fprintf(stdout, "Sent ok.\n");
return EXIT_SUCCESS;
}