this repo has no description
3
fork

Configure Feed

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

app: only destroy clients in Debug build

We only clean up clients in Debug mode so we can check for memory leaks
without failing for this. We don't care about it in any other mode since
we are exiting anyways and we want to do it fast. If we destroy, our
readthread could panic so we don't do it unless we have to.

I first attempted to use a selfpipe poll to get the clients to exit
cleanly, however the tls library does not work nicely with poll - we end
up not reading until the timeout is done. So instead, we do it this way

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>

+10 -3
+10 -3
src/app.zig
··· 1 1 const std = @import("std"); 2 + const builtin = @import("builtin"); 2 3 const comlink = @import("comlink.zig"); 3 4 const vaxis = @import("vaxis"); 4 5 const zeit = @import("zeit"); ··· 137 138 for (self.clients.items, 0..) |_, i| { 138 139 var client = self.clients.items[i]; 139 140 client.deinit(); 140 - self.alloc.destroy(client); 141 + if (builtin.mode != .Debug) { 142 + // We only clean up clients in Debug mode so we can check for memory leaks 143 + // without failing for this. We don't care about it in any other mode since we 144 + // are exiting anyways and we want to do it fast. If we destroy, our readthread 145 + // could panic so we don't do it unless we have to. 146 + self.alloc.destroy(client); 147 + } 141 148 } 142 149 self.clients.deinit(); 143 150 } ··· 777 784 const command: comlink.Command = blk: { 778 785 const start: u1 = if (cmd[0] == '/') 1 else 0; 779 786 const end = mem.indexOfScalar(u8, cmd, ' ') orelse cmd.len; 780 - if (comlink.Command.fromString(cmd[start..end])) |builtin| 781 - break :blk builtin; 787 + if (comlink.Command.fromString(cmd[start..end])) |internal| 788 + break :blk internal; 782 789 if (comlink.Command.user_commands.get(cmd[start..end])) |ref| { 783 790 const str = if (end == cmd.len) "" else std.mem.trim(u8, cmd[end..], " "); 784 791 return lua.execUserCommand(lua_state, str, ref);