rage-iodine 3.0.7 → 3.1.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: af7a9d60835bf9e95bf426fd9adf7fd2375af632dd39bb35d57a83f2441d8318
4
- data.tar.gz: d13e31e81ca1a8764252d8dbf1fca4aed45bc291e661e5f5c322bdb8a0551089
3
+ metadata.gz: ef4ff042834d322d1a1eba37963ac373146345da2f167b75b421dbf6449f4060
4
+ data.tar.gz: 8ca3321bfd60e376ecb10017b118295f82d1ddf9897869f84aefad13909f3dfc
5
5
  SHA512:
6
- metadata.gz: 65287e0a103dacf4b4b52dbb493e2cd42ffe6b23b47e5a1b022c9b1b21601128517663ed9c7de61f4350587865c27d4af7a25d27ee170164c06040d0026cd8b7
7
- data.tar.gz: 75f0102920b0b8f090998f7bafe210ee0918b583ce35595e1a17e1b3c43577bbce9d531e0fd829dfad193c26c3a032db03c1b5d1bd298213ee6f244def4637a2
6
+ metadata.gz: e55be44f50f6a779d9d1457a61dcc9c005055a52c1560dde62fb84d73226b78084a431571af0d3fb24388100236fd39dac0c624a73fab624e0529a20286d0500
7
+ data.tar.gz: 74e9602b4822a05b2b25f87a0685ed8311afc79dd7e266b1e032906d18e15f0ba186870ea3617682c3939bdd2155e64759193504d8b83d4942ddabe3669c50bb
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ Please notice that this change log contains changes for upcoming releases as wel
6
6
 
7
7
  ## Changes:
8
8
 
9
+ #### Change log v.3.1.0 (2024-05-01)
10
+
11
+ **Update**: Implement graceful shutdown.
12
+
13
+ #### Change log v.3.0.8 (2024-04-12)
14
+
15
+ **Fix**: Correctly generate request tags in cluster mode.
16
+
9
17
  #### Change log v.3.0.7 (2024-04-10)
10
18
 
11
19
  **Fix**: Fix excessive CPU usage when using `run_every` on kqueue systems.
