transactd 1.0.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README +1 -1
  3. data/README-JA +1 -1
  4. data/bin/common/tdclc_32_1_1.dll +0 -0
  5. data/bin/common/tdclc_64_1_1.dll +0 -0
  6. data/build/common/transactd_common.cmake +6 -2
  7. data/build/tdclc/CMakeLists.txt +9 -0
  8. data/build/tdclc/tdclc_32.cbproj +2 -10
  9. data/build/tdclc/tdclc_64.cbproj +2 -9
  10. data/build/tdclcpp/tdclcpp_bcb_32.cbproj +3 -7
  11. data/build/tdclcpp/tdclcpp_bcb_64.cbproj +1 -15
  12. data/build/tdclrb/CMakeLists.txt +12 -4
  13. data/build/tdclrb/GEM_VERSION +2 -2
  14. data/source/bzs/db/engine/mysql/mysqlThd.cpp +5 -4
  15. data/source/bzs/db/engine/mysql/mysqlThd.h +1 -1
  16. data/source/bzs/db/protocol/tdap/btrDate.cpp +15 -4
  17. data/source/bzs/db/protocol/tdap/client/client.cpp +2 -2
  18. data/source/bzs/db/protocol/tdap/client/client.h +46 -18
  19. data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +53 -11
  20. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +50 -28
  21. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +5 -2
  22. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +19 -1
  23. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +16 -5
  24. data/source/bzs/db/protocol/tdap/tdapcapi.h +9 -4
  25. data/source/bzs/db/transactd/transactd.cpp +22 -8
  26. data/source/bzs/env/compiler.h +6 -0
  27. data/source/bzs/env/crosscompile.h +9 -1
  28. data/source/bzs/example/changeSchema.cpp +6 -6
  29. data/source/bzs/example/changeSchema_c.cpp +4 -4
  30. data/source/bzs/example/createDatabase.cpp +7 -7
  31. data/source/bzs/example/deleteRecords.cpp +2 -2
  32. data/source/bzs/example/deleteRecords_c.cpp +1 -1
  33. data/source/bzs/example/dropDatabase.cpp +4 -1
  34. data/source/bzs/example/dropDatabase_c.cpp +1 -1
  35. data/source/bzs/example/insertRecords.cpp +1 -1
  36. data/source/bzs/example/readRecords.cpp +1 -1
  37. data/source/bzs/example/updateRecords.cpp +1 -1
  38. data/source/bzs/example/update_with_transaction.cpp +1 -1
  39. data/source/bzs/example/update_with_transaction_c.cpp +1 -1
  40. data/source/bzs/netsvc/client/tcpClient.cpp +3 -2
  41. data/source/bzs/rtl/datetime.cpp +15 -5
  42. data/source/bzs/test/trdclengn/test_trdclengn.cpp +1 -1
  43. metadata +3 -3
  44. data/bin/common/tdclc_32_1_0.dll +0 -0
  45. data/bin/common/tdclc_64_1_0.dll +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eee3cdfaa3f792fa78bdd768a1e1bd59aab2d397
4
- data.tar.gz: b3bdc6c8537f1702937fec029a738741acf7ce36
3
+ metadata.gz: 7f89d3c2a7bda1a1c1acbe8113106f860cac1ede
4
+ data.tar.gz: 33eb8baabb33c8915a9fc68dd5bb8cf4b3198d76
5
5
  SHA512:
6
- metadata.gz: d9c9fd281de6502256b7c224c4e1a5ea0f76feec5c3e3835c18f80d90154d2e94ed178deffc408c9af08f404e221518adf8b639a7035a6694a3870e1c46e1aa1
7
- data.tar.gz: af652139f6b992ae9bd0785633f617a6720d104b1559fce4ee94519a4d35da99490b01ece82e695cf6e1b212ba70b013a6018b3f579e865bd19ffed82e30e58f
6
+ metadata.gz: 1341f50aaae62539ab3844a0658836f516ea75f47d48879e78e34f795f12fa41743a580ec1b54d4c93fb8408729d44f770514a1aee17fe2cf0b0a73058317123
7
+ data.tar.gz: 8ca6b44afd9d429e98c673a32982b0a759c1a2ab304029778262c5729ffdbf0bb7311f18d86b5ee5df29b6d2baac4a1841d0fdfaf679fa45b1ea2a3a4a7c53dc
data/README CHANGED
@@ -258,7 +258,7 @@ to drop a database.
258
258
  mysql>drop database test;
