Synchronization issue on Windows7 and IE10

29 views
Skip to first unread message

Juraj Majer

unread,
Oct 25, 2013, 6:43:41 AM10/25/13
to mongoos...@googlegroups.com
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


Sergey Lyubka

unread,
Oct 29, 2013, 11:57:47 PM10/29/13
to mongoose-users
Synchronization is done by means of pthread_mutex_lock() call in consume_socket().
If the queue is empty, pthread_cond_wait() unlocks the mutex and waits until the queue
is not empty, returning with mutex locked.
It may be that my win32 implementation of pthread_cond_wait() is faulty.


--
You received this message because you are subscribed to the Google Groups "mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-user...@googlegroups.com.
To post to this group, send email to mongoos...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages