search for standard sites pub-search.waow.tech
search zig blog atproto
11
fork

Configure Feed

Select the types of activity you want to include in your feed.

revert: restore shared turso client with mutex

per-request http.Client caused all turso requests to hang (likely
TLS handshake overhead). restore shared client with mutex — the
sync not-ready fix means search won't hit turso during sync anyway.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

zzstoatzz 31eefcab ad4b87f1

+12 -10
+12 -10
backend/src/db/Client.zig
··· 27 27 allocator: Allocator, 28 28 url: []const u8, 29 29 token: []const u8, 30 + mutex: std.Thread.Mutex = .{}, 31 + http_client: http.Client, 30 32 31 33 pub fn init(allocator: Allocator) !Client { 32 34 const url = std.posix.getenv("TURSO_URL") orelse { ··· 50 52 .allocator = allocator, 51 53 .url = host, 52 54 .token = token, 55 + .http_client = .{ .allocator = allocator }, 53 56 }; 54 57 } 55 58 56 59 pub fn deinit(self: *Client) void { 57 - _ = self; 60 + self.http_client.deinit(); 58 61 } 59 62 60 63 pub fn query(self: *Client, comptime sql: []const u8, args: anytype) !Result { ··· 120 123 }); 121 124 defer span.end(); 122 125 126 + self.mutex.lock(); 127 + defer self.mutex.unlock(); 128 + 123 129 var url_buf: [URL_BUF_SIZE]u8 = undefined; 124 130 const url = std.fmt.bufPrint(&url_buf, "https://{s}/v2/pipeline", .{self.url}) catch 125 131 return error.UrlTooLong; ··· 134 140 var response_body: std.Io.Writer.Allocating = .init(self.allocator); 135 141 errdefer response_body.deinit(); 136 142 137 - // per-request http client — no shared mutex needed 138 - var hc: http.Client = .{ .allocator = self.allocator }; 139 - defer hc.deinit(); 140 - 141 - const res = hc.fetch(.{ 143 + const res = self.http_client.fetch(.{ 142 144 .location = .{ .url = url }, 143 145 .method = .POST, 144 146 .headers = .{ ··· 175 177 }); 176 178 defer span.end(); 177 179 180 + self.mutex.lock(); 181 + defer self.mutex.unlock(); 182 + 178 183 var url_buf: [URL_BUF_SIZE]u8 = undefined; 179 184 const url = std.fmt.bufPrint(&url_buf, "https://{s}/v2/pipeline", .{self.url}) catch 180 185 return error.UrlTooLong; ··· 189 194 var response_body: std.Io.Writer.Allocating = .init(self.allocator); 190 195 errdefer response_body.deinit(); 191 196 192 - var hc: http.Client = .{ .allocator = self.allocator }; 193 - defer hc.deinit(); 194 - 195 - const res = hc.fetch(.{ 197 + const res = self.http_client.fetch(.{ 196 198 .location = .{ .url = url }, 197 199 .method = .POST, 198 200 .headers = .{