aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/global.zig20
-rw-r--r--src/http_client_async.zig3
2 files changed, 12 insertions, 11 deletions
diff --git a/src/global.zig b/src/global.zig
index 046496029..fefc6b8bc 100644
--- a/src/global.zig
+++ b/src/global.zig
@@ -79,17 +79,9 @@ pub const Output = struct {
source = Source.init(stdout_stream, stderr_stream);
}
- pub fn configureNamedThread(thread: std.Thread, name: StringTypes.stringZ) void {
- if (source_set) return;
+ pub fn configureNamedThread(_: std.Thread, name: StringTypes.stringZ) void {
+ Global.setThreadName(name);
configureThread();
-
- // On Linux, thread may be undefined
- // Fortunately, we can use a different syscall that only affects the current thread
- if (Environment.isLinux) {
- _ = std.os.prctl(.SET_NAME, .{@ptrToInt(name.ptr)}) catch 0;
- } else {
- thread.setName(name) catch {};
- }
}
fn isForceColor() ?bool {
@@ -559,6 +551,14 @@ pub const Global = struct {
return @import("root").start_time;
}
+ pub fn setThreadName(name: StringTypes.stringZ) void {
+ if (Environment.isLinux) {
+ _ = std.os.prctl(.SET_NAME, .{@ptrToInt(name.ptr)}) catch 0;
+ } else if (Environment.isMac) {
+ _ = std.c.pthread_setname_np(name);
+ }
+ }
+
pub const AllocatorConfiguration = struct {
verbose: bool = false,
long_running: bool = false,
diff --git a/src/http_client_async.zig b/src/http_client_async.zig
index 107f576f3..ada77b8c4 100644
--- a/src/http_client_async.zig
+++ b/src/http_client_async.zig
@@ -46,6 +46,7 @@ pub fn onThreadStart() void {
AsyncIO.global_loaded = true;
NetworkThread.global.pool.io = &AsyncIO.global;
+ Global.setThreadName("HTTP");
}
pub inline fn getAllocator() std.mem.Allocator {
@@ -61,7 +62,7 @@ else
pub const OPEN_SOCKET_FLAGS = SOCK.CLOEXEC;
-pub const extremely_verbose = true;
+pub const extremely_verbose = Environment.isDebug;
fn writeRequest(
comptime Writer: type,