Browse Source

added critical section deletion on windows

pull/2/merge
dunemaster 7 years ago
parent
commit
c09f9cad2d
10 changed files with 60 additions and 1 deletions
  1. +12
    -0
      build-windows/libetpan/libetpan.vcproj
  2. +1
    -1
      build-windows/smtpsend/smtpsend.vcproj
  3. +12
    -0
      src/data-types/mailsasl.c
  4. +2
    -0
      src/data-types/mailsasl_private.h
  5. +10
    -0
      src/data-types/mailstream_ssl.c
  6. +2
    -0
      src/data-types/mailstream_ssl_private.h
  7. +7
    -0
      src/data-types/mmapstring.c
  8. +2
    -0
      src/data-types/mmapstring_private.h
  9. +8
    -0
      src/windows/win_init.cpp
  10. +4
    -0
      tests/smtpsend.c

+ 12
- 0
build-windows/libetpan/libetpan.vcproj 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"
>


+ 1
- 1
build-windows/smtpsend/smtpsend.vcproj 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"


+ 12
- 0
src/data-types/mailsasl.c 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)


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

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


+ 10
- 0
src/data-types/mailstream_ssl.c 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)
{
}


+ 2
- 0
src/data-types/mailstream_ssl_private.h 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


+ 7
- 0
src/data-types/mmapstring.c 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);


+ 2
- 0
src/data-types/mmapstring_private.h View File

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


+ 8
- 0
src/windows/win_init.cpp 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:


+ 4
- 0
tests/smtpsend.c 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;
}

Loading…
Cancel
Save