transactd 3.4.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CMakeLists.txt +2 -2
  3. data/bin/common/tdclc_32_3_5.dll +0 -0
  4. data/bin/common/tdclc_64_3_5.dll +0 -0
  5. data/build/common/options.cmake +12 -0
  6. data/build/common/transactd_cl_common.cmake +1 -0
  7. data/build/common/transactd_required.cmake +5 -0
  8. data/build/swig/ruby/tdclrb_wrap.cpp +1029 -130
  9. data/build/swig/tdcl.i +60 -5
  10. data/build/tdclc/CMakeLists.txt +30 -32
  11. data/build/tdclc/libtdclcm.map +1 -1
  12. data/build/tdclc/tdclc.cbproj +1 -1
  13. data/build/tdclc/tdclc.rc +4 -4
  14. data/build/tdclcpp/CMakeLists.txt +39 -48
  15. data/build/tdclcpp/tdclcpp.rc +4 -4
  16. data/build/tdclcpp/tdclcpp_bc.cbproj +4 -1
  17. data/build/tdclrb/CMakeLists.txt +5 -4
  18. data/build/tdclrb/tdclrb.rc +4 -4
  19. data/source/bzs/db/engine/mysql/database.cpp +45 -35
  20. data/source/bzs/db/engine/mysql/database.h +6 -8
  21. data/source/bzs/db/engine/mysql/dbManager.cpp +11 -0
  22. data/source/bzs/db/engine/mysql/dbManager.h +1 -0
  23. data/source/bzs/db/engine/mysql/ha.cpp +174 -0
  24. data/source/bzs/db/engine/mysql/ha.h +50 -0
  25. data/source/bzs/db/engine/mysql/mysqlInternal.h +18 -1
  26. data/source/bzs/db/engine/mysql/mysqlProtocol.cpp +222 -9
  27. data/source/bzs/db/engine/mysql/mysqlProtocol.h +5 -0
  28. data/source/bzs/db/protocol/tdap/client/client.cpp +23 -9
  29. data/source/bzs/db/protocol/tdap/client/client.h +125 -94
  30. data/source/bzs/db/protocol/tdap/client/connMgr.cpp +139 -30
  31. data/source/bzs/db/protocol/tdap/client/connMgr.h +40 -8
  32. data/source/bzs/db/protocol/tdap/client/database.cpp +17 -17
  33. data/source/bzs/db/protocol/tdap/client/database.h +15 -0
  34. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +10 -4
  35. data/source/bzs/db/protocol/tdap/client/haNameResolver.cpp +486 -0
  36. data/source/bzs/db/protocol/tdap/client/haNameResolver.h +74 -0
  37. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +102 -71
  38. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +15 -3
  39. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +2 -5
  40. data/source/bzs/db/protocol/tdap/client/nsTable.h +2 -1
  41. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +2 -2
  42. data/source/bzs/db/protocol/tdap/client/table.cpp +1 -2
  43. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +13 -0
  44. data/source/bzs/db/protocol/tdap/client/trnsctcl.def +1 -0
  45. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +9 -7
  46. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +2 -2
  47. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +328 -117
  48. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +7 -8
  49. data/source/bzs/db/protocol/tdap/tdapcapi.h +81 -41
  50. data/source/bzs/db/transactd/connManager.cpp +118 -93
  51. data/source/bzs/db/transactd/connManager.h +6 -1
  52. data/source/bzs/db/transactd/connectionRecord.h +27 -7
  53. data/source/bzs/db/transactd/transactd.cpp +24 -13
  54. data/source/bzs/env/crosscompile.h +2 -0
  55. data/source/bzs/netsvc/client/iconnection.h +2 -0
  56. data/source/bzs/netsvc/client/tcpClient.cpp +45 -14
  57. data/source/bzs/netsvc/client/tcpClient.h +21 -4
  58. data/source/bzs/netsvc/server/IAppModule.h +1 -0
  59. data/source/bzs/netsvc/server/serverCpt.cpp +1 -1
  60. data/source/bzs/netsvc/server/serverPipe.cpp +2 -0
  61. data/source/bzs/netsvc/server/serverTpool.cpp +3 -5
  62. data/source/bzs/test/tdclatl/test_v3.js +91 -3
  63. data/source/bzs/test/tdclphp/transactd_v3_Test.php +89 -3
  64. data/source/bzs/test/tdclrb/transactd_v3_spec.rb +69 -2
  65. data/source/bzs/test/trdclengn/testField.h +19 -1
  66. data/source/bzs/test/trdclengn/test_tdclcpp_ha.cpp +388 -0
  67. data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +6 -1
  68. data/source/bzs/test/trdclengn/test_trdclengn.cpp +1 -0
  69. data/source/bzs/test/trdclengn/testbase.h +7 -1
  70. data/source/global/replication/haCommand.cpp +843 -0
  71. data/source/global/replication/haCommand.h +78 -0
  72. data/source/global/replication/haMgr.cpp +321 -0
  73. data/source/global/replication/replCommand.cpp +696 -0
  74. data/source/global/replication/replCommand.h +161 -0
  75. data/source/global/tdclatl/BinlogPos.cpp +10 -0
  76. data/source/global/tdclatl/BinlogPos.h +1 -0
  77. data/source/global/tdclatl/ConnMgr.cpp +89 -2
  78. data/source/global/tdclatl/ConnMgr.h +13 -1
  79. data/source/global/tdclatl/ConnRecord.cpp +8 -2
  80. data/source/global/tdclatl/ConnRecord.h +4 -3
  81. data/source/global/tdclatl/Database.cpp +13 -0
  82. data/source/global/tdclatl/Database.h +2 -0
  83. data/source/global/tdclatl/HaNameREsolver.cpp +54 -0
  84. data/source/global/tdclatl/HaNameREsolver.h +68 -0
  85. data/source/global/tdclatl/resource.h +0 -0
  86. data/source/global/tdclatl/tdclatl.idl +76 -5
  87. metadata +16 -6
  88. data/bin/common/tdclc_32_3_4.dll +0 -0
  89. data/bin/common/tdclc_64_3_4.dll +0 -0
  90. data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +0 -423
  91. data/source/bzs/db/protocol/tdap/mysql/debuglog.h +0 -116