259
259
  ```
260
260
 
261
- If `-- showprogress=yes` is passed, it shows progress like:
261
+ If `-- show_progress=yes` is passed, it shows progress like:
262
262
  ```
263
263
  0% 10 20 30 40 50 60 70 80 90 100%
264
264
  |----|----|----|----|----|----|----|----|----|----|
data/README-JA CHANGED
@@ -266,7 +266,7 @@ mysql>drop database test;
266
266
  ```
267
267
  を実行しデータベースを事前に削除してください。
268
268
 
269
- コマンドライン引数に `--showprogress=yes` を追加すると下記のように実行状況をプロ
269
+ コマンドライン引数に `--show_progress=yes` を追加すると下記のように実行状況をプロ
270
270
  グレス表示します。
271
271
  ```
272
272
  0% 10 20 30 40 50 60 70 80 90 100%
Binary file
Binary file
@@ -208,8 +208,12 @@ macro(transactd_link_boost_libraries boost_components)
208
208
  if(MINGW)
209
209
  target_link_libraries(${this_target} ${Boost_LIBRARIES})
210
210
  else()
211
- # need "-lrt" after chrono or timer
212
- target_link_libraries(${this_target} ${Boost_LIBRARIES} rt)
211
+ if(APPLE)
212
+ target_link_libraries(${this_target} ${Boost_LIBRARIES})
213
+ else()
214
+ # need "-lrt" after chrono or timer
215
+ target_link_libraries(${this_target} ${Boost_LIBRARIES} rt)
216
+ endif()
213
217
  endif()
214
218
  endif()
215
219
  ## find Boost for Visual Studio /MD or /MDd or /MT or /MTd
@@ -67,6 +67,12 @@ set(${this_target}_SOURCE_FILES
67
67
  ${TRANSACTD_ROOT}/source/bzs/netsvc/client/tcpClient.cpp
68
68
  ${TRANSACTD_ROOT}/source/bzs/rtl/stl_uty.cpp
69
69
  )
70
+ if(APPLE)
71
+ set(${this_target}_SOURCE_FILES ${${this_target}_SOURCE_FILES}
72
+ ${TRANSACTD_ROOT}/source/bzs/env/crosscompile.cpp
73
+ ${TRANSACTD_ROOT}/source/bzs/env/mbcswchrLinux.cpp
74
+ )
75
+ endif()
70
76
 
71
77
 
72
78
  # ==========================================================
@@ -129,6 +135,9 @@ add_library(${this_target} SHARED ${${this_target}_SOURCE_FILES})
129
135
  # add link / include
130
136
  # ==========================================================
131
137
  transactd_link_boost_libraries("filesystem;system;thread")
138
+ if(APPLE)
139
+ target_link_libraries(${this_target} iconv)
140
+ endif()
132
141
 
133
142
 
134
143
  # ==========================================================
@@ -26,9 +26,7 @@
26
26
  <PropertyGroup Condition="'$(Base)'!=''">
27
27
  <Defines>BOOST_ALL_NO_LIB;TRANSACTD;$(Defines)</Defines>
28
28
  <BRCC_CompilerToUse>rc</BRCC_CompilerToUse>
29
- <BRCC_Defines>__BCPLUSPLUS__;$(BRCC_Defines)</BRCC_Defines>
30
- <VerInfo_DLL>true</VerInfo_DLL>
31
- <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
29
+ <BRCC_IncludePath>$(BDSINCLUDE)\windows\sdk;$(BRCC_IncludePath)</BRCC_IncludePath>
32
30
  <DllSuffix>_1_0</DllSuffix>
33
31
  <DynamicRTL>false</DynamicRTL>
34
32
  <BPILibOutputDir>..\..\lib</BPILibOutputDir>
@@ -38,10 +36,7 @@
38
36
  <Manifest_File>None</Manifest_File>
39
37
  <IncludePath>..\..\source\;$(IncludePath)</IncludePath>
40
38
  <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
41
- <VerInfo_Locale>1041</VerInfo_Locale>
42
- <VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
43
39
  <OutputExt>dll</OutputExt>
44
- <PackageImports>vcl.bpi;rtl.bpi</PackageImports>
45
40
  <Multithreaded>true</Multithreaded>
46
41
  <NoVCL>true</NoVCL>
47
42
  <ProjectType>VCppStyleDll</ProjectType>
@@ -77,7 +72,7 @@
77
72
  </PropertyGroup>
78
73
  <ItemGroup>
79
74
  <ResourceCompile Include="tdclc.rc">
80
- <Form>tdclcpp.res</Form>
75
+ <Form>tdclc.res</Form>
81
76
  <BuildOrder>20</BuildOrder>
82
77
  </ResourceCompile>
83
78
  <CppCompile Include="..\..\source\bzs\db\protocol\tdap\client\client.cpp">
@@ -114,9 +109,6 @@
114
109
  <DependentOn>..\..\netsvc\client\tcpClient.h</DependentOn>
115
110
  <BuildOrder>2</BuildOrder>
116
111
  </CppCompile>
117
- <CppCompile Include="..\..\source\bzs\rtl\datetime.cpp">
118
- <BuildOrder>13</BuildOrder>
119
- </CppCompile>
120
112
  <CppCompile Include="..\..\source\bzs\rtl\stl_uty.cpp">
121
113
  <BuildOrder>9</BuildOrder>
122
114
  </CppCompile>
@@ -43,9 +43,7 @@
43
43
  <PropertyGroup Condition="'$(Base)'!=''">
44
44
  <Defines>BOOST_ALL_NO_LIB;TRANSACTD;$(Defines)</Defines>
45
45
  <BRCC_CompilerToUse>rc</BRCC_CompilerToUse>
46
- <BRCC_Defines>__BCPLUSPLUS__;$(BRCC_Defines)</BRCC_Defines>
47
- <VerInfo_DLL>true</VerInfo_DLL>
48
- <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
46
+ <BRCC_IncludePath>$(BDSINCLUDE)\windows\sdk;$(BRCC_IncludePath)</BRCC_IncludePath>
49
47
  <DllSuffix>_1_0</DllSuffix>
50
48
  <DynamicRTL>false</DynamicRTL>
51
49
  <BPILibOutputDir>..\..\lib</BPILibOutputDir>
@@ -55,8 +53,6 @@
55
53
  <Manifest_File>None</Manifest_File>
56
54
  <IncludePath>..\..\source\;$(IncludePath)</IncludePath>
57
55
  <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
58
- <VerInfo_Locale>1041</VerInfo_Locale>
59
- <VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
60
56
  <OutputExt>dll</OutputExt>
61
57
  <PackageImports>vcl.bpi;rtl.bpi</PackageImports>
62
58
  <Multithreaded>true</Multithreaded>
@@ -101,7 +97,7 @@
101
97
  </PropertyGroup>
102
98
  <ItemGroup>
103
99
  <ResourceCompile Include="tdclc.rc">
104
- <Form>tdclcpp.res</Form>
100
+ <Form>tdclc.res</Form>
105
101
  <BuildOrder>20</BuildOrder>
106
102
  </ResourceCompile>
107
103
  <CppCompile Include="..\..\source\bzs\db\protocol\tdap\client\client.cpp">
@@ -138,9 +134,6 @@
138
134
  <DependentOn>..\..\netsvc\client\tcpClient.h</DependentOn>
139
135
  <BuildOrder>2</BuildOrder>
140
136
  </CppCompile>
141
- <CppCompile Include="..\..\source\bzs\rtl\datetime.cpp">
142
- <BuildOrder>13</BuildOrder>
143
- </CppCompile>
144
137
  <CppCompile Include="..\..\source\bzs\rtl\stl_uty.cpp">
145
138
  <BuildOrder>9</BuildOrder>
146
139
  </CppCompile>
@@ -36,15 +36,12 @@
36
36
  <PropertyGroup Condition="'$(Base)'!=''">
37
37
  <BRCC_EnableMultiByte>true</BRCC_EnableMultiByte>
38
38
  <BRCC_CompilerToUse>rc</BRCC_CompilerToUse>
39
- <BRCC_Defines>__BCPLUSPLUS__;$(BRCC_Defines)</BRCC_Defines>
39
+ <BRCC_IncludePath>$(BDSINCLUDE)\windows\sdk;$(BRCC_IncludePath)</BRCC_IncludePath>
40
40
  <Defines>ARBTREGN_PKG;BOOST_ALL_NO_LIB;$(Defines)</Defines>
