Closed GoogleCodeExporter closed 9 years ago
I don't think this is a big problem, since:
1. Mongoose is a library, and if it is embedded in the app, it should not
decide on
app's behalf to WSACleanup
2. this leak is not cumulative, it is one-off and can be neglected.
Original comment by valenok
on 3 Jun 2009 at 11:08
[deleted comment]
I think, then, you should consider removing the #if/#endif for the _WIN32 in
the init
routine for not calling WSAStartup() on developer's behave. That way, one would
remember to call WSACleanup() since he/she called WSAStartup(), as part of good
housekeeping programming practices.
Otherwise, the "fix" is simply adding #if/#endif to mg_stop to call
WSACleanup() at
the end, after freeing ctx.
Original comment by PKuo...@gmail.com
on 4 Jun 2009 at 8:15
What happens if application continues to run after mg_stop(), using sockets?
Original comment by valenok
on 4 Jun 2009 at 8:56
Nothing IF the developer made his/her own WSAStartup() call, like a "good
Windows
programmer" should -- WSAStartup() may be called multiple times (after the first
call, it just keeps a counter on how many times it has been called). Then
WSACleanup() would check on this internal counter to see if an actual cleanup
should
be performed or just decrease the counter - the cleanup happens on the last
counter
value.
Therefore, for "proper" (Windows) development, one calls WSAStartup because
he/she
will use sockets, then calls mg_start (which calls WSAStartup). mg_stop is
called,
WSACleanup is called so that cancels out the "inner" WSAStartup, but the socket
world
is still happen and alive. Then the developer is done with his/her socket usage
and
calls WSACleanup, that matches the first WSAStartup so an actual cleanup takes
place.
Happy ending for all. (I hope!)
Original comment by PKuo...@gmail.com
on 4 Jun 2009 at 9:50
Original comment by valenok
on 4 Jun 2009 at 9:52
Submitted http://code.google.com/p/mongoose/source/detail?r=436
Thank you.
Original comment by valenok
on 5 Jul 2009 at 7:32
Original issue reported on code.google.com by
PKuo...@gmail.com
on 3 Jun 2009 at 2:22