@@ -56,16 +56,21 @@ private:
56
56
  void doDisconnectAll();
57
57
  const connection::records& getTableList(const char* dbname, int type) const;
58
58
  bool checkGlobalACL(THD* thd, ulong wantAccess) const;
59
+ const connection::records& readByProtocol(int type, blobBuffer* bb,
60
+ const char* channel=NULL) const;
59
61
  public:
60
62
  connManager(unsigned __int64 me) : m_me(me), m_stat(0){};
61
63
  virtual ~connManager();
62
64
  const connection::records& systemVariables() const;
65
+ const connection::records& extendedVariables(blobBuffer* bb) const;
63
66
  const connection::records& statusVariables() const;
64
67
  const connection::records& getRecords(unsigned __int64 conid, int dbid) const;
65
68
  const connection::records& definedDatabases() const;
66
69
  const connection::records& schemaTables(const char* dbname) const;
67
70
  const connection::records& definedTables(const char* dbname, int type) const;
68
- const connection::records& readSlaveStatus(blobBuffer* bb) const;
71
+ const connection::records& readSlaveStatus(const char* channel, blobBuffer* bb) const;
72
+ const connection::records& slaveHosts(blobBuffer* bb) const;
73
+ const connection::records& channels() const;
69
74
  void disconnect(unsigned __int64 conid);
70
75
  void disconnectAll();
71
76
  short stat() const {return m_stat;}
@@ -129,6 +129,15 @@ struct record
129
129
  {
130
130
  name[0] = 0x00;
131
131
  }
132
+ void reset()
133
+ {
134
+ name[0] = 0x00;
135
+ conId = 0;
136
+ id = 0;
137
+ db = 0;
138
+ updCount = 0;
139
+ status = 0;
140
+ }
132
141
  union