data/ext/iodine/fio.c CHANGED
@@ -386,6 +386,8 @@ typedef struct {
386
386
  uint32_t capa;
387
387
  /* connections counted towards shutdown (NOT while running) */
388
388
  uint32_t connection_count;
389
+ /* number of currently paused connections */
390
+ uint32_t async_connection_count;
389
391
  /* thread list */
390
392
  fio_ls_s thread_ids;
391
393
  /* active workers */
@@ -1294,6 +1296,18 @@ static void fio_defer_on_fork(void) {
1294
1296
  #endif
1295
1297
  }
1296
1298
 
1299
+ void fio_graceful_stop(void) {
1300
+ static uint8_t stop_requested;
1301
+
1302
+ if (!fio_data->async_connection_count) {
1303
+ fio_stop();
1304
+ } else if (!stop_requested) {
1305
+ stop_requested = 1;
1306
+ FIO_LOG_INFO("(%d) Waiting for up to 15 seconds to allow active requests to finish...", (int)getpid());
1307
+ fio_run_every(500, 30, (void (*)(void *))fio_graceful_stop, NULL, (void (*)(void *))fio_stop);
1308
+ }
1309
+ }
1310
+
1297
1311
  /* *****************************************************************************
1298
1312
  External Task API
1299
1313
  ***************************************************************************** */
@@ -1695,7 +1709,12 @@ static void sig_int_handler(int sig) {
1695
1709
  #else
1696
1710
  old = &fio_old_sig_term;
1697
1711
  #endif
1698
- fio_stop();
1712
+ if (fio_data->is_worker) {
1713
+ FIO_LOG_INFO("(%d) detected exit signal.", (int)getpid());
1714
+ } else {
1715
+ FIO_LOG_INFO("Server Detected exit signal.");
1716
+ }
1717
+ fio_graceful_stop();
1699
1718
  break;
1700
1719
  #ifndef __MINGW32__
1701
1720
  case SIGPIPE:
@@ -2788,6 +2807,16 @@ void fio_suspend(intptr_t uuid) {
2788
2807
  fio_trylock(&uuid_data(uuid).scheduled);
2789
2808
  }
2790
2809
 
2810
+ void fio_pause(intptr_t uuid) {
2811
+ fio_atomic_add(&fio_data->async_connection_count, 1);
2812
+ fio_suspend(uuid);
2813
+ }
2814
+
2815
+ void fio_resume(intptr_t uuid) {
2816
+ fio_atomic_sub(&fio_data->async_connection_count, 1);
2817
+ fio_force_event(uuid, FIO_EVENT_ON_DATA);
2818
+ }
2819
+
2791
2820
  /* *****************************************************************************
2792
2821
  Section Start Marker
2793
2822
 
@@ -4641,6 +4670,9 @@ static void fio_worker_startup(void) {
4641
4670
  fio_state_callback_clear(FIO_CALL_ON_START);
4642
4671
  }
4643
4672
 
4673
+ /* used in `gen_request_tag` */
4674
+ srand(time(0) + (getpid() << 8));
4675
+
4644
4676
  if (fio_data->workers == 1) {
4645
4677
  /* Single Process - the root is also a worker */
4646
4678
  fio_data->is_worker = 1;
@@ -4669,10 +4701,6 @@ static void fio_worker_startup(void) {
4669
4701
  /* performs all clean-up / shutdown requirements except for the exit sequence */
4670
4702
  static void fio_worker_cleanup(void) {
4671
4703
  /* switch to winding down */
4672
- if (fio_data->is_worker)
4673
- FIO_LOG_INFO("(%d) detected exit signal.", (int)getpid());
4674
- else
4675
- FIO_LOG_INFO("Server Detected exit signal.");
4676
4704
  fio_state_callback_force(FIO_CALL_ON_SHUTDOWN);
4677
4705
  for (size_t i = 0; i <= fio_data->max_protocol_fd; ++i) {
4678
4706
  if (fd_data(i).protocol) {
@@ -7208,7 +7236,7 @@ static void fio_cluster_client_handler(struct cluster_pr_s *pr) {
7208
7236
  fio_publish2process(fio_msg_internal_dup(pr->msg));
7209
7237
  break;
7210
7238
  case FIO_CLUSTER_MSG_SHUTDOWN:
7211
- fio_stop();
7239
+ fio_graceful_stop();
7212
7240
  case FIO_CLUSTER_MSG_ERROR: /* fallthrough */
7213
7241
  case FIO_CLUSTER_MSG_PING: /* fallthrough */
7214
7242
  case FIO_CLUSTER_MSG_ROOT: /* fallthrough */
data/ext/iodine/fio.h CHANGED
@@ -707,6 +707,18 @@ void fio_force_event(intptr_t uuid, enum fio_io_event);
707
707
  */
708
708
  void fio_suspend(intptr_t uuid);
709
709
 
710
+ /**
711
+ * Temporarily prevents `on_data` events from firing and increases the number
712
+ * of currently active connections.
713
+ */
714
+ void fio_pause(intptr_t uuid);
715
+
716
+ /**
717
+ * Schedules the `on_data` event and decreases the number of currently active
718
+ * connections.
719
+ */
720
+ void fio_resume(intptr_t uuid);
721
+
710
722
  /* *****************************************************************************
711
723
  Listening to Incoming Connections
712
724
  ***************************************************************************** */
data/ext/iodine/http1.c CHANGED
@@ -251,7 +251,7 @@ static int http1_push_file(http_s *h, FIOBJ filename, FIOBJ mime_type) {
251
251
  */
252
252
  static void http1_on_pause(http_s *h, http_fio_protocol_s *pr) {
253
253
  ((http1pr_s *)pr)->stop = 1;
254
- fio_suspend(pr->uuid);
254
+ fio_pause(pr->uuid);
255
255
  (void)h;
256
256
  }
257
257
 
@@ -260,7 +260,7 @@ static void http1_on_pause(http_s *h, http_fio_protocol_s *pr) {
260
260
  */
261
261
  static void http1_on_resume(http_s *h, http_fio_protocol_s *pr) {
262
262
  if (!((http1pr_s *)pr)->stop) {
263
- fio_force_event(pr->uuid, FIO_EVENT_ON_DATA);
263
+ fio_resume(pr->uuid);
264
264
  }
265
265
  (void)h;
266
266
  }
@@ -563,6 +563,4 @@ include non-patched methods as well.
563
563
  rb_define_singleton_method(tmp, "rfc2109", iodine_rfc2109, 1);
564
564
  rb_define_singleton_method(tmp, "rfc2822", iodine_rfc2822, 1);
565
565
  // rb_define_module_function(IodineUtils, "time2str", date_str, -1);
566
-
567
- srand(time(0));
568
566
  }
@@ -1,3 +1,3 @@
1
1
  module Iodine
2
- VERSION = '3.0.7'.freeze
2
+ VERSION = '3.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: 3.0.7
4
+ version: 3.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-04-10 00:00:00.000000000 Z
11
+ date: 2024-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake