diff --git a/ext/rbtrace.c b/ext/rbtrace.c index b145f28..58125f0 100644 --- a/ext/rbtrace.c +++ b/ext/rbtrace.c @@ -51,6 +51,11 @@ #endif +// The SUN_LEN macro is not available on Android +#ifndef SUN_LEN +#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) + strlen((ptr)->sun_path)) +#endif + static uint64_t ru_utime_usec() { @@ -688,7 +693,7 @@ rbtracer_add(char *query, bool is_slow) *idx = NULL, *method = NULL; - if (NULL != (idx = rindex(query, '.'))) { + if (NULL != (idx = strrchr(query, '.'))) { klass_begin = 0; klass_end = idx - query; is_singleton = true; @@ -700,7 +705,7 @@ rbtracer_add(char *query, bool is_slow) method = idx+1; - } else if (NULL != (idx = rindex(query, '#'))) { + } else if (NULL != (idx = strrchr(query, '#'))) { klass_begin = 0; klass_end = idx - query; is_singleton = false; diff --git a/server.rb b/server.rb index d0e5a1c..af86940 100644 --- a/server.rb +++ b/server.rb @@ -1,4 +1,5 @@ require 'ext/rbtrace' +require 'tmpdir' class String def multiply_vowels(num) @@ -26,19 +27,21 @@ def self.run while true proc { - Dir.chdir("/tmp") do - Dir.pwd - Process.pid - 'hello'.multiply_vowels(3){ :ohai } - sleep rand*0.5 + Dir.mktmpdir do |tmp| + Dir.chdir(tmp) do + Dir.pwd + Process.pid + 'hello'.multiply_vowels(3){ :ohai } + sleep rand*0.5 - ENV['blah'] - GC.start + ENV['blah'] + GC.start - reload_test.call - Test.run + reload_test.call + Test.run - #fib(1024*100) + #fib(1024*100) + end end }.call end