133
142
  {
134
143
  __int64 conId; // 8 byte
@@ -143,7 +152,8 @@ struct record
143
152
  union
144
153
  {
145
154
  unsigned int db;
146
- unsigned int readCount; // 4 byte
155
+ unsigned int readCount;
156
+ unsigned int port; // 4 byte
147
157
  };
148
158
  union
149
159
  {
@@ -188,22 +198,32 @@ struct record
188
198
  MultiByteToWideChar(CP_UTF8, 0, (char*)longValue, -1, buf, size);
189
199
  return buf;
190
200
  }
191
- #else
192
- inline const char* t_name(char* /*buf*/, int /*size*/) const
201
+ #endif
202
+ /*inline const char* t_name(char* buf, int size) const
193
203
  {
194
204
  return name;
195
- }
205
+ }*/
196
206
  const char* value(char* buf, int size) const
197
207
  {
198
208
  if (type == 0)
199
209
  {
200
210
  _i64toa_s(longValue, buf, size, 10);
201
- return buf;
211
+
202
212
  }else if (type == 1)
213
+ strcpy_s(buf, size, name);
214
+ else
215
+ strcpy_s(buf, size, (char*)longValue);
216
+ return buf;
217
+ }
218
+ const char* value_ptr() const
219
+ {
220
+ if (type == 0)
221
+ return (const char*)&longValue;
222
+ else if(type == 1)
203
223
  return name;
204
- return (char*)longValue;
224
+ return (const char*)longValue;
205
225
  }
206
- #endif
226
+
207
227
  }; // 20 + 68 = 88
208
228
 
209
229
  #ifdef MYSQL_DYNAMIC_PLUGIN
@@ -32,12 +32,14 @@
32
32
  #pragma warning(default : 4800)
33
33
 
34
34
  #include <bzs/db/engine/mysql/mysqlThd.h>
35
+ #include <bzs/db/engine/mysql/ha.h>
35
36
  #include "appBuilderImple.h"
36
37
 
37
38
  /** tcp server type
38
39
  */
39
40
  #define TCP_CPT_SERVER 1
40
41
  #define TCP_TPOOL_SERVER 2
42
+
41
43
  #define PIPE_SHARE_MEM_SIZE 6292480 // 6Mbyte + 1024
42
44
 
43
45
  using namespace bzs::netsvc::server;
@@ -47,7 +49,7 @@ using namespace bzs::netsvc::server;
47
49
  static char* g_listenAddress = NULL;
48
50
  static char* g_listenPort = NULL;
49
51
  static char* g_hostCheckUserName = NULL;
50
- static unsigned int g_tcpServerType = TCP_CPT_SERVER;
52
+ unsigned int g_tcpServerType = TCP_CPT_SERVER;
51
53
  static unsigned int g_maxTcpConnections = 200;
52
54
  static unsigned int g_pool_threads = 20;
53
55
  int g_tableNmaeLower = 1; // defined in btrvProtocol.h
@@ -56,7 +58,8 @@ char* g_transaction_isolation = NULL;
56
58
  char* g_auth_type = NULL;
57
59
  unsigned int g_pipeCommSharememSize = PIPE_SHARE_MEM_SIZE;
58
60
  unsigned int g_timestamp_always = 1;
59
- //int g_grant_apply = 0;//skip
61
+ unsigned int g_startup_ha = 0;
62
+ extern unsigned int g_ha;// defined in srvrole.cpp
60
63
 
61
64
 
62
65
  /** tcp server
@@ -101,6 +104,7 @@ static int transactd_plugin_init(void* p)
101
104
  {
102
105
  try
103
106
  {
107
+ bzs::db::engine::mysql::initHa();
104
108
  if (g_tcpServerType == TCP_CPT_SERVER)
105
109
  {
106
110
  boost::shared_ptr<IAppModuleBuilder> app(new transctionalIF(
@@ -255,6 +259,12 @@ static MYSQL_SYSVAR_STR(transaction_isolation, g_transaction_isolation,
255
259
  static MYSQL_SYSVAR_STR(auth_type, g_auth_type,
256
260
  PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC, NULL, NULL,
257
261
  NULL, "none"); //or "mysql_native"
262
+ static MYSQL_SYSVAR_UINT(timestamp_always, g_timestamp_always, PLUGIN_VAR_READONLY, "", 0,
263
+ 0, 1, 0, 1, 0);
264
+ static MYSQL_SYSVAR_UINT(startup_ha, g_startup_ha,
265
+ PLUGIN_VAR_READONLY, "0...7", 0, 0, 0, 0, 7, 0);
266
+
267
+
258
268
  /*static MYSQL_SYSVAR_INT(grant_apply, g_grant_apply,
259
269
  PLUGIN_VAR_READONLY, "0..1 0:none 1:all", 0, 0, 0, 0, 1, 0);
260
270
  */
