Support thread local storage

This commit is contained in:
Justine Tunney 2022-05-16 13:20:08 -07:00
parent 91ee2b19d4
commit 55de4ca6b5
197 changed files with 1483 additions and 874 deletions

View file

@ -96,7 +96,7 @@
*/
struct UnixErrno {
int errno;
int errno_;
int winerr;
const char *call;
};
@ -185,7 +185,7 @@ static int SysretErrno(lua_State *L, const char *call, int olderr) {
lua_pushnil(L);
ep = lua_newuserdatauv(L, sizeof(*ep), 1);
luaL_setmetatable(L, "unix.Errno");
ep->errno = unixerr;
ep->errno_ = unixerr;
ep->winerr = winerr;
ep->call = call;
errno = olderr;
@ -2047,7 +2047,7 @@ static struct UnixErrno *GetUnixErrno(lua_State *L) {
// unix.Errno:errno()
// └─→ errno:int
static int LuaUnixErrnoErrno(lua_State *L) {
return ReturnInteger(L, GetUnixErrno(L)->errno);
return ReturnInteger(L, GetUnixErrno(L)->errno_);
}
static int LuaUnixErrnoWinerr(lua_State *L) {
@ -2055,11 +2055,11 @@ static int LuaUnixErrnoWinerr(lua_State *L) {
}
static int LuaUnixErrnoName(lua_State *L) {
return ReturnString(L, strerrno(GetUnixErrno(L)->errno));
return ReturnString(L, strerrno(GetUnixErrno(L)->errno_));
}
static int LuaUnixErrnoDoc(lua_State *L) {
return ReturnString(L, strerdoc(GetUnixErrno(L)->errno));
return ReturnString(L, strerdoc(GetUnixErrno(L)->errno_));
}
static int LuaUnixErrnoCall(lua_State *L) {
@ -2071,10 +2071,10 @@ static int LuaUnixErrnoToString(lua_State *L) {
struct UnixErrno *e;
e = GetUnixErrno(L);
if (e->call) {
strerror_wr(e->errno, e->winerr, msg, sizeof(msg));
strerror_wr(e->errno_, e->winerr, msg, sizeof(msg));
lua_pushfstring(L, "%s() failed: %s", e->call, msg);
} else {
lua_pushstring(L, strerrno(e->errno));
lua_pushstring(L, strerrno(e->errno_));
}
return 1;
}

View file

@ -5404,7 +5404,7 @@ static void LogClose(const char *reason) {
INFOF("(stat) %s %s with %,ld unprocessed and %,d handled (%,d workers)",
DescribeClient(), reason, amtread, messageshandled, shared->workers);
} else {
DEBUGF("(stat) %s %s with %,d requests handled", DescribeClient(), reason,
DEBUGF("(stat) %s %s with %,d messages handled", DescribeClient(), reason,
messageshandled);
}
}
@ -6175,8 +6175,6 @@ static bool HandleMessageActual(void) {
p = stpcpy(p, referrerpolicy);
p = stpcpy(p, "\r\n");
}
LockInc(&shared->c.messageshandled);
++messageshandled;
if (loglatency || LOGGABLE(kLogDebug)) {
now = nowl();
LOGF(kLogDebug, "(stat) %`'.*s latency r: %,ldµs c: %,ldµs",