41
- <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
42
- <VerInfo_Keys>CompanyName=BizStation Corp;FileDescription=;FileVersion=1.1.0.0;InternalName=;LegalCopyright=Copy right (C) 2013 BizStation Corp;LegalTrademarks=;OriginalFilename=;ProductName=Transactd Client;ProductVersion=1.1.0.0;Comments=</VerInfo_Keys>
43
- <VerInfo_MinorVer>1</VerInfo_MinorVer>
44
- <VerInfo_DLL>true</VerInfo_DLL>
45
41
  <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
46
- <VerInfo_Locale>1041</VerInfo_Locale>
47
42
  <BCC_wiip>false</BCC_wiip>
43
+ <BCC_wpch>false</BCC_wpch>
44
+ <BCC_wpar>false</BCC_wpar>
48
45
  <Multithreaded>true</Multithreaded>
49
46
  <ILINK_LibraryPath>..\..\lib;$(ILINK_LibraryPath)</ILINK_LibraryPath>
50
47
  <ProjectType>CppDynamicLibrary</ProjectType>
@@ -59,7 +56,6 @@
59
56
  <UsePackages>false</UsePackages>
60
57
  <IntermediateOutputDir>.\$(Config)\$(Platform)</IntermediateOutputDir>
61
58
  <FinalOutputDir>..\..\bin\</FinalOutputDir>
62
- <BCC_wpar>false</BCC_wpar>
63
59
  <BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>
64
60
  <BCC_ExtendedErrorInfo>true</BCC_ExtendedErrorInfo>
65
61
  <TD_VER_MAJOR>1</TD_VER_MAJOR>
@@ -64,16 +64,12 @@
64
64
  <PropertyGroup Condition="'$(Base)'!=''">
65
65
  <ILINK_LibraryPath>..\..\lib;$(ILINK_LibraryPath)</ILINK_LibraryPath>
66
66
  <BRCC_CompilerToUse>rc</BRCC_CompilerToUse>
67
- <BRCC_Defines>__BCPLUSPLUS__;$(BRCC_Defines)</BRCC_Defines>
67
+ <BRCC_IncludePath>$(BDSINCLUDE)\windows\sdk;$(BRCC_IncludePath)</BRCC_IncludePath>
68
68
  <BRCC_EnableMultiByte>true</BRCC_EnableMultiByte>
69
- <VerInfo_MinorVer>1</VerInfo_MinorVer>
70
- <VerInfo_DLL>true</VerInfo_DLL>
71
69
  <Defines>ARBTREGN_PKG;$(Defines)</Defines>
72
70
  <IncludePath>..\..\source\;$(IncludePath)</IncludePath>
73
71
  <Manifest_File>None</Manifest_File>
74
72
  <ILINK_AdditionalOptions>/Gl</ILINK_AdditionalOptions>
75
- <VerInfo_Keys>CompanyName=BizStation Corp;FileDescription=;FileVersion=1.1.0.0;InternalName=;LegalCopyright=Copyright(C) 2013 BizStation Corp;LegalTrademarks=;OriginalFilename=;ProductName=Transactd Client;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
76
- <VerInfo_Locale>1041</VerInfo_Locale>
77
73
  <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
78
74
  <BCC_wiip>false</BCC_wiip>
79
75
  <TD_VER_MAJOR>1</TD_VER_MAJOR>
@@ -100,14 +96,10 @@
100
96
  </PropertyGroup>
101
97
  <PropertyGroup Condition="'$(Base_Win32)'!=''">
102
98
  <Manifest_File>None</Manifest_File>
103
- <VerInfo_Locale>1033</VerInfo_Locale>
104
99
  <DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
105
- <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
106
100
  </PropertyGroup>
107
101
  <PropertyGroup Condition="'$(Base_Win64)'!=''">
108
102
  <DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace)</DCC_Namespace>
109
- <VerInfo_Locale>1033</VerInfo_Locale>
110
- <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
111
103
  </PropertyGroup>
112
104
  <PropertyGroup Condition="'$(Cfg_1)'!=''">
113
105
  <_TCHARMapping>char</_TCHARMapping>
