Commit 3447b5769cfbb41d7a2259ac064de203b961b8fb

Authored by Perry Werneck
1 parent 419c23cd

Incluindo cleanup de todas as sessões ao final da carga dos módulos de API.

Showing 2 changed files with 37 additions and 17 deletions   Show diff stats
src/classlib/session.cc
... ... @@ -49,6 +49,43 @@
49 49  
50 50 /*--[ Implement ]--------------------------------------------------------------------------------------------------*/
51 51  
  52 + using namespace PW3270_NAMESPACE;
  53 +
  54 +#if defined(linux)
  55 + static void onLoad() __attribute__((constructor));
  56 + static void onUnLoad() __attribute__((destructor));
  57 +
  58 + static void onLoad()
  59 + {
  60 + session::init();
  61 + }
  62 +
  63 + static void onUnLoad()
  64 + {
  65 + session::deinit();
  66 + }
  67 +
  68 +#endif // linux
  69 +
  70 +#ifdef _WIN32
  71 +
  72 + BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  73 + {
  74 + switch(reason)
  75 + {
  76 + case DLL_PROCESS_ATTACH:
  77 + session::init();
  78 + break;
  79 +
  80 + case DLL_PROCESS_DETACH
  81 + session::deinit();
  82 + break;
  83 + }
  84 + }
  85 +
  86 +#endif // _WIN32
  87 +
  88 +
52 89 namespace PW3270_NAMESPACE {
53 90  
54 91 session * session::first = nullptr;
... ...
src/java/main.cc
... ... @@ -32,23 +32,6 @@
32 32  
33 33 /*---[ Implement ]----------------------------------------------------------------------------------*/
34 34  
35   -#if defined(linux)
36   - static void onLoad() __attribute__((constructor));
37   - static void onUnLoad() __attribute__((destructor));
38   -#endif // linux
39   -
40   - using namespace PW3270_NAMESPACE;
41   -
42   - static void onLoad()
43   - {
44   - session::init();
45   - }
46   -
47   - static void onUnLoad()
48   - {
49   - session::deinit();
50   - }
51   -
52 35 namespace PW3270_NAMESPACE {
53 36  
54 37 jfieldID java::getHandleField(JNIEnv *env, jobject obj) {
... ...