@@ -275,9 +285,6 @@ static MYSQL_SYSVAR_STR(hs_port, g_hs_listenPort,
275
285
  static MYSQL_SYSVAR_INT(use_handlersocket, g_use_hs, PLUGIN_VAR_READONLY, "", 0,
276
286
  0, 0, 0, 1, 0);
277
287
 
278
- static MYSQL_SYSVAR_UINT(timestamp_always, g_timestamp_always, PLUGIN_VAR_READONLY, "", 0,
279
- 0, 1, 0, 1, 0);
280
-
281
288
  #endif
282
289
 
283
290
  /** system valiables struct.
@@ -295,6 +302,7 @@ static struct st_mysql_sys_var* g_systemVariables[] =
295
302
  MYSQL_SYSVAR(transaction_isolation),
296
303
  MYSQL_SYSVAR(auth_type),
297
304
  MYSQL_SYSVAR(timestamp_always),
305
+ MYSQL_SYSVAR(startup_ha),
298
306
  #ifdef PIPE_SERVER
299
307
  MYSQL_SYSVAR(pipe_comm_sharemem_size),
300
308
  MYSQL_SYSVAR(max_pipe_connections),
@@ -321,7 +329,8 @@ const char* get_trd_sys_var(int index)
321
329
  case TD_VAR_LOCKWAITTIMEOUT:return (const char*)&g_lock_wait_timeout;
322
330
  case TD_VAR_ISOLATION:return g_transaction_isolation;
323
331
  case TD_VAR_AUTHTYPE:return g_auth_type;
324
- case TD_VAR_TIMESTAMPMODE:return (const char*)&g_timestamp_always;
332
+ case TD_VAR_TIMESTAMPMODE:return (const char*)&g_timestamp_always;
333
+ case TD_VAR_STARTUP_HA:return (const char*)&g_startup_ha;
325
334
  #ifdef PIPE_SERVER
326
335
  case TD_VAR_PIPESHAREMEMSIZE:return (const char*)&g_pipeCommSharememSize;
327
336
  case TD_VAR_MAXPIPECONNECTIONS:return (const char*)&g_maxPipeConnections;
@@ -347,6 +356,7 @@ const unsigned int* get_trd_status_var(int index)
347
356
  case TD_SVAR_TCP_WAIT_THREADS:return &cpt::g_waitThread;
348
357
  case TD_SVAR_TPOOL_CONNECTIONS:return &tpool::g_connections;
349
358
  case TD_SVAR_TPOOL_WAIT_THREADS:return &tpool::server::m_threadPoolSize;
359
+ case TD_SVAR_HA:return &g_ha;
350
360
  #ifdef PIPE_SERVER
351
361
  case TD_SVAR_PIPE_CONNECTIONS:return &pipe::g_connections;
352
362
  case TD_SVAR_PIPE_WAIT_THREADS:return &pipe::g_waitThread;
@@ -359,16 +369,17 @@ const unsigned int* get_trd_status_var(int index)
359
369
  /** show status struct.
360
370
  */
361
371
  static st_mysql_show_var g_statusVariables[] = {
362
- { "trnsctd_tcp_connections", (char*)&cpt::g_connections, SHOW_INT },
363
- { "trnsctd_tcp_wait_threads", (char*)&cpt::g_waitThread, SHOW_INT },
364
- { "trnsctd_tpool_connections", (char*)&tpool::g_connections, SHOW_INT },
365
- { "trnsctd_tpool_threads", (char*)&tpool::server::m_threadPoolSize, SHOW_INT },
372
+ { "Transactd_tcp_connections", (char*)&cpt::g_connections, SHOW_INT STATUS_VAR_SCOPE },
373
+ { "Transactd_tcp_wait_threads", (char*)&cpt::g_waitThread, SHOW_INT },
374
+ { "Transactd_tpool_connections", (char*)&tpool::g_connections, SHOW_INT STATUS_VAR_SCOPE },
375
+ { "Transactd_tpool_threads", (char*)&tpool::server::m_threadPoolSize, SHOW_INT STATUS_VAR_SCOPE },
376
+ { "Transactd_ha", (char*)&g_ha, SHOW_INT STATUS_VAR_SCOPE },
366
377
 
367
378
  #ifdef PIPE_SERVER
368
- { "trnsctd_pipe_connections", (char*)&pipe::g_connections, SHOW_INT },
369
- { "trnsctd_pipe_wait_threads", (char*)&pipe::g_waitThread, SHOW_INT },
379
+ { "Transactd_pipe_connections", (char*)&pipe::g_connections, SHOW_INT STATUS_VAR_SCOPE },
380
+ { "Transactd_pipe_wait_threads", (char*)&pipe::g_waitThread, SHOW_INT STATUS_VAR_SCOPE },
370
381
  #endif
371
- { "trnsctd_cur_open_databases", (char*)&g_openDatabases, SHOW_INT },
382
+ { "Transactd_cur_open_databases", (char*)&g_openDatabases, SHOW_INT STATUS_VAR_SCOPE },
372
383
  { NULL, NULL, (enum_mysql_show_type)0 }
373
384
  };
374
385
 
@@ -58,6 +58,7 @@ int gettimeofday(struct timeval*, struct timezone*);
58
58
  #endif
59
59
 
60
60
  #define _strnicmp strncasecmp
61
+ #define _stricmp strcasecmp
61
62
  #define _atoi64 atoll
62
63
  #define _access access
63
64
  #define sprintf_s snprintf
@@ -217,6 +218,7 @@ typedef unsigned __int32 char32_t; // 32bit
217
218
  #if defined(__BORLANDC__)
218
219
  #define _strupr strupr
219
220
  #define _strnicmp strnicmp
221
+ #define _stricmp stricmp
220
222
  #endif
221
223
 
222
224
  #define wcsnicmp16(A, B, C) \
@@ -109,6 +109,8 @@ public:
109
109
  virtual bool isHandShakable() const = 0;
110
110
  virtual const boost::system::error_code& error() const = 0;
111
111
  virtual void* versions() = 0;
112
+ virtual unsigned int userOptions() const = 0;
113
+ virtual void setUserOptions(unsigned int v) = 0;
112
114
  };
