Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » Redirect - possibly another Skylark bug
Redirect - possibly another Skylark bug [message #38632] Mon, 31 December 2012 11:16 Go to previous message
Peter is currently offline  Peter
Messages: 16
Registered: October 2012
Promising Member
Hi.

I'll start with the code example sufficient to reproduce the wrong behaviour. The example consists of a single file Main.cpp:

#include <Skylark/Skylark.h>

using namespace Upp;

bool handler_checked;

SKYLARK(BBB, "bbb") 
{
	http << "<html><body>OK</body></html>";
	handler_checked = false; 
}

SKYLARK(Check, "check")
{
	handler_checked = true;
	http.Redirect(BBB);
}

SKYLARK(HomePage, "")
{
	if(!handler_checked)
	{
		http.Redirect(Check);
		return;
	}
	RLOG("ERROR");
}

SKYLARK(CatchAll, "**")
{
	http.Redirect(HomePage);
}

struct MyApp : SkylarkApp {

    MyApp() {
    #ifdef _DEBUG
	prefork = 0;
	use_caching = false;
	#endif
    }
};

CONSOLE_APP_MAIN
{
	#ifdef _DEBUG
	StdLogSetup(LOG_FILE|LOG_COUT);
	Ini::skylark_log = true;
	#endif
    MyApp().Run();    
}


Now for the actual problem. My motivation is as follows: whenever I go to root page, I want to get redirected to /check and finally
to /bbb. Redirection process is managed by a boolean variable handler_checked (initially set to false). In Check I set it to true and finally reset it back to false in BBB (so that another visit to root page will redirect me to /bbb again).

Unfortunately, after a random number of attempts (usually between 2 and 4) something goes wrong and root page doesn't redirect me to /bbb anymore. According to logs, at some point redirection from /check to /bbb fails. As a result, after redirection sequence is complete, I'm left with handler_checked == true instead of false. That's why another access to root page doesn't redirect me anywhere (I go to RLOG("ERROR") instead).

Please compare these two fragments of log:

1. correct redirection to /bbb:

7 Redirect to: /bbb
7 Finished
n Accepted
g Waiting for accept
n GET /bbb

2. redirection to /bbb skipped(?):

s Redirect to: /bbb
s Finished
4 Accepted
p Waiting for accept
4 GET /

As you can see, in the second case for some reason we have "GET /" instead of "GET /bbb". Because we miss a call to BBB and call HomePage instead with value of handler_checked not restored to false, we end up with the error I described.

I'm able to reproduce this problem with
Google Chrome 20.0.1132.47 (or Chromium which I think makes no real difference) while Mozilla Firefox seems to behave correctly (I haven't tried other browsers yet). Try the following steps using Chrome:

1. Compile the code and run the application.
2. Go to root page.
3. Keep repeating step 2 - one of the attempts should not redirect you to /bbb, you should end up with a blank root page and "ERROR" in log.

Best regards

Peter
 
Read Message
Read Message
Previous Topic: ARM threadind does not work
Next Topic: [Web] using of an uninitialized value in expression
Goto Forum:
  


Current Time: Mon May 12 16:06:05 CEST 2025

Total time taken to generate the page: 0.02832 seconds