Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix require failing in Termux on Android #80

Merged
merged 1 commit into from Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions ext/rbtrace.c
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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, '.'))) {
ZimbiX marked this conversation as resolved.
Show resolved Hide resolved
klass_begin = 0;
klass_end = idx - query;
is_singleton = true;
Expand All @@ -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;
Expand Down
23 changes: 13 additions & 10 deletions server.rb
@@ -1,4 +1,5 @@
require 'ext/rbtrace'
require 'tmpdir'

class String
def multiply_vowels(num)
Expand Down Expand Up @@ -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|
ZimbiX marked this conversation as resolved.
Show resolved Hide resolved
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