113
115
 
114
116
  #define CONNECTION_FUNCTION_DIRECT_READ 1
@@ -52,8 +52,11 @@ int connections::netTimeout = 180;
52
52
  #define DEFAULT_CONNECT_TIMEOUT "20"
53
53
  #define DEFAULT_NET_TIMEOUT "180"
54
54
 
55
+ /* redefine tdapapi.h */
56
+ #define HST_OPTION_CLEAR_CACHE 8
55
57
 
56
- connections::connections(const char* pipeName) : m_pipeName(pipeName),m_resolver(m_ios)
58
+ connections::connections(const char* pipeName) : m_pipeName(pipeName),
59
+ m_resolver(m_ios), m_haNameResolver(NULL)
57
60
  {
58
61
 
59
62
  #ifdef _WIN32
@@ -159,16 +162,6 @@ asio::ip::tcp::endpoint connections::endpoint(const std::string& host,
159
162
  return endpoint;
160
163
  }
161
164
 
162
- connection* connections::getConnection(const std::string& host, const char* port)
163
- {
164
- mutex::scoped_lock lck(m_mutex);
165
- boost::system::error_code ec;
166
- tcp::endpoint ep = endpoint(host, port, ec);
167
- if (!ec)
168
- return getConnection(ep);
169
- return NULL;
170
- }
171
-
172
165
  #ifdef USE_PIPE_CLIENT
173
166
 
174
167
  connection* connections::getConnectionPipe(unsigned short port)
@@ -313,10 +306,25 @@ inline bool connections::doHandShake(connection* c, handshake f, void* data)
313
306
  #pragma warn -8004
314
307
  #endif
315
308
  // The connection of found from connection list of same address is returned.
316
- connection* connections::connect(const std::string& host, const char* port, handshake f, void* data, bool newConnection)
309
+ connection* connections::connect(const std::string& hst, const char* port,
310
+ handshake f, void* data, bool newConnection, bool clearNRCache)
317
311
  {
318
312
  bool namedPipe = false;
319
313
  connection* c;
314
+ std::string host = hst;
315
+ unsigned int opt = clearNRCache ? HST_OPTION_CLEAR_CACHE : 0;
316
+ char buf[MAX_PATH];
317
+ if (m_haNameResolver)
318
+ {
319
+ m_haNameResolver(hst.c_str(), port, buf, opt);
320
+ char* p = strchr(buf, ':');
321
+ if (p)
322
+ {
323
+ *p = 0x00;
324
+ port = p + 1;
325
+ }
326
+ host = buf;
327
+ }
320
328
  mutex::scoped_lock lck(m_mutex);
321
329
  asio::ip::tcp::endpoint ep = endpoint(host, port, m_e);
322
330
  if (m_e)
@@ -330,7 +338,8 @@ connection* connections::connect(const std::string& host, const char* port, hand
330
338
  c = newConnection ? NULL : getConnection(ep);
331
339
  if (newConnection || !c)
332
340
  {
333
- c = createConnection(ep, namedPipe);
341
+ c = createConnection(ep, namedPipe);
342
+ c->setUserOptions(opt);
334
343
  c = doConnect(c);
335
344
  if (!c || !doHandShake(c, f, data))
336
345
  return NULL;
@@ -343,14 +352,29 @@ connection* connections::connect(const std::string& host, const char* port, hand
343
352
  #pragma warn .8004
344
353
  #endif
345
354
 
346
- bool connections::reconnect(connection* c, const std::string& host, const char* port,
355
+ bool connections::reconnect(connection* c, const std::string& hst, const char* port,
347
356
  handshake f, void* data)
348
357
  {
349
358
  boost::system::error_code ec;
359
+ std::string host = hst;
360
+ unsigned int opt = HST_OPTION_CLEAR_CACHE;
361
+ char buf[MAX_PATH];
362
+ if (m_haNameResolver)
363
+ {
364
+ m_haNameResolver(hst.c_str(), port, buf, opt);
365
+ char* p = strchr(buf, ':');
366
+ if (p)
367
+ {
368
+ *p = 0x00;
369
+ port = p + 1;
370
+ }
371
+ host = buf;
372
+ }
350
373
  mutex::scoped_lock lck(m_mutex);
351
374
  asio::ip::tcp::endpoint ep = endpoint(host, port, ec);
352
375
  if (ec)
353
376
  return false;
377
+ c->setUserOptions(opt);
354
378
  c->reconnect(ep);
355
379
  if (!c || !doHandShake(c, f, data))
356
380
  return false;
@@ -362,6 +386,13 @@ int connections::connectionCount()
362
386
  return (int)m_conns.size();
363
387
  }
364
388
 
389
+ void connections::registHaNameResolver(HANAME_RESOLVER_PTR func)
390
+ {
391
+ mutex::scoped_lock lck(m_mutex);
392
+ m_haNameResolver = func;
393
+ }
394
+
395
+
365
396
  } // namespace client
366
397
  } // namespace netsvc
367
398
  } // namespace bzs
@@ -45,7 +45,7 @@
45
45
  #include <pthread.h>
46
46
  #include <signal.h>
47
47
  #endif
48
-
48
+ #include <bzs/env/compiler.h>
49
49
 
50
50
  using namespace boost;
51
51
  using namespace boost::system;
@@ -64,6 +64,16 @@ using namespace boost::system;
64
64
  extern bool win_thread_pool_shutdown;
65
65
  #endif
66
66
 
67
+ /* HA hostname resolver */
68
+ /* @cond INTERNAL */
69
+ #if (defined(__BORLANDC__) && !defined(__clang__))
70
+ typedef const char* __STDCALL (*HANAME_RESOLVER_PTR)(const char* vhost, const char* port, char* retBuf, unsigned int& opt);
71
+ #else
72
+ typedef const char* (__STDCALL* HANAME_RESOLVER_PTR)(const char* vhost, const char* port, char* retBuf, unsigned int& opt);
73
+ #endif
74
+ /* @endcond */
75
+
76
+
67
77
  namespace bzs
68
78
  {
69
79
  namespace netsvc
@@ -118,6 +128,7 @@ class connections
118
128
  boost::asio::ip::tcp::resolver m_resolver;
119
129
  mutex m_mutex;
120
130
  boost::system::error_code m_e;
131
+ HANAME_RESOLVER_PTR m_haNameResolver;
121
132
  static bool m_usePipedLocal;
122
133
 
123
134
  connection* getConnection(asio::ip::tcp::endpoint& ep);
@@ -135,14 +146,15 @@ public:
135
146
  connections(const char* pipeName);
136
147
  ~connections();
137
148
  connection* connect(const std::string& host, const char* port, handshake f,
138
- void* data, bool newConnection = false);
149
+ void* data, bool newConnection, bool clearNRCache);
139
150
  bool reconnect(connection* c, const std::string& host, const char* port,
140
151
  handshake f, void* data);
141
152
 
142
- connection* getConnection(const std::string& host, const char* port);
143
153
  bool disconnect(connection* c);
144
154
  int connectionCount();
145
155
  const boost::system::error_code& connectError() const { return m_e; };
156
+ void registHaNameResolver(HANAME_RESOLVER_PTR func);
157
+ HANAME_RESOLVER_PTR haNameResolver() const {return m_haNameResolver;}
146
158
  static char m_port[PORTNUMBUF_SIZE];
147
159
  static int connectTimeout;
148
160
  static int netTimeout;
@@ -151,6 +163,7 @@ public:
151
163
  /** Implementation of Part of the connection interface
152
164
  */
153
165
  #define VER_ST_SIZE 12
166
+
154
167
  class connectionBase : public connection
155
168
  {
156
169
  protected:
@@ -162,6 +175,7 @@ protected:
162
175
  size_t m_readLen;
163
176
  int m_refCount;
164
177
  int m_charsetServer;
178
+ unsigned int m_options;
165
179
  char m_vers[VER_ST_SIZE];
166
180
  bool m_connected;
167
181
  bool m_isHandShakable;
@@ -203,6 +217,9 @@ public:
203
217
  const boost::system::error_code& error() const { return m_e; };
204
218
 
205
219
  void* versions() {return (void*)m_vers;};
220
+ unsigned int userOptions() const {return m_options;}
221
+ void setUserOptions(unsigned int v) { m_options = v;}
222
+
206
223
  };
207
224
 
208
225
 
@@ -493,10 +510,10 @@ class tcpConnection : public connectionImple<asio::ip::tcp::socket>
493
510
 
494
511
  void on_connect(const boost::system::error_code& e)
495
512
  {
513
+ m_e = e;
496
514
  #ifdef USE_CONNECT_TIMER
497
515
  m_timer.cancel();
498
516
  #endif
499
- m_e = e;
500
517
  if (!checkError(e))
501
518
  return ;
502
519
  s_io.on_connected();
@@ -46,6 +46,7 @@ class iconnection;
46
46
  #define EXECUTE_RESULT_FORCSE_ASYNC 2
47
47
  #define EXECUTE_RESULT_FORCSE_SYNC 3
48
48
  #define EXECUTE_RESULT_ACCESS_DNIED 4
49
+ #define EXECUTE_RESULT_SEND_QUIT 5
49
50
  typedef std::vector<boost::asio::const_buffer> buffers;
50
51
  typedef std::vector<char> vector_buffer;
51
52
 
@@ -88,7 +88,7 @@ class connection : public iconnection, private boost::noncopyable
88
88
  int ret = m_module->execute(buf, size, &m_optionalBuffes);
89
89
  if (ret == EXECUTE_RESULT_QUIT)
90
90
  return;
91
- else if(ret == EXECUTE_RESULT_ACCESS_DNIED)
91
+ else if(ret == EXECUTE_RESULT_ACCESS_DNIED || ret == EXECUTE_RESULT_SEND_QUIT)
92
92
  {
93
93
  boost::asio::write(m_socket, buffer(&m_result[0], size),
94
94
  boost::asio::transfer_all());
@@ -355,6 +355,8 @@ class connection : public iconnection, private boost::noncopyable
355
355
 
356
356
  sentResult = m_comm->send();
357
357
  m_module->cleanup();
358
+ if(/*ret == EXECUTE_RESULT_ACCESS_DNIED || */ret == EXECUTE_RESULT_SEND_QUIT)
359
+ return;
358
360
  }
359
361
  }
360
362
  }