Commit 4a4ca20
Fix crash when restarting mongoose server on Windows
mg_start() calls InitializeCriticalSection(&global_log_file_lock) on
every invocation, but mg_stop() never calls DeleteCriticalSection.
Re-initializing an already-initialized critical section is undefined
behavior on Windows and corrupts the heap, causing the next allocation
to throw an exception.
Make the Win32 initialization (WSAStartup + InitializeCriticalSection)
one-shot via a static flag, and remove the asymmetric WSACleanup from
mg_stop so resources remain valid across mg_start/mg_stop cycles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent cc26887 commit 4a4ca20
1 file changed
Lines changed: 12 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5046 | 5046 | | |
5047 | 5047 | | |
5048 | 5048 | | |
5049 | | - | |
5050 | | - | |
5051 | | - | |
| 5049 | + | |
| 5050 | + | |
| 5051 | + | |
5052 | 5052 | | |
5053 | 5053 | | |
5054 | 5054 | | |
| |||
5058 | 5058 | | |
5059 | 5059 | | |
5060 | 5060 | | |
5061 | | - | |
5062 | | - | |
5063 | | - | |
| 5061 | + | |
| 5062 | + | |
| 5063 | + | |
| 5064 | + | |
| 5065 | + | |
| 5066 | + | |
| 5067 | + | |
| 5068 | + | |
| 5069 | + | |
5064 | 5070 | | |
5065 | 5071 | | |
5066 | 5072 | | |
| |||
0 commit comments