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).



197
198
199
200
# File 'lib/iodine.rb', line 197

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).



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

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).



206
207
208
209
# File 'lib/iodine.rb', line 206

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).



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

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



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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'ext/iodine/extconf.rb', line 33

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 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).



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

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).



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

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