4 ms·
I would be careful to use this in production. I'm a diehard C and C++ fan, but: Having a mutex unlock inside an if statement that performs an early return, on l
by lionkor 2y ago
I would be careful to use this in production. I'm a diehard C and C++ fan, but: Having a mutex unlock inside an if statement that performs an early return, on line 52000 something, does not inspire confidence.
Excellent job on building this, and it's very readable and nice, otherwise!
- not_a_dane 2y agowhen I see C/C++ code, I prefer do not run it.
- bun_terminator 2y agoThis is C, not C++ - very different languages.
- lionkor 2y agoYes, you should be using a goto for this in C
- metadat 2y agoLine 52,000 and x of what file? I didn't find any file with that many line's yet, still searching but I doubt it exists unless it's in a different repository.
- lionkor 2y agohttps://github.com/quickjs-ng/quickjs/blob/b071d36ab561a85fad11f487f875aba2d25b5ccd/quickjs.c#L52282 https://github.com/quickjs-ng/quickjs/blob/b071d36ab561a85fa...
- metadat 2y agoThanks for digging that up. It looks like the mutex is theoretically sound.. unlocked before all returns, as long as there isn't an exception raised in between. I wonder what the parent comment's issue is.
- lionkor 2y agoOh yeah of course its sound, but this is not how you write C code, because all it takes is for someone else in 10 years to, somewhere between 51000 and 53000 introduce an early return statement and forget to unlock that mutex, or other little things. This is solved in C usually with a goto to a cleanup routine, and avoiding early returns.