joswa / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

assert(ctx->sq_head > ctx->sq_tail) assertion failed #216

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The following is the event_handler. 
In the ajaxAccountsInfo and ajaxPricesInfo, I only output the ajax content 
simply by using mg_printf.

static void *event_handler(enum mg_event event,
                           mg_connection *conn,
                           const mg_request_info *request_info)
{
  void *processed = (void*)"yes";

  if (event == MG_NEW_REQUEST) {
    if (strcmp(request_info->uri, "/accounts") == 0) {
        WebService::inst()->ajaxAccountsInfo(conn, request_info);
    } else if (strcmp(request_info->uri, "/prices") == 0) {
        WebService::inst()->ajaxPricesInfo(conn, request_info);
    } else {
      // No suitable handler found, mark as not processed. Mongoose will
      // try to serve the request.
      processed = NULL;
    }
  } else {
    processed = NULL;
  }

  return processed;
}

On the browser side, a jQuery script refresh /accounts and /prices every 
second. There is only one browser accessing the server.

What version of the product are you using? On what operating system?
OS: Windows XP
Compiler: Mingw32, GCC 4.4.0

Original issue reported on code.google.com by andy...@gmail.com on 30 Dec 2010 at 5:38

GoogleCodeExporter commented 9 years ago
I think that if ctx->queue is a ring, the assertion ctx->sq_head > ctx->sq_tail 
should not always be true if the ctx->sq_head is wrapped while the ctx->sq_tail 
is not wrapped.

Original comment by andy...@gmail.com on 30 Dec 2010 at 5:43

GoogleCodeExporter commented 9 years ago
I think there is a lack of "volatile" keyword on most ctx fields. These fields 
are modified by several threads. Compiler is not aware of that and some 
optimization can put some values in register instead of keeping them in ram.

I already observe same behaviour on ctx->nb_thread with an assert when stopping 
cleanly.

Original comment by laurent....@gmail.com on 13 Feb 2011 at 1:22

GoogleCodeExporter commented 9 years ago
Pushed 
http://code.google.com/p/mongoose/source/detail?r=11b1f767f54f68d7289b6a5e10859c
0c5faed439
Please test 

Original comment by valenok on 15 Feb 2011 at 4:15

GoogleCodeExporter commented 9 years ago
With "volatile", it's ok. No more assert triggered. Thx

Original comment by laurent....@gmail.com on 1 Apr 2011 at 2:59

GoogleCodeExporter commented 9 years ago

Original comment by valenok on 21 Jun 2011 at 11:31