sinusiks / phpdesktop

Automatically exported from code.google.com/p/phpdesktop
0 stars 0 forks source link

MSIE/Win7: mongoose webserver hangs for about 30s after application was closed #61

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
stoppping Mongoose webserver freezes for about 30 seconds on Win7. This does 
not happen in phpdesktop-chrome that uses exact same version of Mongoose. 
Fortunately, the freezing happens after the application window was closed, so 
this problem is not visible to end user. Only that the phpdesktop-msie.exe 
process still hangs in Task Manager. This could be an issue if 
"single_instanace_application" is set in settings.json file and user tries to 
launch application once again, after he closed it just several seconds ago. 
This issue must have something to do with the MSIE web control. Maybe it is 
caused by the call to CoInitialize() that identifies the concurrency model as 
single-thread apartment?

Original issue reported on code.google.com by czarek.t...@gmail.com on 22 Jan 2014 at 11:21

GoogleCodeExporter commented 9 years ago
This is happening randomly, depepnding on the content being served by the 
webserver. If I just load only index.php and close app it hangs. If I navigate 
to some other script and close app, then it doesn't hang. In some other 
scenario with two some other scripts being run, it hangs again.

Original comment by czarek.t...@gmail.com on 22 Jan 2014 at 11:27

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
It seems that the IE webbrowser control does not free IO channel resources 
properly, or does it delayed. There is this sleep call in mongoose when 
stopping webserver:

  ctx->stop_flag = 1;
  // Wait until mg_fini() stops
  while (ctx->stop_flag != 2) {
    (void) mg_sleep(10);
  }
  free_context(ctx);

Let's investigate if there is a way to stop mongoose immediately without the 
calls to mg_sleep().

Original comment by czarek.t...@gmail.com on 22 Jan 2014 at 11:37

GoogleCodeExporter commented 9 years ago
It seems that when application quits it shouldn't matter if mongoose resources 
are released, thus we could fix the problem and quit app immediately without 
the call to mg_stop(). See this post by Sergey Lyubka:

https://groups.google.com/d/msg/mongoose-users/qLNrY6asGms/zGC-rIHMO5oJ

We could introduce a new parameter to the mg_stop(bool quit_immediately=false) 
function.

Original comment by czarek.t...@gmail.com on 22 Jan 2014 at 11:46

GoogleCodeExporter commented 9 years ago
Fixed in revision 1f8c53d45df4.

Original comment by czarek.t...@gmail.com on 22 Jan 2014 at 12:13

GoogleCodeExporter commented 9 years ago
Project will move to Github. Find this issue at the new address (soon): 
https://github.com/cztomczak/phpdesktop/issues/61

Original comment by czarek.t...@gmail.com on 24 Aug 2015 at 3:23