@@ -136,8 +128,6 @@
136
128
  <TASM_Debugging>None</TASM_Debugging>
137
129
  </PropertyGroup>
138
130
  <PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
139
- <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
140
- <VerInfo_Locale>1033</VerInfo_Locale>
141
131
  <Defines>NDEBUG;$(Defines)</Defines>
142
132
  <DllSuffix>m_$(DllSuffix)</DllSuffix>
143
133
  </PropertyGroup>
@@ -149,9 +139,7 @@
149
139
  <BCC_DisableOptimizations>true</BCC_DisableOptimizations>
150
140
  <BCC_OptimizeForSpeed>false</BCC_OptimizeForSpeed>
151
141
  <ILINK_Verbose>true</ILINK_Verbose>
152
- <VerInfo_Locale>1033</VerInfo_Locale>
153
142
  <BCC_SourceDebuggingOn>true</BCC_SourceDebuggingOn>
154
- <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
155
143
  <DllSuffix>u_$(DllSuffix)</DllSuffix>
156
144
  </PropertyGroup>
157
145
  <PropertyGroup Condition="'$(Cfg_4)'!=''">
@@ -162,8 +150,6 @@
162
150
  <BCC_WindowsVersionDefines>NTDDI_VERSION=NTDDI_WINXPSP1;_WIN32_WINNT=_WIN32_WINNT_WINXP</BCC_WindowsVersionDefines>
163
151
  <BCC_OptimizeForSize>true</BCC_OptimizeForSize>
164
152
  <BCC_OptimizeForSpeed>false</BCC_OptimizeForSpeed>
165
- <VerInfo_Locale>1033</VerInfo_Locale>
166
- <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
167
153
  <DllSuffix>u_$(DllSuffix)</DllSuffix>
168
154
  </PropertyGroup>
169
155
  <ItemGroup>
@@ -167,8 +167,12 @@ endif()
167
167
  # ==========================================================
168
168
  # add_library
169
169
  # ==========================================================
170
- add_library(${this_target} SHARED ${${this_target}_SOURCE_FILES})
171
-
170
+ if(APPLE)
171
+ add_library(${this_target} MODULE ${${this_target}_SOURCE_FILES})
172
+ set_target_properties(${this_target} PROPERTIES LINK_FLAGS "-flat_namespace")
173
+ else()
174
+ add_library(${this_target} SHARED ${${this_target}_SOURCE_FILES})
175
+ endif()
172
176
 
173
177
  # ==========================================================
174
178
  # add link / include
@@ -187,8 +191,12 @@ target_link_libraries(${this_target} ${TRANSACTD_RUBY_LIBRARY_PATH})
187
191
  # ==========================================================
188
192
  set_target_properties(${this_target} PROPERTIES PREFIX "")
189
193
  set_target_properties(${this_target} PROPERTIES OUTPUT_NAME transactd)
190
- set_target_properties(${this_target} PROPERTIES SUFFIX ".so")
191
- if(UNIX)
194
+ if(APPLE)
195
+ set_target_properties(${this_target} PROPERTIES SUFFIX ".bundle")
196
+ else()
197
+ set_target_properties(${this_target} PROPERTIES SUFFIX ".so")
198
+ endif()
199
+ if(UNIX AND NOT APPLE)
192
200
  set_target_properties(${this_target} PROPERTIES
193
201
  SOVERSION ${TDVER_RUBYGEM_MAJOR}.${TDVER_RUBYGEM_MINOR}
194
202
  VERSION ${TDVER_RUBYGEM_MAJOR}.${TDVER_RUBYGEM_MINOR}.${TDVER_RUBYGEM_RELEASE})
@@ -1,3 +1,3 @@
1
1
  TDVER_RUBYGEM_VER_MAJOR 1
2
- TDVER_RUBYGEM_VER_MINOR 0
3
- TDVER_RUBYGEM_VER_RELEASE 1
2
+ TDVER_RUBYGEM_VER_MINOR 1
3
+ TDVER_RUBYGEM_VER_RELEASE 2
@@ -27,15 +27,16 @@ extern unsigned int g_lock_wait_timeout;
27
27
  extern char* g_transaction_isolation;
28
28
 
29
29
  #ifdef USETLS
30
- DWORD g_tlsiID = 0;
30
+ tls_key g_tlsiID ;
31
+ #else
32
+ __THREAD char* __THREAD_BCB t_stack = NULL;
31
33
  #endif
