Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/socket/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ def %(s) s || self end

have_func("pthread_create")
have_func("pthread_detach")
have_func("pthread_attr_setdetachstate")

$VPATH << '$(topdir)' << '$(top_srcdir)'
create_makefile("socket")
Expand Down
1 change: 0 additions & 1 deletion ext/socket/ipsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,6 @@ init_fast_fallback_inetsock_internal(VALUE v)
if (raddrinfo_pthread_create(&threads[i], fork_safe_do_fast_fallback_getaddrinfo, arg->getaddrinfo_entries[i]) != 0) {
rsock_raise_resolution_error("getaddrinfo(3)", EAI_AGAIN);
}
pthread_detach(threads[i]);
}

if (NIL_P(resolv_timeout)) {
Expand Down
40 changes: 37 additions & 3 deletions ext/socket/raddrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,49 @@ int
raddrinfo_pthread_create(pthread_t *th, void *(*start_routine) (void *), void *arg)
{
int limit = 3, ret;
int saved_errno;
#ifdef HAVE_PTHREAD_ATTR_SETDETACHSTATE
pthread_attr_t attr;
pthread_attr_t *attr_p = &attr;
int err;
int init_retries = 0;
int init_retries_max = 3;
retry_attr_init:
if ((err = pthread_attr_init(attr_p)) != 0) {
if (err == ENOMEM && init_retries < init_retries_max) {
init_retries++;
rb_gc();
goto retry_attr_init;
}
return err;
}
if ((err = pthread_attr_setdetachstate(attr_p, PTHREAD_CREATE_DETACHED)) != 0) {
saved_errno = errno;
pthread_attr_destroy(attr_p);
errno = saved_errno;
return err; // EINVAL - shouldn't happen
}
#else
pthread_attr_t *attr_p = NULL;
#endif
do {
// It is said that pthread_create may fail spuriously, so we follow the JDK and retry several times.
//
// https://bugs.openjdk.org/browse/JDK-8268605
// https://github.com/openjdk/jdk/commit/e35005d5ce383ddd108096a3079b17cb0bcf76f1
ret = pthread_create(th, 0, start_routine, arg);
ret = pthread_create(th, attr_p, start_routine, arg);
} while (ret == EAGAIN && limit-- > 0);
#ifdef HAVE_PTHREAD_ATTR_SETDETACHSTATE
saved_errno = errno;
pthread_attr_destroy(attr_p);
if (ret != 0) {
errno = saved_errno;
}
#else
if (ret == 0) {
pthread_detach(th); // this can race with shutdown routine of thread in some glibc versions
}
#endif
return ret;
}

Expand Down Expand Up @@ -534,7 +570,6 @@ rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hint
errno = err;
return EAI_SYSTEM;
}
pthread_detach(th);

rb_thread_call_without_gvl2(wait_getaddrinfo, arg, cancel_getaddrinfo, arg);

Expand Down Expand Up @@ -770,7 +805,6 @@ rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
errno = err;
return EAI_SYSTEM;
}
pthread_detach(th);

rb_thread_call_without_gvl2(wait_getnameinfo, arg, cancel_getnameinfo, arg);

Expand Down
2 changes: 1 addition & 1 deletion internal/set_table.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef INTERNAL_SET_TABLE_H
#define INTERNAL_SET_TABLE_H

#include "include/ruby/st.h"
#include "ruby/st.h"

struct set_table_entry;

Expand Down
2 changes: 1 addition & 1 deletion internal/st.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef INTERNAL_ST_H
#define INTERNAL_ST_H

#include "include/ruby/st.h"
#include "ruby/st.h"

st_table *rb_st_replace(st_table *new_tab, st_table *old_tab);
#define st_replace rb_st_replace
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/lockfile_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def add_section(name, value)
out << " #{key}: #{val}\n"
end
when String
out << " #{value}\n"
out << " #{value}\n"
else
raise ArgumentError, "#{value.inspect} can't be serialized in a lockfile"
end
Expand Down
8 changes: 4 additions & 4 deletions spec/bundler/bundler/definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
foo!
#{checksums}
BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
G
end

Expand Down Expand Up @@ -137,7 +137,7 @@
foo!
#{checksums}
BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
G

expect(lockfile).to eq(expected_lockfile)
Expand Down Expand Up @@ -175,7 +175,7 @@
only_java
#{checksums}
BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
G
end

Expand Down Expand Up @@ -205,7 +205,7 @@
foo
#{checksums}
BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
G
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/cache/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@
foo!

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L

# Simulate an old incorrect situation where vendor/cache would be the install location of git gems
Expand Down
10 changes: 5 additions & 5 deletions spec/bundler/commands/cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
myrack-obama

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
bundle :cache, raise_on_error: false
expect(exitstatus).to eq(16)
Expand Down Expand Up @@ -322,7 +322,7 @@
myrack

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
FileUtils.mkdir_p app_cache

Expand Down Expand Up @@ -359,7 +359,7 @@
bar

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L

bundle "cache --no-install"
Expand Down Expand Up @@ -502,7 +502,7 @@
foo

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L

simulate_platform "x86_64-linux" do
Expand Down Expand Up @@ -589,7 +589,7 @@
bcrypt_pbkdf

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L

simulate_platform "arm64-darwin-23" do
Expand Down
6 changes: 3 additions & 3 deletions spec/bundler/commands/check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
myrack

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
end

Expand Down Expand Up @@ -411,7 +411,7 @@
depends_on_myrack!
#{checksums}
BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
end
end
Expand Down Expand Up @@ -482,7 +482,7 @@
dex-dispatch-engine!
#{checksums}
BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
end
end
Expand Down
28 changes: 14 additions & 14 deletions spec/bundler/commands/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
myrack

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L

bundle "install", raise_on_error: false
Expand Down Expand Up @@ -764,10 +764,10 @@
DEPENDENCIES
#{checksums}
RUBY VERSION
#{Bundler::RubyVersion.system}
#{Bundler::RubyVersion.system}

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
end

Expand All @@ -790,10 +790,10 @@
DEPENDENCIES
#{checksums}
RUBY VERSION
#{Bundler::RubyVersion.system}
#{Bundler::RubyVersion.system}

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
end

Expand Down Expand Up @@ -1330,7 +1330,7 @@ def run
libv8

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L

simulate_platform("x86_64-linux", &example)
Expand All @@ -1357,7 +1357,7 @@ def run
libv8

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
end

Expand Down Expand Up @@ -1433,7 +1433,7 @@ def run
#{Bundler::RubyVersion.system}

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
end

Expand Down Expand Up @@ -1474,10 +1474,10 @@ def run
loofah (~> 2.12.0)
#{checksums}
RUBY VERSION
#{Bundler::RubyVersion.system}
#{Bundler::RubyVersion.system}

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
end
end
Expand Down Expand Up @@ -1507,7 +1507,7 @@ def run
myrack_middleware

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
end

Expand Down Expand Up @@ -1754,7 +1754,7 @@ def run
zzz!

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
end

Expand Down Expand Up @@ -1845,7 +1845,7 @@ def run
mypsych (~> 4.0)

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L

install_gemfile <<~G
Expand All @@ -1868,7 +1868,7 @@ def run
mypsych (~> 5.0)

BUNDLED WITH
#{Bundler::VERSION}
#{Bundler::VERSION}
L
end
end
Loading