Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:michals
ruby2.6
0006-io-add-select_with_poll-class-method-when-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0006-io-add-select_with_poll-class-method-when-USE_POLL.patch of Package ruby2.6
From ebc8b0c2b4e5caf324adab08f128e2b82f0d7f9d Mon Sep 17 00:00:00 2001 From: Michal Suchanek <msuchanek@suse.de> Date: Mon, 3 Feb 2020 19:36:15 +0100 Subject: [PATCH 06/12] io: add select_with_poll class method when USE_POLL This can be used to retrieve the fd error state. --- io.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/io.c b/io.c index 2bb1afe5032a..36c43af8ded1 100644 --- a/io.c +++ b/io.c @@ -9528,32 +9528,51 @@ rb_io_advise(int argc, VALUE *argv, VALUE io) * (snipped) * ping */ +static VALUE +do_rb_f_select(struct select_args * argp, VALUE timeout); +#if USE_POLL +static VALUE +rb_f_select_with_poll(int argc, VALUE *argv, VALUE obj) +{ + VALUE timeout; + struct select_args args; + rb_scan_args(argc, argv, "14", &args.read, &args.write, &args.except, &args.error, &timeout); + return do_rb_f_select(&args, timeout); +} +#endif static VALUE rb_f_select(int argc, VALUE *argv, VALUE obj) { VALUE timeout, rv; struct select_args args; - struct timeval timerec; - int i; rb_scan_args(argc, argv, "13", &args.read, &args.write, &args.except, &timeout); args.error = Qnil; + rv = do_rb_f_select(&args, timeout); + if (RB_TYPE_P(rv, T_ARRAY)) + rb_ary_pop(rv); + return rv; +} + +static VALUE +do_rb_f_select(struct select_args * args, VALUE timeout) +{ + struct timeval timerec; + int i; + if (NIL_P(timeout)) { - args.timeout = 0; + args->timeout = 0; } else { timerec = rb_time_interval(timeout); - args.timeout = &timerec; + args->timeout = &timerec; } - for (i = 0; i < numberof(args.fdsets); ++i) - rb_fd_init(&args.fdsets[i]); + for (i = 0; i < numberof(args->fdsets); ++i) + rb_fd_init(&args->fdsets[i]); - rv = rb_ensure(select_call, (VALUE)&args, select_end, (VALUE)&args); - if (RB_TYPE_P(rv, T_ARRAY)) - rb_ary_pop(rv); - return rv; + return rb_ensure(select_call, (VALUE)args, select_end, (VALUE)args); } #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) @@ -13147,6 +13166,9 @@ Init_IO(void) rb_define_singleton_method(rb_cIO, "write", rb_io_s_write, -1); rb_define_singleton_method(rb_cIO, "binwrite", rb_io_s_binwrite, -1); rb_define_singleton_method(rb_cIO, "select", rb_f_select, -1); +#if USE_POLL + rb_define_singleton_method(rb_cIO, "select_with_poll", rb_f_select_with_poll, -1); +#endif rb_define_singleton_method(rb_cIO, "pipe", rb_io_s_pipe, -1); rb_define_singleton_method(rb_cIO, "try_convert", rb_io_s_try_convert, 1); rb_define_singleton_method(rb_cIO, "copy_stream", rb_io_s_copy_stream, -1); -- 2.23.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor