rage-iodine 4.0.0 → 4.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26936e113c659cee25877d312515e6fe50ca5ed56ff5e8195e6f5274292f2145
4
- data.tar.gz: 40b7aa9c791a5bc08513e5e0c478c02274a39c81d9be0fab7736f8478157ffab
3
+ metadata.gz: 4262f702902096226a678e94c8b73acf61798fb5441c8cfbb04a831cbea7a738
4
+ data.tar.gz: fdede223e570118defae54723fe52744cc01548e1c0c71d303dfc4760448d76a
5
5
  SHA512:
6
- metadata.gz: 1a789b92abed8d78b010ace73cb41d1688ff50c4fc6b590b6705a717196c212721039e252461ba8834a8f0bcd43679fc9c611a9f4d4690a826f3ac212bb3b9e5
7
- data.tar.gz: 446a4ecf05a3b371266ea71a92cb514d9a510d2c0fb6dc72e212ff26253e60c343bfc1675a68e6f3c9985c267b9940e61492706f4e61d89e6cb73dbba6c05a2c
6
+ metadata.gz: 2cf0070ab89370aa02970d80d920ac5b498172e5dfc2ef78b460a1d2d131886ef033a16f96107b3510f4b1652622e133942dcd16d438adead001962bcba54111
7
+ data.tar.gz: 85a2937799e604dbd0079668b5432bd785b3550d7e3e5dd94bae41f0b0c7b58ed68c036aad6cbcb79dadaddfb6534a31c0f0b34e34bfb5773c8dbfab84a0656d
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ Please notice that this change log contains changes for upcoming releases as wel
6
6
 
7
7
  ## Changes:
8
8
 
9
+ #### Change log v.4.1.0 (2025-02-07)
10
+
11
+ **Update**: Correctly handle `0` timeouts.
12
+
9
13
  #### Change log v.4.0.0 (2024-09-11)
10
14
 
11
15
  **Update**: Stop disconnecting from the DB on fork.
@@ -17,6 +17,7 @@ static uint8_t ATTACH_ON_READ_READY_CALLBACK;
17
17
  static uint8_t ATTACH_ON_WRITE_READY_CALLBACK;
18
18
  static VALUE e_timeout_args[1];
19
19
  static VALUE e_closed_args[1];
20
+ static VALUE e_not_ready_args[1];
20
21
 
21
22
  /* *****************************************************************************
22
23
  Fiber Scheduler API
@@ -58,6 +59,25 @@ static void iodine_scheduler_task_perform(intptr_t uuid, fio_protocol_s *fio_pro
58
59
  (void)uuid;
59
60
  }
60
61
 
62
+ static void iodine_scheduler_task_not_ready(void *uuid, void *fio_protocol) {
63
+ scheduler_protocol_s *protocol = (scheduler_protocol_s *)fio_protocol;
64
+
65
+ if (!protocol->fulfilled) {
66
+ IodineCaller.call2(protocol->block, call_id, 1, e_not_ready_args);
67
+ protocol->fulfilled = 1;
68
+ }
69
+
70
+ (void)uuid;
71
+ }
72
+
73
+ static void iodine_scheduler_task_deferred_not_ready(intptr_t uuid, fio_protocol_s *fio_protocol) {
74
+ // if there's a read event, `fio_defer` will give it time to fulfill the protocol first;
75
+ // otherwise, the fiber will be resumed with `false` indicating the IO is not ready
76
+ fio_defer(iodine_scheduler_task_not_ready, (void *)uuid, (void *)fio_protocol);
77
+
78
+ (void)uuid;
79
+ }
80
+
61
81
  static void iodine_scheduler_task_timeout(intptr_t uuid, fio_protocol_s *fio_protocol) {
62
82
  scheduler_protocol_s *protocol = (scheduler_protocol_s *)fio_protocol;
63
83
 
@@ -74,8 +94,11 @@ static VALUE iodine_scheduler_attach(VALUE self, VALUE r_fd, VALUE r_waittype, V
74
94
  Check_Type(r_waittype, T_FIXNUM);
75
95
  size_t waittype = FIX2UINT(r_waittype);
76
96
 
77
- Check_Type(r_timeout, T_FIXNUM);
78
- size_t timeout = FIX2UINT(r_timeout);
97
+ size_t timeout;
98
+ if (r_timeout != Qnil) {
99
+ Check_Type(r_timeout, T_FIXNUM);
100
+ timeout = FIX2UINT(r_timeout);
101
+ }
79
102
 
80
103
  fio_set_non_block(fd);
81
104
 
@@ -112,8 +135,14 @@ static VALUE iodine_scheduler_attach(VALUE self, VALUE r_fd, VALUE r_waittype, V
112
135
  }
113
136
 
114
137
  intptr_t uuid = fio_fd2uuid(fd);
115
- if (timeout) {
138
+
139
+ if (r_timeout == Qnil) {
140
+ fio_timeout_set(uuid, 0);
141
+ } else if (timeout) {
116
142
  fio_timeout_set(uuid, timeout);
143
+ } else {
144
+ // timeout was explicitly set to 0 - return right away
145
+ protocol->p.on_ready = iodine_scheduler_task_deferred_not_ready;
117
146
  }
118
147
 
119
148
  fio_watch(uuid, (fio_protocol_s *)protocol);
@@ -185,6 +214,7 @@ void iodine_scheduler_initialize(void) {
185
214
  call_id = rb_intern2("call", 4);
186
215
  e_timeout_args[0] = INT2NUM(-ETIMEDOUT);
187
216
  e_closed_args[0] = INT2NUM(-EIO);
217
+ e_not_ready_args[0] = Qfalse;
188
218
 
189
219
  VALUE SchedulerModule = rb_define_module_under(IodineModule, "Scheduler");
190
220
 
@@ -1,3 +1,3 @@
1
1
  module Iodine
2
- VERSION = '4.0.0'.freeze
2
+ VERSION = '4.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rage-iodine
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-11 00:00:00.000000000 Z
11
+ date: 2025-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake