Use tomb v2, update deps, fix hang on stale connection

- Use tomb v2 to properly spawn and reap goroutines (hopefully)
- Update deps
- Fix hang on stale connection due to improper goroutine management
This commit is contained in:
eleksir
2024-11-16 10:41:00 +03:00
parent 678d830f8c
commit fb19f8056a
345 changed files with 14486 additions and 7346 deletions

View File

@@ -37,14 +37,17 @@ func (token Token) Environ(inheritExisting bool) (env []string, err error) {
return nil, err
}
defer DestroyEnvironmentBlock(block)
blockp := unsafe.Pointer(block)
for {
entry := UTF16PtrToString((*uint16)(blockp))
if len(entry) == 0 {
break
size := unsafe.Sizeof(*block)
for *block != 0 {
// find NUL terminator
end := unsafe.Pointer(block)
for *(*uint16)(end) != 0 {
end = unsafe.Add(end, size)
}
env = append(env, entry)
blockp = unsafe.Add(blockp, 2*(len(entry)+1))
entry := unsafe.Slice(block, (uintptr(end)-uintptr(unsafe.Pointer(block)))/size)
env = append(env, UTF16ToString(entry))
block = (*uint16)(unsafe.Add(end, size))
}
return env, nil
}