Top Level Namespace

Defined Under Namespace

Modules: Iodine

Constant Summary collapse

OPENSSL_TEST_CODE =
"\\#include <openssl/bio.h>\n\\#include <openssl/err.h>\n\\#include <openssl/ssl.h>\n\\#if OPENSSL_VERSION_NUMBER < 0x10100000L\n\\#error \"OpenSSL version too small\"\n\\#endif\nint main(void) {\n  SSL_library_init();\n  SSL_CTX *ctx = SSL_CTX_new(TLS_method());\n  SSL *ssl = SSL_new(ctx);\n  BIO *bio = BIO_new_socket(3, 0);\n  BIO_up_ref(bio);\n  SSL_set0_rbio(ssl, bio);\n  SSL_set0_wbio(ssl, bio);\n}\n"

Instance Method Summary collapse

Instance Method Details

#after_fork(*args, &block) ⇒ Object

Deprecated.

Performs a block of code whenever a new worker process spins up (performed once per worker).



215
216
217
218
# File 'lib/iodine.rb', line 215

def after_fork(*args, &block)
  warn "after_fork is deprecated, use Iodine.on_state(:after_fork)."
  Iodine.on_state(:after_fork, &block)
end

#after_fork_in_master(*args, &block) ⇒ Object

Deprecated.

Performs a block of code whenever a new worker process spins up (performed once per worker).



233
234
235
236
# File 'lib/iodine.rb', line 233

def after_fork_in_master(*args, &block)
  warn "after_fork_in_master is deprecated, use Iodine.on_state(:enter_master)."
  Iodine.on_state(:enter_master, &block)
end

#after_fork_in_worker(*args, &block) ⇒ Object

Deprecated.

Performs a block of code whenever a new worker process spins up (performed once per worker).



224
225
226
227
# File 'lib/iodine.rb', line 224

def after_fork_in_worker(*args, &block)
  warn "after_fork_in_worker is deprecated, use Iodine.on_state(:enter_child)."
  Iodine.on_state(:enter_child, &block)
end

#before_fork(*args, &block) ⇒ Object

Deprecated.

Performs a block of code just before a new worker process spins up (performed once per worker, in the master thread).



260
261
262
263
# File 'lib/iodine.rb', line 260

def before_fork(*args, &block)
  warn "before_fork is deprecated, use Iodine.on_state(:before_fork)."
  Iodine.on_state(:before_fork, &block)
end

#iodine_test_polling_supportObject

Test polling



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'ext/iodine/extconf.rb', line 4

def iodine_test_polling_support
  iodine_poll_test_kqueue = "\\#define _GNU_SOURCE\n\\#include <stdlib.h>\n\\#include <sys/event.h>\nint main(void) {\n  int fd = kqueue();\n}\n"

  iodine_poll_test_epoll = "\\#define _GNU_SOURCE\n\\#include <stdlib.h>\n\\#include <stdio.h>\n\\#include <sys/types.h>\n\\#include <sys/stat.h>\n\\#include <fcntl.h>\n\\#include <sys/epoll.h>\nint main(void) {\n  int fd = epoll_create1(EPOLL_CLOEXEC);\n}\n"

  iodine_poll_test_poll = "\\#define _GNU_SOURCE\n\\#include <stdlib.h>\n\\#include <poll.h>\nint main(void) {\n  struct pollfd plist[18];\n  memset(plist, 0, sizeof(plist[0]) * 18);\n  poll(plist, 1, 1);\n}\n"

  # Test for manual selection and then TRY_COMPILE with each polling engine
  if Gem.win_platform?
    puts "skipping polling tests, using WSAPOLL on Windows"
    $defs << "-DFIO_ENGINE_WSAPOLL"
  elsif ENV['FIO_POLL']
    puts "skipping polling tests, enforcing manual selection of: poll"
    $defs << "-DFIO_ENGINE_POLL"
  elsif ENV['FIO_FORCE_POLL']
    puts "skipping polling tests, enforcing manual selection of: poll"
    $defs << "-DFIO_ENGINE_POLL"
  elsif ENV['FIO_FORCE_EPOLL']
    puts "skipping polling tests, enforcing manual selection of: epoll"
    $defs << "-DFIO_ENGINE_EPOLL"
  elsif ENV['FIO_FORCE_KQUEUE']
    puts "* Skipping polling tests, enforcing manual selection of: kqueue"
    $defs << "-DFIO_ENGINE_KQUEUE"
  elsif try_compile(iodine_poll_test_epoll)
    puts "detected `epoll`"
    $defs << "-DFIO_ENGINE_EPOLL"
  elsif try_compile(iodine_poll_test_kqueue)
    puts "detected `kqueue`"
    $defs << "-DFIO_ENGINE_KQUEUE"
  elsif try_compile(iodine_poll_test_poll)
    puts "detected `poll` - this is suboptimal fallback!"
    $defs << "-DFIO_ENGINE_POLL"
  else
    puts "* WARNING: No supported polling engine! expecting compilation to fail."
  end
end

#on_worker_boot(*args, &block) ⇒ Object

Deprecated.

Performs a block of code before a new worker process spins up (performed once per worker).



242
243
244
245
# File 'lib/iodine.rb', line 242

def on_worker_boot(*args, &block)
  warn "on_worker_boot is deprecated, use Iodine.on_state(:after_fork)."
  Iodine.on_state(:after_fork, &block)
end

#on_worker_fork(*args, &block) ⇒ Object

Deprecated.

Performs a block of code before a new worker process spins up (performed once per worker).



251
252
253
254
# File 'lib/iodine.rb', line 251

def on_worker_fork(*args, &block)
  warn "on_worker_fork is deprecated, use Iodine.on_state(:before_fork)."
  Iodine.on_state(:before_fork, &block)
end