Hi everybody,
we are using mongoose web server 3.0 and we encountered following problem.
Problem: Lets say we have some resource on our mongoose server which returns only text info, e.g. URL
http://localhost:8000/get_version. If I try to request this URL from IE10 on Windows7 it works. But if I repeat the request approx. 30 times or more (hitting F5) it happens once that the request is never served and IE10 is still loading the page and never succeed.
Analysis: We found out that sometimes IE10 opens two TCP connections to our mongoose server when hitting F5 once. Request is served using one connection and the second connection is still open, waiting for more requests to come. Opening 2 connections results in opening two sockets on the server (function produce_socket in mongoose.c) and 2 worker threads are woke up to serve the sockets (function consume_socket in mongoose.c). The problem is that the access to queue of sockets ctx->queue in consume_socket function is not synchronized. Both threads grab the same socket and then both threads increment ctx->sq_tail++;. This results in the fact that second socket is not served by any thread and is forgot forever.
Solution:The access to queue of sockets should be synchronized, e.g. by some new mutex?
Please, can you confirm that it is a bug? I checked the source code of newest version 4.1 and the bug seems to be also there. However I have not tested version 4.1.
Thanks!
Juraj Majer