trilogy 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0730bbbdae7e8eab195c4ad745e223bcd55fe6299f98cb324c88beea15ebdc5e
4
- data.tar.gz: 7779f268cbfae85bf5575f680ebff9fee6d22b78bb5d3d315ba664969ab9618a
3
+ metadata.gz: a56e3472569e26552e3c8d7a674b70d9f5e15a546187f75e806f4d56ff5f15b2
4
+ data.tar.gz: a2c29dc1fcf378be7a26088661401d9d4e7d4253c6823f8e7e84414662947cb1
5
5
  SHA512:
6
- metadata.gz: 42c81e496210cfc0538ef1dd9f4f7c34e2ce94de45e5bcfe4c5815839c463a6b3ae78af529b88c63a670b3cd2035a6b931ef76fdfe1ec508f6b7851858b664d2
7
- data.tar.gz: ad05962a8a47cea68ab66188badf405fe96342587bd86d91faf43dd028dc641949ea58d9a6d25547e820c4700c6cd9548d70a2494f0a215b08bb8a61c9c920c8
6
+ metadata.gz: 0f3348ccdf12ae3cef0c34f95e09829528a0bdb09b466774a1a8369fdeae6f4d1fb59df96b1d17e5361aea4656968b5e2149ffbf9fe8337b17d45f0903408122
7
+ data.tar.gz: 33711de128dd47aeff4ab618d0c3b6032e966b1b52b7dad6352e1588f5d13e54df2d4709c97c006ec63d1fa603a1f190abd58784cea835d26be6c1f56da5b46c
@@ -18,7 +18,7 @@
18
18
  VALUE Trilogy_CastError;
19
19
  static VALUE Trilogy_BaseConnectionError, Trilogy_ProtocolError, Trilogy_SSLError, Trilogy_QueryError,
20
20
  Trilogy_ConnectionClosedError, Trilogy_ConnectionRefusedError, Trilogy_ConnectionResetError,
21
- Trilogy_TimeoutError, Trilogy_SyscallError, Trilogy_Result;
21
+ Trilogy_TimeoutError, Trilogy_SyscallError, Trilogy_Result, Trilogy_EOFError;
22
22
 
23
23
  static ID id_socket, id_host, id_port, id_username, id_password, id_found_rows, id_connect_timeout, id_read_timeout,
24
24
  id_write_timeout, id_keepalive_enabled, id_keepalive_idle, id_keepalive_interval, id_keepalive_count,
@@ -96,7 +96,7 @@ static void trilogy_syserr_fail_str(int e, VALUE msg)
96
96
  rb_raise(Trilogy_ConnectionResetError, "%" PRIsVALUE, msg);
97
97
  } else if (e == EPIPE) {
98
98
  // Backwards compatibility: This error class makes no sense, but matches legacy behavior
99
- rb_raise(Trilogy_QueryError, "%" PRIsVALUE ": TRILOGY_CLOSED_CONNECTION", msg);
99
+ rb_raise(Trilogy_EOFError, "%" PRIsVALUE ": TRILOGY_CLOSED_CONNECTION: EPIPE", msg);
100
100
  } else {
101
101
  VALUE exc = rb_funcall(Trilogy_SyscallError, id_from_errno, 2, INT2NUM(e), msg);
102
102
  rb_exc_raise(exc);
@@ -158,6 +158,10 @@ static void handle_trilogy_error(struct trilogy_ctx *ctx, int rc, const char *ms
158
158
  rb_raise(Trilogy_BaseConnectionError, "%" PRIsVALUE ": TRILOGY_DNS_ERROR", rbmsg);
159
159
  }
160
160
 
161
+ case TRILOGY_CLOSED_CONNECTION: {
162
+ rb_raise(Trilogy_EOFError, "%" PRIsVALUE ": TRILOGY_CLOSED_CONNECTION", rbmsg);
163
+ }
164
+
161
165
  default:
162
166
  rb_raise(Trilogy_QueryError, "%" PRIsVALUE ": %s", rbmsg, trilogy_error(rc));
163
167
  }
@@ -1176,6 +1180,9 @@ RUBY_FUNC_EXPORTED void Init_cext()
1176
1180
  Trilogy_CastError = rb_const_get(Trilogy, rb_intern("CastError"));
1177
1181
  rb_global_variable(&Trilogy_CastError);
1178
1182
 
1183
+ Trilogy_EOFError = rb_const_get(Trilogy, rb_intern("EOFError"));
1184
+ rb_global_variable(&Trilogy_EOFError);
1185
+
1179
1186
  id_socket = rb_intern("socket");
1180
1187
  id_host = rb_intern("host");
1181
1188
  id_port = rb_intern("port");
@@ -195,6 +195,14 @@ static int raw_connect_internal(struct trilogy_sock *sock, const struct addrinfo
195
195
  return TRILOGY_SYSERR;
196
196
  }
197
197
 
198
+ #ifdef TCP_NODELAY
199
+ if (sock->addr->ai_family != PF_UNIX) {
200
+ int flags = 1;
201
+ if (setsockopt(sock->fd, IPPROTO_TCP, TCP_NODELAY, (void *)&flags, sizeof(flags)) < 0) {
202
+ goto fail;
203
+ }
204
+ }
205
+ #endif
198
206
  if (sock->base.opts.keepalive_enabled) {
199
207
  int flags = 1;
200
208
  if (setsockopt(sock->fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&flags, sizeof(flags)) < 0) {
data/lib/trilogy/error.rb CHANGED
@@ -20,7 +20,7 @@ class Trilogy
20
20
  .select { |c| c.is_a?(Class) && c < SystemCallError }
21
21
  .each do |c|
22
22
  errno_name = c.to_s.split('::').last
23
- ERRORS[c::Errno] = const_set(errno_name, Class.new(c) { include Trilogy::Error })
23
+ ERRORS[c::Errno] = const_set(errno_name, Class.new(c) { include Trilogy::ConnectionError })
24
24
  end
25
25
 
26
26
  ERRORS.freeze
@@ -112,7 +112,13 @@ class Trilogy
112
112
  include ConnectionError
113
113
  end
114
114
 
115
+ # Raised on attempt to use connection which was explicitly closed by the user
115
116
  class ConnectionClosed < IOError
116
117
  include ConnectionError
117
118
  end
119
+
120
+ # Occurrs when a socket read or write returns EOF or when an operation is
121
+ # attempted on a socket which previously encountered an error.
122
+ class EOFError < BaseConnectionError
123
+ end
118
124
  end
@@ -1,3 +1,3 @@
1
1
  class Trilogy
2
- VERSION = "2.5.0"
2
+ VERSION = "2.6.0"
3
3
  end
data/lib/trilogy.rb CHANGED
@@ -8,7 +8,7 @@ require "trilogy/encoding"
8
8
 
9
9
  class Trilogy
10
10
  def initialize(options = {})
11
- options[:port] = options[:port].to_i if options.key?(:port)
11
+ options[:port] = options[:port].to_i if options[:port]
12
12
  mysql_encoding = options[:encoding] || "utf8mb4"
13
13
  encoding = Trilogy::Encoding.find(mysql_encoding)
14
14
  charset = Trilogy::Encoding.charset(mysql_encoding)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trilogy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-16 00:00:00.000000000 Z
11
+ date: 2023-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  requirements: []
105
- rubygems_version: 3.4.7
105
+ rubygems_version: 3.4.10
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: A friendly MySQL-compatible library for Ruby, binding to libtrilogy