trilogy 2.13.2 → 2.13.3
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.
- checksums.yaml +4 -4
- data/ext/trilogy-ruby/cext.c +46 -20
- data/lib/trilogy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 18d367219cde913a99e5fcda45192907cce6577f5308d682b42b48f1d046bbb2
|
|
4
|
+
data.tar.gz: 2ddfd049d0061f446f18d378e0f297b757bf63f01015eb302541d6482ed388c4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ce0b26f62e79f480b89d902002b0cff30d85b2f7fcaddf1313c9d0127da87e200e719aeb9716641b343fe0fc6af2ee901f704d40e90f335352de147a63eb0920
|
|
7
|
+
data.tar.gz: 8c0b3ca40a1cc51ae4233086b2ed995a439a119114a01043877993a8a6268a4415d0e64338136f9c5f9ed42aa22b6dc497faf22a11ce894d50314500a3d2ced4
|
data/ext/trilogy-ruby/cext.c
CHANGED
|
@@ -233,18 +233,22 @@ static struct trilogy_ctx *get_open_ctx(VALUE obj)
|
|
|
233
233
|
return ctx;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
|
|
237
|
-
static void trilogy_syserr_fail_str(int e, VALUE msg)
|
|
236
|
+
static VALUE trilogy_new_syserr_fail(int e, VALUE msg)
|
|
238
237
|
{
|
|
239
238
|
if (e == EPIPE) {
|
|
240
239
|
// Backwards compatibility: This error message is a bit odd, but includes "TRILOGY_CLOSED_CONNECTION" to match legacy string matching
|
|
241
|
-
|
|
240
|
+
return rb_exc_new_str(Trilogy_EOFError, rb_sprintf("%" PRIsVALUE ": TRILOGY_CLOSED_CONNECTION: EPIPE", msg));
|
|
242
241
|
} else {
|
|
243
|
-
|
|
244
|
-
rb_exc_raise(exc);
|
|
242
|
+
return rb_funcall(Trilogy_SyscallError, id_from_errno, 2, INT2NUM(e), msg);
|
|
245
243
|
}
|
|
246
244
|
}
|
|
247
245
|
|
|
246
|
+
NORETURN(static void trilogy_syserr_fail_str(int, VALUE));
|
|
247
|
+
static void trilogy_syserr_fail_str(int e, VALUE msg)
|
|
248
|
+
{
|
|
249
|
+
rb_exc_raise(trilogy_new_syserr_fail(e, msg));
|
|
250
|
+
}
|
|
251
|
+
|
|
248
252
|
static int trilogy_error_recoverable_p(int rc)
|
|
249
253
|
{
|
|
250
254
|
// TRILOGY_OPENSSL_ERR and TRILOGY_SYSERR (which can result from an SSL error) must shut down the socket, as further
|
|
@@ -263,8 +267,7 @@ static void handle_trilogy_error(struct trilogy_ctx *ctx, int rc, const char *ms
|
|
|
263
267
|
va_start(args, msg);
|
|
264
268
|
VALUE rbmsg = rb_vsprintf(msg, args);
|
|
265
269
|
va_end(args);
|
|
266
|
-
|
|
267
|
-
rb_trilogy_release_buffer(ctx);
|
|
270
|
+
VALUE exc;
|
|
268
271
|
|
|
269
272
|
if (!trilogy_error_recoverable_p(rc)) {
|
|
270
273
|
if (ctx->conn.socket != NULL) {
|
|
@@ -275,18 +278,23 @@ static void handle_trilogy_error(struct trilogy_ctx *ctx, int rc, const char *ms
|
|
|
275
278
|
}
|
|
276
279
|
}
|
|
277
280
|
|
|
281
|
+
|
|
278
282
|
switch (rc) {
|
|
279
|
-
case TRILOGY_SYSERR:
|
|
280
|
-
|
|
283
|
+
case TRILOGY_SYSERR: {
|
|
284
|
+
exc = trilogy_new_syserr_fail(errno, rbmsg);
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
281
287
|
|
|
282
|
-
case TRILOGY_TIMEOUT:
|
|
283
|
-
|
|
288
|
+
case TRILOGY_TIMEOUT: {
|
|
289
|
+
exc = rb_exc_new_str(Trilogy_TimeoutError, rbmsg);
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
284
292
|
|
|
285
293
|
case TRILOGY_ERR: {
|
|
286
294
|
VALUE conn_message = rb_str_new(ctx->conn.error_message, ctx->conn.error_message_len);
|
|
287
295
|
VALUE message = rb_sprintf("%" PRIsVALUE " (%" PRIsVALUE ")", conn_message, rbmsg);
|
|
288
|
-
|
|
289
|
-
|
|
296
|
+
exc = rb_funcall(Trilogy_ProtocolError, id_from_code, 2, message, INT2NUM(ctx->conn.error_code));
|
|
297
|
+
break;
|
|
290
298
|
}
|
|
291
299
|
|
|
292
300
|
case TRILOGY_OPENSSL_ERR: {
|
|
@@ -294,30 +302,48 @@ static void handle_trilogy_error(struct trilogy_ctx *ctx, int rc, const char *ms
|
|
|
294
302
|
ERR_clear_error();
|
|
295
303
|
if (ERR_GET_LIB(ossl_error) == ERR_LIB_SYS) {
|
|
296
304
|
int err_reason = ERR_GET_REASON(ossl_error);
|
|
297
|
-
|
|
305
|
+
exc = trilogy_new_syserr_fail(err_reason, rbmsg);
|
|
298
306
|
}
|
|
299
|
-
|
|
307
|
+
else {
|
|
308
|
+
rbmsg = rb_sprintf("%" PRIsVALUE ": SSL Error: %s", rbmsg, ERR_reason_error_string(ossl_error));
|
|
309
|
+
exc = rb_exc_new_str(Trilogy_SSLError, rbmsg);
|
|
310
|
+
}
|
|
311
|
+
break;
|
|
300
312
|
}
|
|
301
313
|
|
|
302
314
|
case TRILOGY_DNS_ERR: {
|
|
303
|
-
|
|
315
|
+
rbmsg = rb_sprintf("%" PRIsVALUE ": TRILOGY_DNS_ERROR", rbmsg);
|
|
316
|
+
exc = rb_exc_new_str(Trilogy_BaseConnectionError, rbmsg);
|
|
317
|
+
break;
|
|
304
318
|
}
|
|
305
319
|
|
|
306
320
|
case TRILOGY_CLOSED_CONNECTION: {
|
|
307
|
-
|
|
321
|
+
rbmsg = rb_sprintf("%" PRIsVALUE ": TRILOGY_CLOSED_CONNECTION", rbmsg);
|
|
322
|
+
exc = rb_exc_new_str(Trilogy_EOFError, rbmsg);
|
|
323
|
+
break;
|
|
308
324
|
}
|
|
309
325
|
|
|
310
326
|
case TRILOGY_AUTH_PLUGIN_ERROR: {
|
|
311
|
-
|
|
327
|
+
rbmsg = rb_sprintf("%" PRIsVALUE ": TRILOGY_AUTH_PLUGIN_ERROR", rbmsg);
|
|
328
|
+
exc = rb_exc_new_str(Trilogy_AuthPluginError, rbmsg);
|
|
329
|
+
break;
|
|
312
330
|
}
|
|
313
331
|
|
|
314
332
|
case TRILOGY_UNSUPPORTED: {
|
|
315
|
-
|
|
333
|
+
rbmsg = rb_sprintf("%" PRIsVALUE ": TRILOGY_UNSUPPORTED", rbmsg);
|
|
334
|
+
exc = rb_exc_new_str(Trilogy_BaseConnectionError, rbmsg);
|
|
335
|
+
break;
|
|
316
336
|
}
|
|
317
337
|
|
|
318
338
|
default:
|
|
319
|
-
|
|
339
|
+
rbmsg = rb_sprintf("%" PRIsVALUE ": %s", rbmsg, trilogy_error(rc));
|
|
340
|
+
exc = rb_exc_new_str(Trilogy_QueryError, rbmsg);
|
|
341
|
+
break;
|
|
320
342
|
}
|
|
343
|
+
|
|
344
|
+
// Some error messages depend on the buffer.
|
|
345
|
+
rb_trilogy_release_buffer(ctx);
|
|
346
|
+
rb_exc_raise(exc);
|
|
321
347
|
}
|
|
322
348
|
|
|
323
349
|
static VALUE allocate_trilogy(VALUE klass)
|
data/lib/trilogy/version.rb
CHANGED