32
34
 
33
- __THREAD char* __THREAD_BCB t_stack = NULL;
34
35
 
35
36
  inline char* getStackaddr()
36
37
  {
37
38
  #ifdef USETLS
38
- return (char*)TlsGetValue(g_tlsiID);
39
+ return (char*)tls_getspecific(g_tlsiID);
39
40
  #else
40
41
  return t_stack;
41
42
  #endif
@@ -44,7 +45,7 @@ inline char* getStackaddr()
44
45
  inline void setStackaddr(char* v)
45
46
  {
46
47
  #ifdef USETLS
47
- TlsSetValue(g_tlsiID, v);
48
+ tls_setspecific(g_tlsiID, v);
48
49
  #else
49
50
  t_stack = v;
50
51
  #endif
@@ -28,7 +28,7 @@ THD* createThdForThread();
28
28
  void deleteThdForThread(THD* thd);
29
29
  void endThread();
30
30
 
31
- #ifdef _WIN32
31
+ #if (defined(_WIN32) || defined(__APPLE__))
32
32
  #define USETLS
33
33
  #endif
34
34
 
@@ -31,17 +31,28 @@
31
31
 
32
32
  #pragma package(smart_init)
33
33
 
34
+ #undef USETLS
35
+ #if ((defined(_WIN32) && _MSC_VER) || __APPLE__)
36
+ #define USETLS
37
+ #endif
38
+
34
39
 
35
- #if (defined(_WIN32) && _MSC_VER)
36
- extern DWORD g_tlsiID_SC2;
40
+ #ifdef USETLS
41
+ extern tls_key g_tlsiID_SC2;
37
42
  #else
38
43
  __THREAD _TCHAR __THREAD_BCB g_date2[45];
39
44
  #endif
40
45
 
41
46
  inline _TCHAR* databuf()
42
47
  {
43
- #if (defined(_WIN32) && _MSC_VER)
44
- return (_TCHAR*)TlsGetValue(g_tlsiID_SC2);
48
+ #ifdef USETLS
49
+ _TCHAR* p = (_TCHAR*)tls_getspecific(g_tlsiID_SC2);
50
+ if (p == NULL)
51
+ {
52
+ p = (_TCHAR*)new wchar_t[45];
53
+ tls_setspecific(g_tlsiID_SC2, p);
54
+ }
55
+ return p;
45
56
  #else
46
57
  return g_date2;
47
58
  #endif
@@ -36,8 +36,8 @@ namespace tdap
36
36
  namespace client
37
37
  {
38
38
 
39
- #if( defined(_WIN32) && defined(_MSC_VER))
40
- DWORD g_tlsiID = 0;
39
+ #ifdef USETLS
40
+ tls_key g_tlsiID;
41
41
  #else
42
42
  __THREAD client* __THREAD_BCB g_client=NULL;
43
43
  #endif
@@ -31,7 +31,10 @@
31
31
  #include <vector>
32
32
  #ifdef _WIN32
33
33
  #include <mbstring.h>
34
+ #else
35
+ #include <pthread.h>
34
36
  #endif
37
+
35
38
  extern bzs::netsvc::client::connections* m_cons;
36
39
 
37
40
  namespace bzs
@@ -46,7 +49,8 @@ namespace client
46
49
  {
47
50
  #define TABELNAME_PREFIX "dbfile="
48
51
 
49
-
52
+ class client;
53
+ void setClientThread(client* v);
50
54
 
51
55
  class client
52
56
  {
@@ -60,11 +64,10 @@ class client
60
64
  std::string m_sql;
61
65
  std::string m_serverCharData;
62
66
  std::string m_serverCharData2;
63
-
64
67
  uint_td m_tmplen;
65
68
  bool m_logout;
66
69
  blobBuffer m_blobBuffer;
67
-
70
+ bool m_disconnected;
68
71
 
69
72
  std::vector<char> m_sendbuf;
70
73
  inline bzs::netsvc::client::connection* con(){return m_req.cid->con;};
@@ -72,7 +75,10 @@ class client
72
75
 
73
76
  inline void disconnect()
74
77
  {
75
- m_req.result = !m_cons->disconnect(con());
78
+ if (!con())
79
+ m_req.result = 1;
80
+ else
81
+ m_disconnected = m_cons->disconnect(con());
76
82
  if (m_req.result==0)
77
83
  setCon(NULL);
78
84
  }
@@ -106,8 +112,13 @@ class client
106
112
  }
107
113
  static void addSecondCharsetData(unsigned int destCodePage, std::string& src);
108
114
  public:
109
- client():m_charsetIndexServer(-1)
115
+ client():m_charsetIndexServer(-1),m_disconnected(true)
116
+ {
117
+ }
118
+ void cleanup()
110
119
  {
120
+ if (m_disconnected)
121
+ setClientThread(NULL);
111
122
  }
112
123
  request& req(){return m_req;}
113
124
  inline void setParam(ushort_td op, posblk* pbk,
@@ -136,9 +147,8 @@ public:
136
147
  {
137
148
  if (m_op==TD_STOP_ENGINE)
138
149
  {
139
- m_req.result = !m_cons->disconnect(con());
140
- if (m_req.result==0)
141
- setCon(NULL);
150
+ m_req.result = 0;
151
+ disconnect();
142
152
  return !m_req.result;
143
153
  }
144
154
  return false;
@@ -153,7 +163,7 @@ public:
153
163
  setCon(m_cons->connect(host)); //if error throw exception
154
164
 
155
165
  }
156
-
166
+ m_disconnected = !m_req.cid->con;
157
167
  }
158
168
  inline void create()
159
169
  {
@@ -176,7 +186,6 @@ public:
176
186
  }else if ((m_req.keyNum == CR_SUBOP_SWAPNAME)||(m_req.keyNum == CR_SUBOP_RENAME))
177
187
  {
178
188
  readServerCharsetIndex();
179
- //m_sql = std::string((char*)m_req.data, *m_req.datalen);
180
189
  m_sql = (char*)m_req.data;
181
190
  addSecondCharsetData(mysql::codePage(m_charsetIndexServer), m_sql);
182
191
  m_req.data =(ushort_td*) m_sql.c_str();
@@ -211,7 +220,6 @@ public:
211
220
  {
212
221
  if (result()==0)
213
222
  {
214
- //mutex::scoped_lock lck(m_mutex);
215
223
  if (!con())
216
224
  m_preResult = ERROR_TD_NOT_CONNECTED;
217
225
  else
@@ -257,27 +265,47 @@ public:
257
265
 
258
266
  };
259
267
 
260
- #ifndef _MSC_VER
261
- extern __THREAD client* __THREAD_BCB g_client;
268
+ #define USETLS //USE TLS ALL
269
+
270
+
271
+
272
+ #ifdef USETLS
273
+ extern tls_key g_tlsiID;
262
274
  #else
263
- extern DWORD g_tlsiID;
275
+ extern __THREAD client* __THREAD_BCB g_client;
264
276
  #endif
265
277
 
266
278
 
279
+
267
280
  inline client* getClientThread()
268
281
  {
269
- #ifdef _MSC_VER
270
- return (client*)TlsGetValue(g_tlsiID);
282
+ #ifdef USETLS
283
+ client* p = (client*)tls_getspecific(g_tlsiID);
284
+ if (p == NULL)
285
+ {
286
+ p = new client();
287
+ tls_setspecific(g_tlsiID, p);
288
+ }
289
+ return p;
271
290
  #else
291
+ if (g_client == NULL)
292
+ g_client = new client();
272
293
  return g_client;
273
294
  #endif
274
295
  }
275
296
 
276
297
  inline void setClientThread(client* v)
277
298
  {
278
- #ifdef _MSC_VER
279
- TlsSetValue(g_tlsiID, v);
299
+ #ifdef USETLS
300
+ if (v == NULL)
301
+ {
302
+ client* p = (client*)tls_getspecific(g_tlsiID);
303
+ delete p;
304
+ }
305
+ tls_setspecific(g_tlsiID, v);
280
306
  #else
307
+ if (v == NULL)
308
+ delete g_client;
281
309
  g_client = v;
282
310
  #endif
283
311
  }
@@ -20,7 +20,7 @@
20
20
  #pragma hdrstop
21
21
 
22
22
  #include "database.h"
23
-
23
+ #include <bzs/rtl/exception.h>
24
24
  //---------------------------------------------------------------------------
25
25
 
26
26
 
@@ -40,7 +40,12 @@ namespace client
40
40
 
41
41
  database* database::create()
42
42
  {
43
- return new database();
43
+ try
44
+ {
45
+ return new database();
46
+ }
47
+ catch( bzs::rtl::exception& /*e*/){}
48
+ return NULL;
44
49
  }
45
50
 
46
51
  }//namespace client
@@ -49,23 +54,59 @@ database* database::create()
49
54
  }//namespace db
50
55
  }//namespace bzs
51
56
 
57
+
58
+ #undef USETLS
59
+ #if ((defined(_WIN32) && _MSC_VER) || __APPLE__)
60
+ #define USETLS
61
+ #endif
62
+
52
63
  /* At MSVC use __thread before Windows Vista, After the DLL is loaded with LoadLibrary
53
64
  then it causes system failure.
54
65
 
55
66
  */
56
- #if (defined(_WIN32) && _MSC_VER)
57
- DWORD g_tlsiID_SC1 = 0;
58
- DWORD g_tlsiID_SC2 = 0;
59
- DWORD g_tlsiID_SC3 = 0;
67
+ #ifdef USETLS
68
+ tls_key g_tlsiID_SC1;
69
+ tls_key g_tlsiID_SC2;
70
+ tls_key g_tlsiID_SC3;
60
71
 
61
72
  void initTlsThread()
62
73
  {
63
- TlsSetValue(g_tlsiID_SC1, new wchar_t[256]);
74
+ tls_setspecific(g_tlsiID_SC1, new wchar_t[256]);
75
+ tls_setspecific(g_tlsiID_SC2, new wchar_t[45]);
76
+ tls_setspecific(g_tlsiID_SC3, new wchar_t[45]);
77
+ }
64
78
 
65
- TlsSetValue(g_tlsiID_SC2, new wchar_t[45]);
66
- TlsSetValue(g_tlsiID_SC3, new wchar_t[45]);
79
+ void cleanupTls()
80
+ {
81
+ delete (char*)tls_getspecific(g_tlsiID_SC1);
82
+ delete (char*)tls_getspecific(g_tlsiID_SC2);
83
+ delete (char*)tls_getspecific(g_tlsiID_SC3);
67
84
  }
68
85
 
86
+ #ifdef __APPLE__
87
+
88
+ void __attribute__ ((constructor)) onLoadLibrary(void);
89
+ void __attribute__ ((destructor)) onUnloadLibrary(void);
90
+
91
+ void onLoadLibrary(void)
92
+ {
93
+ pthread_key_create(&g_tlsiID_SC1, NULL);
94
+ pthread_key_create(&g_tlsiID_SC2, NULL);
95
+ pthread_key_create(&g_tlsiID_SC3, NULL);
96
+ }
97
+
98
+ void onUnloadLibrary(void)
99
+ {
100
+ cleanupTls();
101
+ pthread_key_delete(g_tlsiID_SC1);
102
+ pthread_key_delete(g_tlsiID_SC2);
103
+ pthread_key_delete(g_tlsiID_SC3);
104
+ }
105
+
106
+
107
+
108
+ #else
109
+
69
110
  BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved)
70
111
  {
71
112
  if (reason == DLL_PROCESS_ATTACH)
@@ -77,7 +118,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved)
77
118
  if ((g_tlsiID_SC3 = TlsAlloc()) == TLS_OUT_OF_INDEXES)
78
119
  return FALSE;
79
120
  initTlsThread();
80
-
81
121
  }
82
122
  else if(reason == DLL_THREAD_ATTACH)
83
123
  {
@@ -85,16 +125,18 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved)
85
125
  }
86
126
  else if(reason == DLL_THREAD_DETACH)
87
127
  {
88
-
128
+ cleanupTls();
89
129
  }
90
130
  else if (reason == DLL_PROCESS_DETACH)
91
131
  {
132
+ cleanupTls();
92
133
  TlsFree(g_tlsiID_SC1);
93
134
  TlsFree(g_tlsiID_SC2);
94
135
  TlsFree(g_tlsiID_SC3);
95
136
  }
96
137
  return TRUE;
97
138
  }
139
+ #endif
98
140
  #endif //(_UNICODE && defined(_WIN32) && _MSC_VER)
99
141
 
100
142