ruby-oci8 2.2.4 → 2.2.4.1
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.
- data/ChangeLog +16 -1
- data/NEWS +15 -0
- data/docs/hanging-after-inactivity.md +14 -12
- data/ext/oci8/extconf.rb +1 -0
- data/ext/oci8/hook_funcs.c +19 -8
- data/ext/oci8/oci8lib.c +2 -2
- data/lib/oci8/properties.rb +2 -2
- data/lib/oci8/version.rb +1 -1
- metadata +3 -2
data/ChangeLog
CHANGED
@@ -1,6 +1,21 @@
|
|
1
|
+
2017-06-17 Kubo Takehiro <kubo@jiubao.org>
|
2
|
+
* NEWS: Add changes between 2.2.4 and 2.2.4.1
|
3
|
+
* lib/oci8/version.rb: Update to 2.2.4.1
|
4
|
+
* lib/oci8/version.rb: Fix URL links
|
5
|
+
* docs/hanging-after-inactivity.md: Revised
|
6
|
+
|
7
|
+
2017-06-16 Kubo Takehiro <kubo@jiubao.org>
|
8
|
+
* ext/oci8/extconf.rb, ext/oci8/hook_funcs.c, ext/oci8/oci8lib.c:
|
9
|
+
Fix to pass compilation on cygwin.
|
10
|
+
* mkpkg-win32.rb: Add tests on cygwin.
|
11
|
+
|
12
|
+
2017-06-16 Kubo Takehiro <kubo@jiubao.org>
|
13
|
+
* ext/oci8/hook_funcs.c: Fix the calling convention of setsockopt
|
14
|
+
on Windows x86.
|
15
|
+
|
1
16
|
2017-06-11 Kubo Takehiro <kubo@jiubao.org>
|
2
17
|
* NEWS: Add changes between 2.2.3 and 2.2.4.
|
3
|
-
* lib/oci8/version.rb: update to 2.2.
|
18
|
+
* lib/oci8/version.rb: update to 2.2.4.
|
4
19
|
* docs/ldap-auth-and-function-interposition.md,
|
5
20
|
docs/hanging-after-inactivity.md: updated
|
6
21
|
|
data/NEWS
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# @markup markdown
|
2
2
|
|
3
|
+
2.2.4.1
|
4
|
+
=======
|
5
|
+
|
6
|
+
Fixed issue
|
7
|
+
-----------
|
8
|
+
|
9
|
+
### Fix invalid function calls when TCP keepalive time parameter is set on Windows x86
|
10
|
+
|
11
|
+
When TCP keepalive time parameter is set, The win32 API `setsockopt` was hooked
|
12
|
+
with incorrect calling convention on Windows x86. As far as I checked it doesn't
|
13
|
+
cause bad effects. But it is by chance. If the code in `oci.dll` is optimized
|
14
|
+
differently, it may cause unexpected behavior.
|
15
|
+
|
16
|
+
### Fix compilation errors in 2.2.4 on cygwin
|
17
|
+
|
3
18
|
2.2.4
|
4
19
|
=====
|
5
20
|
|
@@ -6,13 +6,13 @@ Hanging After a Long Period of Inactivity
|
|
6
6
|
When a database connection hangs after a long period of inactivity,
|
7
7
|
this document may help you.
|
8
8
|
|
9
|
-
When a firewall resides between Oracle database server
|
10
|
-
|
9
|
+
When a firewall or a NAT proxy resides between Oracle database server
|
10
|
+
and client, it sometimes drops inactive connections as dead ones. If a
|
11
11
|
client connects to an Oracle server and tries to use the connection
|
12
|
-
after a long sleep (> 1 hour), the client may hang
|
12
|
+
after a long sleep (> 1 hour), the client may hang in an effort to use the
|
13
13
|
dropped connection. This issue will be solved by setting TCP keepalive
|
14
14
|
packets whose keepalive time parameter is smaller than the inactive
|
15
|
-
connection timeout
|
15
|
+
connection timeout.
|
16
16
|
|
17
17
|
TCP keepalive is enabled by [(ENABLE=broken)][] in a connect
|
18
18
|
descriptor. If you use easy connect naming such as `//hostname/service_name`,
|
@@ -28,28 +28,29 @@ This is equivalent to the following:
|
|
28
28
|
conn = OCI8.new(username, password, connect_descriptor)
|
29
29
|
|
30
30
|
The default TCP keepalive time is two hours, which may be larger
|
31
|
-
than the inactive connection timeout
|
31
|
+
than the inactive connection timeout. The default
|
32
32
|
value in the system is configurable via [procfs and sysctl on Linux][]
|
33
33
|
or [registry parameters on Windows][]. If you have no privilege to
|
34
|
-
customize the system, you can change
|
35
|
-
by the tcp_keepalive_time property.
|
34
|
+
customize the system, you can change per-connection keepalive time
|
35
|
+
by the `tcp_keepalive_time` property.
|
36
36
|
|
37
37
|
OCI8.properties[:tcp_keepalive_time] = 600 # 10 minutes
|
38
38
|
|
39
|
-
|
40
|
-
platforms since ruby-oci8 2.2.4.
|
39
|
+
It is supported on the following platforms since ruby-oci8 2.2.4.
|
41
40
|
|
42
41
|
* Linux i386 and x86_64
|
43
42
|
* macOS
|
44
43
|
* Windows x86 and x64
|
45
44
|
* Solaris x86_64
|
46
45
|
|
46
|
+
When it is set on unsupported platforms, you get `NotImplementedError`.
|
47
|
+
|
47
48
|
This feature is implemented with hackish way. When
|
48
49
|
`tcp_keepalive_time` is set, Oracle client library's
|
49
50
|
procedure linkage table is modified to intercept [setsockopt][] system
|
50
|
-
|
51
|
-
TCP keepalive, ruby-oci8 changes the TCP keepalive time
|
52
|
-
|
51
|
+
call. When Oracle client library issues the system call which enables
|
52
|
+
TCP keepalive, [ruby-oci8 changes][] the per-connection TCP keepalive time
|
53
|
+
immediately.
|
53
54
|
|
54
55
|
I hope that Oracle adds a new OCI handle attribute to support this
|
55
56
|
feature natively in the future.
|
@@ -59,3 +60,4 @@ feature natively in the future.
|
|
59
60
|
[registry parameters on Windows]: https://blogs.technet.microsoft.com/nettracer/2010/06/03/things-that-you-may-want-to-know-about-tcp-keepalives/
|
60
61
|
[plthook]: https://github.com/kubo/plthook
|
61
62
|
[setsockopt]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html
|
63
|
+
[ruby-oci8 changes]: https://github.com/kubo/ruby-oci8/blob/ruby-oci8-2.2.4/ext/oci8/hook_funcs.c#L302-L318
|
data/ext/oci8/extconf.rb
CHANGED
@@ -160,6 +160,7 @@ if xsystem(cc_command("").gsub(CONFTEST_C, File.dirname(__FILE__) + "/" + plthoo
|
|
160
160
|
$objs << "hook_funcs.o"
|
161
161
|
$defs << "-DHAVE_PLTHOOK"
|
162
162
|
have_library('dbghelp', 'ImageDirectoryEntryToData', ['windows.h', 'dbghelp.h']) if RUBY_PLATFORM =~ /cygwin/
|
163
|
+
$libs += ' -lws2_32' if RUBY_PLATFORM =~ /cygwin/
|
163
164
|
else
|
164
165
|
puts "no"
|
165
166
|
end
|
data/ext/oci8/hook_funcs.c
CHANGED
@@ -4,16 +4,26 @@
|
|
4
4
|
*
|
5
5
|
* Copyright (C) 2015 Kubo Takehiro <kubo@jiubao.org>
|
6
6
|
*/
|
7
|
+
#if defined(_WIN32) || defined(__CYGWIN__)
|
8
|
+
#define WINDOWS
|
9
|
+
#include <winsock2.h>
|
10
|
+
#endif
|
7
11
|
#include "oci8.h"
|
8
12
|
#include "plthook.h"
|
9
|
-
#
|
13
|
+
#ifdef __CYGWIN__
|
14
|
+
#undef boolean /* boolean defined in oratypes.h coflicts with that in windows.h */
|
15
|
+
#endif
|
16
|
+
#ifdef WINDOWS
|
17
|
+
#include <windows.h>
|
18
|
+
#include <mstcpip.h>
|
19
|
+
#else
|
10
20
|
#include <unistd.h>
|
11
21
|
#include <sys/socket.h>
|
12
22
|
#include <netinet/in.h>
|
13
23
|
#include <netinet/tcp.h>
|
14
24
|
#endif
|
15
25
|
|
16
|
-
#ifdef
|
26
|
+
#ifdef WINDOWS
|
17
27
|
static CRITICAL_SECTION lock;
|
18
28
|
#define LOCK(lock) EnterCriticalSection(lock)
|
19
29
|
#define UNLOCK(lock) LeaveCriticalSection(lock)
|
@@ -24,6 +34,7 @@ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
|
24
34
|
#define UNLOCK(lock) pthread_mutex_unlock(lock)
|
25
35
|
#define SOCKET int
|
26
36
|
#define INVALID_SOCKET (-1)
|
37
|
+
#define WSAAPI
|
27
38
|
#endif
|
28
39
|
|
29
40
|
#if defined(__APPLE__) && defined(TCP_KEEPALIVE) /* macOS */
|
@@ -35,7 +46,7 @@ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
|
35
46
|
#elif defined(TCP_KEEPIDLE) /* Linux, etc */
|
36
47
|
#define USE_TCP_KEEPIDLE
|
37
48
|
#define SUPPORT_TCP_KEEPALIVE_TIME
|
38
|
-
#elif defined(
|
49
|
+
#elif defined(WINDOWS)
|
39
50
|
#define SUPPORT_TCP_KEEPALIVE_TIME
|
40
51
|
#endif
|
41
52
|
|
@@ -43,7 +54,7 @@ int oci8_cancel_read_at_exit = 0;
|
|
43
54
|
|
44
55
|
#ifdef SUPPORT_TCP_KEEPALIVE_TIME
|
45
56
|
int oci8_tcp_keepalive_time = 0;
|
46
|
-
static int hook_setsockopt(SOCKET sockfd, int level, int optname, const void *optval, socklen_t optlen);
|
57
|
+
static int WSAAPI hook_setsockopt(SOCKET sockfd, int level, int optname, const void *optval, socklen_t optlen);
|
47
58
|
#else
|
48
59
|
int oci8_tcp_keepalive_time = -1;
|
49
60
|
#endif
|
@@ -115,7 +126,7 @@ static int replace_functions(const char * const *files, hook_func_entry_t *funct
|
|
115
126
|
return -1;
|
116
127
|
}
|
117
128
|
|
118
|
-
#ifdef
|
129
|
+
#ifdef WINDOWS
|
119
130
|
|
120
131
|
#ifndef _MSC_VER
|
121
132
|
/* setsockopt() in ws2_32.dll */
|
@@ -288,7 +299,7 @@ static void shutdown_socket(socket_entry_t *entry)
|
|
288
299
|
#endif
|
289
300
|
|
290
301
|
#ifdef SUPPORT_TCP_KEEPALIVE_TIME
|
291
|
-
static int hook_setsockopt(SOCKET sockfd, int level, int optname, const void *optval, socklen_t optlen)
|
302
|
+
static int WSAAPI hook_setsockopt(SOCKET sockfd, int level, int optname, const void *optval, socklen_t optlen)
|
292
303
|
{
|
293
304
|
int rv = setsockopt(sockfd, level, optname, optval, optlen);
|
294
305
|
|
@@ -306,7 +317,7 @@ static int hook_setsockopt(SOCKET sockfd, int level, int optname, const void *op
|
|
306
317
|
setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPALIVE_THRESHOLD, &millisec, sizeof(millisec));
|
307
318
|
#elif defined(USE_TCP_KEEPIDLE) /* Linux, etc */
|
308
319
|
setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE, &oci8_tcp_keepalive_time, sizeof(int));
|
309
|
-
#elif defined(
|
320
|
+
#elif defined(WINDOWS)
|
310
321
|
struct tcp_keepalive vals;
|
311
322
|
DWORD dummy;
|
312
323
|
|
@@ -326,7 +337,7 @@ void oci8_shutdown_sockets(void)
|
|
326
337
|
{
|
327
338
|
socket_entry_t *entry;
|
328
339
|
|
329
|
-
#ifdef
|
340
|
+
#ifdef WINDOWS
|
330
341
|
if (!locK_is_initialized) {
|
331
342
|
return;
|
332
343
|
}
|
data/ext/oci8/oci8lib.c
CHANGED
@@ -71,7 +71,7 @@ static VALUE bind_base_alloc(VALUE klass)
|
|
71
71
|
rb_raise(rb_eNameError, "private method `new' called for %s:Class", rb_class2name(klass));
|
72
72
|
}
|
73
73
|
|
74
|
-
#if defined(HAVE_PLTHOOK) && !defined(WIN32)
|
74
|
+
#if defined(HAVE_PLTHOOK) && !defined(WIN32) && !defined(__CYGWIN__)
|
75
75
|
static const char *find_libclntsh(void *handle)
|
76
76
|
{
|
77
77
|
void *symaddr = dlsym(handle, "OCIEnvCreate");
|
@@ -226,7 +226,7 @@ Init_oci8lib()
|
|
226
226
|
oracle_client_version = ORAVERNUM(major, minor, update, patch, port_update);
|
227
227
|
}
|
228
228
|
#endif
|
229
|
-
#if defined(HAVE_PLTHOOK) && !defined(WIN32)
|
229
|
+
#if defined(HAVE_PLTHOOK) && !defined(WIN32) && !defined(__CYGWIN__)
|
230
230
|
rebind_internal_symbols();
|
231
231
|
#endif
|
232
232
|
|
data/lib/oci8/properties.rb
CHANGED
@@ -177,13 +177,13 @@ class OCI8
|
|
177
177
|
#
|
178
178
|
# [:tcp_keepalive]
|
179
179
|
#
|
180
|
-
# See {file:docs/hanging-after-inactivity.md
|
180
|
+
# See {file:docs/hanging-after-inactivity.md}
|
181
181
|
#
|
182
182
|
# *Since:* 2.2.4
|
183
183
|
#
|
184
184
|
# [:tcp_keepalive_time]
|
185
185
|
#
|
186
|
-
# See {file:docs/hanging-after-inactivity.md
|
186
|
+
# See {file:docs/hanging-after-inactivity.md}
|
187
187
|
#
|
188
188
|
# *Since:* 2.2.4
|
189
189
|
#
|
data/lib/oci8/version.rb
CHANGED
metadata
CHANGED
@@ -6,7 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 2
|
7
7
|
- 2
|
8
8
|
- 4
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 2.2.4.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Kubo Takehiro
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2017-06-
|
18
|
+
date: 2017-06-17 00:00:00 +09:00
|
18
19
|
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|