io-event 1.2.0 → 1.2.2
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
- checksums.yaml.gz.sig +0 -0
- data/ext/io/event/interrupt.h +2 -2
- data/ext/io/event/selector/epoll.c +37 -45
- data/lib/io/event/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fceb6b2998209f5520e3444be04fcb1846ca35f84a17133c0e28ae484c4e729d
|
4
|
+
data.tar.gz: cbaf0dce0a19528e7b12d0962f571b37f6b7c459ead50f355a6ca6e0502c8a4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dc61a581b53a198b40bdcfe8a46d1cf597e7748a700673ec4d2a5a26c05d0cc945e795e20e85c0d6f76e3d11cc18b9bc1e2b3b6265d0ac77f3ce01a339f0c51
|
7
|
+
data.tar.gz: acdf0b46bac22e77ecf2234e80c9f597ffdef01bd9a93799dfc599bd89f39e337b466f660ff60a11c1dd57d8f30527c7e4dc6c7f61de40dd01f00e5ae470ed87
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/ext/io/event/interrupt.h
CHANGED
@@ -27,7 +27,7 @@ struct IO_Event_Interrupt {
|
|
27
27
|
int descriptor;
|
28
28
|
};
|
29
29
|
|
30
|
-
inline int IO_Event_Interrupt_descriptor(struct IO_Event_Interrupt *interrupt) {
|
30
|
+
static inline int IO_Event_Interrupt_descriptor(struct IO_Event_Interrupt *interrupt) {
|
31
31
|
return interrupt->descriptor;
|
32
32
|
}
|
33
33
|
#else
|
@@ -35,7 +35,7 @@ struct IO_Event_Interrupt {
|
|
35
35
|
int descriptor[2];
|
36
36
|
};
|
37
37
|
|
38
|
-
inline int IO_Event_Interrupt_descriptor(struct IO_Event_Interrupt *interrupt) {
|
38
|
+
static inline int IO_Event_Interrupt_descriptor(struct IO_Event_Interrupt *interrupt) {
|
39
39
|
return interrupt->descriptor[0];
|
40
40
|
}
|
41
41
|
#endif
|
@@ -569,7 +569,6 @@ VALUE IO_Event_Selector_EPoll_io_write_compatible(int argc, VALUE *argv, VALUE s
|
|
569
569
|
|
570
570
|
#endif
|
571
571
|
|
572
|
-
#if defined(HAVE_EPOLL_PWAIT2)
|
573
572
|
static
|
574
573
|
struct timespec * make_timeout(VALUE duration, struct timespec * storage) {
|
575
574
|
if (duration == Qnil) {
|
@@ -600,31 +599,6 @@ static
|
|
600
599
|
int timeout_nonblocking(struct timespec * timespec) {
|
601
600
|
return timespec && timespec->tv_sec == 0 && timespec->tv_nsec == 0;
|
602
601
|
}
|
603
|
-
#else
|
604
|
-
static
|
605
|
-
int make_timeout(VALUE duration) {
|
606
|
-
if (duration == Qnil) {
|
607
|
-
return -1;
|
608
|
-
}
|
609
|
-
|
610
|
-
if (FIXNUM_P(duration)) {
|
611
|
-
return NUM2LONG(duration) * 1000L;
|
612
|
-
}
|
613
|
-
|
614
|
-
else if (RB_FLOAT_TYPE_P(duration)) {
|
615
|
-
double value = RFLOAT_VALUE(duration);
|
616
|
-
|
617
|
-
return value * 1000;
|
618
|
-
}
|
619
|
-
|
620
|
-
rb_raise(rb_eRuntimeError, "unable to convert timeout");
|
621
|
-
}
|
622
|
-
|
623
|
-
static
|
624
|
-
int timeout_nonblocking(int timeout) {
|
625
|
-
return timeout == 0;
|
626
|
-
}
|
627
|
-
#endif
|
628
602
|
|
629
603
|
struct select_arguments {
|
630
604
|
struct IO_Event_Selector_EPoll *data;
|
@@ -632,24 +606,52 @@ struct select_arguments {
|
|
632
606
|
int count;
|
633
607
|
struct epoll_event events[EPOLL_MAX_EVENTS];
|
634
608
|
|
635
|
-
#if defined(HAVE_EPOLL_PWAIT2)
|
636
609
|
struct timespec * timeout;
|
637
610
|
struct timespec storage;
|
638
|
-
#else
|
639
|
-
int timeout;
|
640
|
-
#endif
|
641
611
|
};
|
642
612
|
|
613
|
+
static int make_timeout_ms(struct timespec * timeout) {
|
614
|
+
if (timeout == NULL) {
|
615
|
+
return -1;
|
616
|
+
}
|
617
|
+
|
618
|
+
if (timeout_nonblocking(timeout)) {
|
619
|
+
return 0;
|
620
|
+
}
|
621
|
+
|
622
|
+
return (timeout->tv_sec * 1000) + (timeout->tv_nsec / 1000000);
|
623
|
+
}
|
624
|
+
|
625
|
+
static
|
626
|
+
int enosys_error(int result) {
|
627
|
+
if (result == -1) {
|
628
|
+
return errno == ENOSYS;
|
629
|
+
}
|
630
|
+
|
631
|
+
return 0;
|
632
|
+
}
|
633
|
+
|
643
634
|
static
|
644
635
|
void * select_internal(void *_arguments) {
|
645
636
|
struct select_arguments * arguments = (struct select_arguments *)_arguments;
|
646
637
|
|
647
638
|
#if defined(HAVE_EPOLL_PWAIT2)
|
648
639
|
arguments->count = epoll_pwait2(arguments->data->descriptor, arguments->events, EPOLL_MAX_EVENTS, arguments->timeout, NULL);
|
649
|
-
|
650
|
-
|
640
|
+
|
641
|
+
// Comment out the above line and enable the below lines to test ENOSYS code path.
|
642
|
+
// arguments->count = -1;
|
643
|
+
// errno = ENOSYS;
|
644
|
+
|
645
|
+
if (!enosys_error(arguments->count)) {
|
646
|
+
return NULL;
|
647
|
+
}
|
648
|
+
else {
|
649
|
+
// Fall through and execute epoll_wait fallback.
|
650
|
+
}
|
651
651
|
#endif
|
652
652
|
|
653
|
+
arguments->count = epoll_wait(arguments->data->descriptor, arguments->events, EPOLL_MAX_EVENTS, make_timeout_ms(arguments->timeout));
|
654
|
+
|
653
655
|
return NULL;
|
654
656
|
}
|
655
657
|
|
@@ -689,20 +691,14 @@ VALUE IO_Event_Selector_EPoll_select(VALUE self, VALUE duration) {
|
|
689
691
|
|
690
692
|
struct select_arguments arguments = {
|
691
693
|
.data = data,
|
692
|
-
#if defined(HAVE_EPOLL_PWAIT2)
|
693
694
|
.storage = {
|
694
695
|
.tv_sec = 0,
|
695
696
|
.tv_nsec = 0
|
696
|
-
}
|
697
|
-
#else
|
698
|
-
.timeout = 0
|
699
|
-
#endif
|
697
|
+
},
|
700
698
|
};
|
701
|
-
|
702
|
-
#if defined(HAVE_EPOLL_PWAIT2)
|
699
|
+
|
703
700
|
arguments.timeout = &arguments.storage;
|
704
|
-
|
705
|
-
|
701
|
+
|
706
702
|
// Process any currently pending events:
|
707
703
|
select_internal_with_gvl(&arguments);
|
708
704
|
|
@@ -712,11 +708,7 @@ VALUE IO_Event_Selector_EPoll_select(VALUE self, VALUE duration) {
|
|
712
708
|
// 3. There are no items in the ready list,
|
713
709
|
// then we can perform a blocking select.
|
714
710
|
if (!ready && !arguments.count && !data->backend.ready) {
|
715
|
-
#if defined(HAVE_EPOLL_PWAIT2)
|
716
711
|
arguments.timeout = make_timeout(duration, &arguments.storage);
|
717
|
-
#else
|
718
|
-
arguments.timeout = make_timeout(duration);
|
719
|
-
#endif
|
720
712
|
|
721
713
|
if (!timeout_nonblocking(arguments.timeout)) {
|
722
714
|
// Wait for events to occur
|
data/lib/io/event/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io-event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -41,7 +41,7 @@ cert_chain:
|
|
41
41
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
42
42
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
43
43
|
-----END CERTIFICATE-----
|
44
|
-
date: 2023-
|
44
|
+
date: 2023-05-14 00:00:00.000000000 Z
|
45
45
|
dependencies:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: bake
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
|
-
rubygems_version: 3.4.
|
153
|
+
rubygems_version: 3.4.7
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: An event loop.
|
metadata.gz.sig
CHANGED
Binary file
|