bannsec / cosmosocks

Socks server written in Cosmopolitan libc
GNU General Public License v3.0
20 stars 2 forks source link

Threads #8

Open bannsec opened 1 year ago

bannsec commented 1 year ago

Initially used forking due to recommendations on cosmopolitan libc. It appears they're actively improving threading support, so will need to reassess if threads would be preferable to forking.

Might be a bit on this... I don't see a good way to have detached threads in cosmopolitan libc: https://justine.lol/cosmopolitan/documentation.html#_spawn

struct ths* opt_out_thread -- needn't be initialiized and is always clobbered except when it isn't specified, in which case, the thread is kind of detached and will (currently) just leak the stack / tls memory

No point in just leaking memory.

jart commented 1 year ago

Cosmopolitan Libc v2.1 now supports pthreads. That includes detached threads, which are currently automatically reclaimed on pthread_create entry or __cxa_finalize.

bannsec commented 1 year ago

Awesome! Will check it out.