puma 5.3.2-java → 5.5.2-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

data/docs/signals.md CHANGED
@@ -1,8 +1,8 @@
1
- The [unix signal](https://en.wikipedia.org/wiki/Unix_signal) is a method of sending messages between [processes](https://en.wikipedia.org/wiki/Process_(computing)). When a signal is sent, the operating system interrupts the target process's normal flow of execution. There are standard signals that are used to stop a process but there are also custom signals that can be used for other purposes. This document is an attempt to list all supported signals that Puma will respond to. In general, signals need only be sent to the master process of a cluster.
1
+ The [unix signal](https://en.wikipedia.org/wiki/Unix_signal) is a method of sending messages between [processes](https://en.wikipedia.org/wiki/Process_(computing)). When a signal is sent, the operating system interrupts the target process's normal flow of execution. There are standard signals that are used to stop a process, but there are also custom signals that can be used for other purposes. This document is an attempt to list all supported signals that Puma will respond to. In general, signals need only be sent to the master process of a cluster.
2
2
 
3
3
  ## Sending Signals
4
4
 
5
- If you are new to signals it can be useful to see how they can be used. When a process is created in a *nix like operating system it will have a [PID - or process identifier](https://en.wikipedia.org/wiki/Process_identifier) that can be used to send signals to the process. For demonstration we will create an infinitely running process by tailing a file:
5
+ If you are new to signals, it can be helpful to see how they are used. When a process starts in a *nix-like operating system, it will have a [PID - or process identifier](https://en.wikipedia.org/wiki/Process_identifier) that can be used to send signals to the process. For demonstration, we will create an infinitely running process by tailing a file:
6
6
 
7
7
  ```sh
8
8
  $ echo "foo" >> my.log
@@ -10,7 +10,7 @@ $ irb
10
10
  > pid = Process.spawn 'tail -f my.log'
11
11
  ```
12
12
 
13
- From here we can see that the tail process is running by using the `ps` command:
13
+ From here, we can see that the tail process is running by using the `ps` command:
14
14
 
15
15
  ```sh
16
16
  $ ps aux | grep tail
@@ -27,7 +27,7 @@ Process.detach(pid) # https://ruby-doc.org/core-2.1.1/Process.html#method-c-deta
27
27
  Process.kill("TERM", pid)
28
28
  ```
29
29
 
30
- Now you will see via `ps` that there is no more `tail` process. Sometimes when referring to signals the `SIG` prefix will be used for instance `SIGTERM` is equivalent to sending `TERM` via `Process.kill`.
30
+ Now you will see via `ps` that there is no more `tail` process. Sometimes when referring to signals, the `SIG` prefix will be used. For example, `SIGTERM` is equivalent to sending `TERM` via `Process.kill`.
31
31
 
32
32
  ## Puma Signals
33
33
 
@@ -35,13 +35,13 @@ Puma cluster responds to these signals:
35
35
 
36
36
  - `TTIN` increment the worker count by 1
37
37
  - `TTOU` decrement the worker count by 1
38
- - `TERM` send `TERM` to worker. Worker will attempt to finish then exit.
39
- - `USR2` restart workers. This also reloads puma configuration file, if there is one.
40
- - `USR1` restart workers in phases, a rolling restart. This will not reload configuration file.
41
- - `HUP ` reopen log files defined in stdout_redirect configuration parameter. If there is no stdout_redirect option provided it will behave like `INT`
42
- - `INT ` equivalent of sending Ctrl-C to cluster. Will attempt to finish then exit.
38
+ - `TERM` send `TERM` to worker. The worker will attempt to finish then exit.
39
+ - `USR2` restart workers. This also reloads the Puma configuration file, if there is one.
40
+ - `USR1` restart workers in phases, a rolling restart. This will not reload the configuration file.
41
+ - `HUP ` reopen log files defined in stdout_redirect configuration parameter. If there is no stdout_redirect option provided, it will behave like `INT`
42
+ - `INT ` equivalent of sending Ctrl-C to cluster. Puma will attempt to finish then exit.
43
43
  - `CHLD`
44
- - `URG ` refork workers in phases from worker 0, if `fork_workers` option is enabled.
44
+ - `URG ` refork workers in phases from worker 0 if `fork_workers` option is enabled.
45
45
 
46
46
  ## Callbacks order in case of different signals
47
47
 
data/docs/stats.md CHANGED
@@ -1,4 +1,4 @@
1
- ## accessing stats
1
+ ## Accessing stats
2
2
 
3
3
  Stats can be accessed in two ways:
4
4
 
@@ -47,18 +47,18 @@ end
47
47
 
48
48
  ## Explanation of stats
49
49
 
50
- `Puma.stats` returns different information and a different structure depending on if Puma is in single vs cluster mode. There is one top-level attribute that is common to both modes:
50
+ `Puma.stats` returns different information and a different structure depending on if Puma is in single vs. cluster mode. There is one top-level attribute that is common to both modes:
51
51
 
52
- * started_at: when puma was started
52
+ * started_at: when Puma was started
53
53
 
54
54
  ### single mode and individual workers in cluster mode
55
55
 
56
- When Puma is run in single mode, these stats are available at the top level. When Puma is run in cluster mode, these stats are available within the `worker_status` array in a hash labeled `last_status`, in an array of hashes, one hash for each worker.
56
+ When Puma runs in single mode, these stats are available at the top level. When Puma runs in cluster mode, these stats are available within the `worker_status` array in a hash labeled `last_status`, in an array of hashes where one hash represents each worker.
57
57
 
58
58
  * backlog: requests that are waiting for an available thread to be available. if this is above 0, you need more capacity [always true?]
59
59
  * running: how many threads are running
60
- * pool_capacity: the number of requests that the server is capable of taking right now. For example if the number is 5 then it means there are 5 threads sitting idle ready to take a request. If one request comes in, then the value would be 4 until it finishes processing. If the minimum threads allowed is zero, this number will still have a maximum value of the maximum threads allowed.
61
- * max_threads: the maximum number of threads puma is configured to spool up per worker
60
+ * pool_capacity: the number of requests that the server is capable of taking right now. For example, if the number is 5, then it means there are 5 threads sitting idle ready to take a request. If one request comes in, then the value would be 4 until it finishes processing. If the minimum threads allowed is zero, this number will still have a maximum value of the maximum threads allowed.
61
+ * max_threads: the maximum number of threads Puma is configured to spool per worker
62
62
  * requests_count: the number of requests this worker has served since starting
63
63
 
64
64
 
@@ -72,9 +72,9 @@ When Puma is run in single mode, these stats are available at the top level. Whe
72
72
 
73
73
  ### worker status
74
74
 
75
- * started_at: when the worker was started
75
+ * started_at: when the worker started
76
76
  * pid: the process id of the worker process
77
- * index: each worker gets a number. if puma is configured to have 3 workers, then this will be 0, 1, or 2
77
+ * index: each worker gets a number. if Puma is configured to have 3 workers, then this will be 0, 1, or 2
78
78
  * booted: if it's done booting [?]
79
79
  * last_checkin: Last time the worker responded to the master process' heartbeat check.
80
80
  * last_status: a hash of info about the worker's state handling requests. See the explanation for this in "single mode and individual workers in cluster mode" section above.
data/docs/systemd.md CHANGED
@@ -1,19 +1,18 @@
1
1
  # systemd
2
2
 
3
- [systemd](https://www.freedesktop.org/wiki/Software/systemd/) is a
4
- commonly available init system (PID 1) on many Linux distributions. It
5
- offers process monitoring (including automatic restarts) and other
6
- useful features for running Puma in production.
3
+ [systemd](https://www.freedesktop.org/wiki/Software/systemd/) is a commonly
4
+ available init system (PID 1) on many Linux distributions. It offers process
5
+ monitoring (including automatic restarts) and other useful features for running
6
+ Puma in production.
7
7
 
8
8
  ## Service Configuration
9
9
 
10
- Below is a sample puma.service configuration file for systemd, which
11
- can be copied or symlinked to `/etc/systemd/system/puma.service`, or if
12
- desired, using an application or instance specific name.
10
+ Below is a sample puma.service configuration file for systemd, which can be
11
+ copied or symlinked to `/etc/systemd/system/puma.service`, or if desired, using
12
+ an application or instance-specific name.
13
13
 
14
- Note that this uses the systemd preferred "simple" type where the
15
- start command remains running in the foreground (does not fork and
16
- exit).
14
+ Note that this uses the systemd preferred "simple" type where the start command
15
+ remains running in the foreground (does not fork and exit).
17
16
 
18
17
  ~~~~ ini
19
18
  [Unit]
@@ -37,8 +36,8 @@ WatchdogSec=10
37
36
  # Preferably configure a non-privileged user
38
37
  # User=
39
38
 
40
- # The path to the your application code root directory.
41
- # Also replace the "<YOUR_APP_PATH>" place holders below with this path.
39
+ # The path to your application code root directory.
40
+ # Also replace the "<YOUR_APP_PATH>" placeholders below with this path.
42
41
  # Example /home/username/myapp
43
42
  WorkingDirectory=<YOUR_APP_PATH>
44
43
 
@@ -64,33 +63,31 @@ Restart=always
64
63
  WantedBy=multi-user.target
65
64
  ~~~~
66
65
 
67
- See [systemd.exec](https://www.freedesktop.org/software/systemd/man/systemd.exec.html)
66
+ See
67
+ [systemd.exec](https://www.freedesktop.org/software/systemd/man/systemd.exec.html)
68
68
  for additional details.
69
69
 
70
70
  ## Socket Activation
71
71
 
72
- systemd and puma also support socket activation, where systemd opens
73
- the listening socket(s) in advance and provides them to the puma
74
- master process on startup. Among other advantages, this keeps
75
- listening sockets open across puma restarts and achieves graceful
76
- restarts, including when upgraded puma, and is compatible with both
77
- clustered mode and application preload.
78
-
79
- **Note:** Any wrapper scripts which `exec`, or other indirections in
80
- `ExecStart`, may result in activated socket file descriptors being closed
81
- before they reach the puma master process. For example, if using `bundle exec`,
82
- pass the `--keep-file-descriptors` flag. `bundle exec` can be avoided by using a
83
- `puma` executable generated by `bundle binstubs puma`. This is tracked in
84
- [#1499].
85
-
86
- **Note:** Socket activation doesn't currently work on JRuby. This is
87
- tracked in [#1367].
88
-
89
- To use socket activation, configure one or more `ListenStream` sockets
90
- in a companion `*.socket` unit file. Also uncomment the associated
91
- `Requires` directive for the socket unit in the service file (see
92
- above.) Here is a sample puma.socket, matching the ports used in the
93
- above puma.service:
72
+ systemd and Puma also support socket activation, where systemd opens the
73
+ listening socket(s) in advance and provides them to the Puma master process on
74
+ startup. Among other advantages, this keeps listening sockets open across puma
75
+ restarts and achieves graceful restarts, including when upgraded Puma, and is
76
+ compatible with both clustered mode and application preload.
77
+
78
+ **Note:** Any wrapper scripts which `exec`, or other indirections in `ExecStart`
79
+ may result in activated socket file descriptors being closed before reaching the
80
+ puma master process. For example, if using `bundle exec`, pass the
81
+ `--keep-file-descriptors` flag. `bundle exec` can be avoided by using a `puma`
82
+ executable generated by `bundle binstubs puma`. This is tracked in [#1499].
83
+
84
+ **Note:** Socket activation doesn't currently work on JRuby. This is tracked in
85
+ [#1367].
86
+
87
+ Configure one or more `ListenStream` sockets in a companion `*.socket` unit file
88
+ to use socket activation. Also, uncomment the associated `Requires` directive
89
+ for the socket unit in the service file (see above.) Here is a sample
90
+ puma.socket, matching the ports used in the above puma.service:
94
91
 
95
92
  ~~~~ ini
96
93
  [Unit]
@@ -113,31 +110,32 @@ Backlog=1024
113
110
  WantedBy=sockets.target
114
111
  ~~~~
115
112
 
116
- See [systemd.socket](https://www.freedesktop.org/software/systemd/man/systemd.socket.html)
113
+ See
114
+ [systemd.socket](https://www.freedesktop.org/software/systemd/man/systemd.socket.html)
117
115
  for additional configuration details.
118
116
 
119
- Note that the above configurations will work with Puma in either
120
- single process or cluster mode.
117
+ Note that the above configurations will work with Puma in either single process
118
+ or cluster mode.
121
119
 
122
120
  ### Sockets and symlinks
123
121
 
124
- When using releases folders, you should set the socket path using the
125
- shared folder path (ex. `/srv/projet/shared/tmp/puma.sock`), not the
126
- release folder path (`/srv/projet/releases/1234/tmp/puma.sock`).
122
+ When using releases folders, you should set the socket path using the shared
123
+ folder path (ex. `/srv/projet/shared/tmp/puma.sock`), not the release folder
124
+ path (`/srv/projet/releases/1234/tmp/puma.sock`).
127
125
 
128
126
  Puma will detect the release path socket as different than the one provided by
129
- systemd and attempt to bind it again, resulting in the exception
130
- `There is already a server bound to:`.
127
+ systemd and attempt to bind it again, resulting in the exception `There is
128
+ already a server bound to:`.
131
129
 
132
130
  ### Binding
133
131
 
134
- By default you need to configure puma to have binds matching with all
132
+ By default, you need to configure Puma to have binds matching with all
135
133
  ListenStream statements. Any mismatched systemd ListenStreams will be closed by
136
- puma.
134
+ Puma.
137
135
 
138
136
  To automatically bind to all activated sockets, the option
139
137
  `--bind-to-activated-sockets` can be used. This matches the config DSL
140
- `bind_to_activated_sockets` statement. This will cause puma to create a bind
138
+ `bind_to_activated_sockets` statement. This will cause Puma to create a bind
141
139
  automatically for any activated socket. When systemd socket activation is not
142
140
  enabled, this option does nothing.
143
141
 
@@ -146,8 +144,8 @@ binds that's not socket activated.
146
144
 
147
145
  ## Usage
148
146
 
149
- Without socket activation, use `systemctl` as root (e.g. via `sudo`) as
150
- with other system services:
147
+ Without socket activation, use `systemctl` as root (i.e., via `sudo`) as with
148
+ other system services:
151
149
 
152
150
  ~~~~ sh
153
151
  # After installing or making changes to puma.service
@@ -156,35 +154,35 @@ systemctl daemon-reload
156
154
  # Enable so it starts on boot
157
155
  systemctl enable puma.service
158
156
 
159
- # Initial start up.
157
+ # Initial startup.
160
158
  systemctl start puma.service
161
159
 
162
160
  # Check status
163
161
  systemctl status puma.service
164
162
 
165
- # A normal restart. Warning: listeners sockets will be closed
163
+ # A normal restart. Warning: listener's sockets will be closed
166
164
  # while a new puma process initializes.
167
165
  systemctl restart puma.service
168
166
  ~~~~
169
167
 
170
- With socket activation, several but not all of these commands should
171
- be run for both socket and service:
168
+ With socket activation, several but not all of these commands should be run for
169
+ both socket and service:
172
170
 
173
171
  ~~~~ sh
174
172
  # After installing or making changes to either puma.socket or
175
173
  # puma.service.
176
174
  systemctl daemon-reload
177
175
 
178
- # Enable both socket and service so they start on boot. Alternatively
179
- # you could leave puma.service disabled and systemd will start it on
180
- # first use (with startup lag on first request)
176
+ # Enable both socket and service, so they start on boot. Alternatively
177
+ # you could leave puma.service disabled, and systemd will start it on
178
+ # the first use (with startup lag on the first request)
181
179
  systemctl enable puma.socket puma.service
182
180
 
183
- # Initial start up. The Requires directive (see above) ensures the
181
+ # Initial startup. The Requires directive (see above) ensures the
184
182
  # socket is started before the service.
185
183
  systemctl start puma.socket puma.service
186
184
 
187
- # Check status of both socket and service.
185
+ # Check the status of both socket and service.
188
186
  systemctl status puma.socket puma.service
189
187
 
190
188
  # A "hot" restart, with systemd keeping puma.socket listening and
@@ -197,8 +195,8 @@ systemctl restart puma.service
197
195
  systemctl restart puma.socket puma.service
198
196
  ~~~~
199
197
 
200
- Here is sample output from `systemctl status` with both service and
201
- socket running:
198
+ Here is sample output from `systemctl status` with both service and socket
199
+ running:
202
200
 
203
201
  ~~~~
204
202
  ● puma.socket - Puma HTTP Server Accept Sockets
@@ -231,14 +229,12 @@ Apr 07 08:40:19 hx puma[28320]: Use Ctrl-C to stop
231
229
 
232
230
  ### capistrano3-puma
233
231
 
234
- By default,
235
- [capistrano3-puma](https://github.com/seuros/capistrano-puma) uses
236
- `pumactl` for deployment restarts, outside of systemd. To learn the
237
- exact commands that this tool would use for `ExecStart` and
238
- `ExecStop`, use the following `cap` commands in dry-run mode, and
239
- update from the above forking service configuration accordingly. Note
240
- also that the configured `User` should likely be the same as the
241
- capistrano3-puma `:puma_user` option.
232
+ By default, [capistrano3-puma](https://github.com/seuros/capistrano-puma) uses
233
+ `pumactl` for deployment restarts outside of systemd. To learn the exact
234
+ commands that this tool would use for `ExecStart` and `ExecStop`, use the
235
+ following `cap` commands in dry-run mode, and update from the above forking
236
+ service configuration accordingly. Note also that the configured `User` should
237
+ likely be the same as the capistrano3-puma `:puma_user` option.
242
238
 
243
239
  ~~~~ sh
244
240
  stage=production # or different stage, as needed
@@ -248,3 +244,4 @@ cap $stage puma:stop --dry-run
248
244
 
249
245
  [Restart]: https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart=
250
246
  [#1367]: https://github.com/puma/puma/issues/1367
247
+ [#1499]: https://github.com/puma/puma/issues/1499
@@ -11,9 +11,18 @@ end
11
11
  unless ENV["DISABLE_SSL"]
12
12
  dir_config("openssl")
13
13
 
14
- if %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} and
14
+ found_ssl = if pkg_config 'openssl'
15
+ puts 'using OpenSSL pkgconfig (openssl.pc)'
16
+ true
17
+ elsif %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} &&
15
18
  %w'ssl ssleay32'.find {|ssl| have_library(ssl, 'SSL_CTX_new')}
19
+ true
20
+ else
21
+ puts '** Puma will be compiled without SSL support'
22
+ false
23
+ end
16
24
 
25
+ if found_ssl
17
26
  have_header "openssl/bio.h"
18
27
 
19
28
  # below is yes for 1.0.2 & later
@@ -25,6 +34,14 @@ unless ENV["DISABLE_SSL"]
25
34
 
26
35
  have_func "X509_STORE_up_ref"
27
36
  have_func("SSL_CTX_set_ecdh_auto(NULL, 0)", "openssl/ssl.h")
37
+
38
+ # Random.bytes available in Ruby 2.5 and later, Random::DEFAULT deprecated in 3.0
39
+ if Random.respond_to?(:bytes)
40
+ $defs.push("-DHAVE_RANDOM_BYTES")
41
+ puts "checking for Random.bytes... yes"
42
+ else
43
+ puts "checking for Random.bytes... no"
44
+ end
28
45
  end
29
46
  end
30
47
 
@@ -428,7 +428,13 @@ case 18:
428
428
  switch( (*p) ) {
429
429
  case 13: goto tr26;
430
430
  case 32: goto tr27;
431
+ case 127: goto st0;
431
432
  }
433
+ if ( (*p) > 8 ) {
434
+ if ( 10 <= (*p) && (*p) <= 31 )
435
+ goto st0;
436
+ } else if ( (*p) >= 0 )
437
+ goto st0;
432
438
  goto tr25;
433
439
  tr25:
434
440
  #line 46 "ext/puma_http11/http11_parser.rl"
@@ -438,9 +444,16 @@ st19:
438
444
  if ( ++p == pe )
439
445
  goto _test_eof19;
440
446
  case 19:
441
- #line 442 "ext/puma_http11/http11_parser.c"
442
- if ( (*p) == 13 )
443
- goto tr29;
447
+ #line 448 "ext/puma_http11/http11_parser.c"
448
+ switch( (*p) ) {
449
+ case 13: goto tr29;
450
+ case 127: goto st0;
451
+ }
452
+ if ( (*p) > 8 ) {
453
+ if ( 10 <= (*p) && (*p) <= 31 )
454
+ goto st0;
455
+ } else if ( (*p) >= 0 )
456
+ goto st0;
444
457
  goto st19;
445
458
  tr9:
446
459
  #line 53 "ext/puma_http11/http11_parser.rl"
@@ -484,7 +497,7 @@ st20:
484
497
  if ( ++p == pe )
485
498
  goto _test_eof20;
486
499
  case 20:
487
- #line 488 "ext/puma_http11/http11_parser.c"
500
+ #line 501 "ext/puma_http11/http11_parser.c"
488
501
  switch( (*p) ) {
489
502
  case 32: goto tr31;
490
503
  case 60: goto st0;
@@ -505,7 +518,7 @@ st21:
505
518
  if ( ++p == pe )
506
519
  goto _test_eof21;
507
520
  case 21:
508
- #line 509 "ext/puma_http11/http11_parser.c"
521
+ #line 522 "ext/puma_http11/http11_parser.c"
509
522
  switch( (*p) ) {
510
523
  case 32: goto tr33;
511
524
  case 60: goto st0;
@@ -526,7 +539,7 @@ st22:
526
539
  if ( ++p == pe )
527
540
  goto _test_eof22;
528
541
  case 22:
529
- #line 530 "ext/puma_http11/http11_parser.c"
542
+ #line 543 "ext/puma_http11/http11_parser.c"
530
543
  switch( (*p) ) {
531
544
  case 43: goto st22;
532
545
  case 58: goto st23;
@@ -551,7 +564,7 @@ st23:
551
564
  if ( ++p == pe )
552
565
  goto _test_eof23;
553
566
  case 23:
554
- #line 555 "ext/puma_http11/http11_parser.c"
567
+ #line 568 "ext/puma_http11/http11_parser.c"
555
568
  switch( (*p) ) {
556
569
  case 32: goto tr8;
557
570
  case 34: goto st0;
@@ -571,7 +584,7 @@ st24:
571
584
  if ( ++p == pe )
572
585
  goto _test_eof24;
573
586
  case 24:
574
- #line 575 "ext/puma_http11/http11_parser.c"
587
+ #line 588 "ext/puma_http11/http11_parser.c"
575
588
  switch( (*p) ) {
576
589
  case 32: goto tr37;
577
590
  case 34: goto st0;
@@ -594,7 +607,7 @@ st25:
594
607
  if ( ++p == pe )
595
608
  goto _test_eof25;
596
609
  case 25:
597
- #line 598 "ext/puma_http11/http11_parser.c"
610
+ #line 611 "ext/puma_http11/http11_parser.c"
598
611
  switch( (*p) ) {
599
612
  case 32: goto tr41;
600
613
  case 34: goto st0;
@@ -614,7 +627,7 @@ st26:
614
627
  if ( ++p == pe )
615
628
  goto _test_eof26;
616
629
  case 26:
617
- #line 618 "ext/puma_http11/http11_parser.c"
630
+ #line 631 "ext/puma_http11/http11_parser.c"
618
631
  switch( (*p) ) {
619
632
  case 32: goto tr44;
620
633
  case 34: goto st0;
@@ -43,7 +43,7 @@
43
43
 
44
44
  field_name = ( token -- ":" )+ >start_field $snake_upcase_field %write_field;
45
45
 
46
- field_value = any* >start_value %write_value;
46
+ field_value = ( (any -- CTL) | "\t" )* >start_value %write_value;
47
47
 
48
48
  message_header = field_name ":" " "* field_value :> CRLF;
49
49
 
@@ -208,7 +208,7 @@ sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
208
208
  #endif
209
209
  int ssl_options;
210
210
  VALUE key, cert, ca, verify_mode, ssl_cipher_filter, no_tlsv1, no_tlsv1_1,
211
- verification_flags;
211
+ verification_flags, session_id_bytes;
212
212
  DH *dh;
213
213
 
214
214
  #if OPENSSL_VERSION_NUMBER < 0x10002000L
@@ -309,6 +309,21 @@ sslctx_initialize(VALUE self, VALUE mini_ssl_ctx) {
309
309
  } else {
310
310
  SSL_CTX_set_verify(ctx, NUM2INT(verify_mode), engine_verify_callback);
311
311
  }
312
+
313
+ // Random.bytes available in Ruby 2.5 and later, Random::DEFAULT deprecated in 3.0
314
+ session_id_bytes = rb_funcall(
315
+ #ifdef HAVE_RANDOM_BYTES
316
+ rb_cRandom,
317
+ #else
318
+ rb_const_get(rb_cRandom, rb_intern_const("DEFAULT")),
319
+ #endif
320
+ rb_intern_const("bytes"),
321
+ 1, ULL2NUM(SSL_MAX_SSL_SESSION_ID_LENGTH));
322
+
323
+ SSL_CTX_set_session_id_context(ctx,
324
+ (unsigned char *) RSTRING_PTR(session_id_bytes),
325
+ SSL_MAX_SSL_SESSION_ID_LENGTH);
326
+
312
327
  // printf("\ninitialize end security_level %d\n", SSL_CTX_get_security_level(ctx));
313
328
  rb_obj_freeze(self);
314
329
  return self;