Top Level Namespace

Defined Under Namespace

Modules: Iodine

Constant Summary collapse

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

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


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

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


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

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


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

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


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

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 = <<EOS
\#define _GNU_SOURCE
\#include <stdlib.h>
\#include <sys/event.h>
int main(void) {
  int fd = kqueue();
}
EOS

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

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

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


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

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


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

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