×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    8

    Connecting on the 9500 eats all the CPU time

    I have an application on the Nokia 9500 which performs a long process in a number of steps. A CIdle object determines when to execute the next step. One of these steps sends and retrieves data from a webservice. But.. in about 50% of the runs, the application panics with a ViewSrv 11 after making the connection.

    I use the RHttpSession and RHttpTransaction classes to make the connection and to retrieve the data. The CIdle object runs with priority 'low' (I also tried 'idle', which had the same result). Right before returning ETrue to the CIdle object, I wait a while with User::After(5000), thinking this might solve the problem, but it didn't.

    What I see in the log files, is that:
    - the connection is being made and the transaction started
    - the CIdle callback function returns with a value of ETrue, telling the CIdle object that there is more work to be done

    ..and that's it. In about half of the cases, the CIdle object never gets activated again.

    What I see on the screen is:
    - I am asked how I want to connect to the Internet; I select a GSM connection
    - my application starts blinking an info message to indicate it is busy
    - behind the info message, I still see the connection dialog; the screen does not get refreshed when the call is being made
    - the screen either gets refreshed, or the View server thinks it all takes too much time and bails out with a panic 11

    It looks like *something* is eating up all the processor time after my application gives control back to the operating system.

    The same application (with a different UI layer) works flawlessly on a Sony/Ericsson P900...

    Is this a bug in the 9500 OS? Or am I missing something? Any help is appreciated.

    -- arno

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    8
    I created a small test program to demonstrate the problem. You can download a zip file containing the sources, a package file and an installation file for the Nokia 9500 at:

    http://www.powerjuice.nl/NokiaTest.zip

    The core is the CNokiaTest class.
    Header:
    Code:
    // CNokiaTest.h
    // Test class for Nokia 9500 HTTP connection.
    
    #ifndef __CNOKIATEST_H
    #define __CNOKIATEST_H
    
    class CIdle;
    #include <http/rhttpsession.h>
    #include <http/mhttptransactioncallback.h>
    #include <http/mhttpdatasupplier.h>
    
    class CNokiaTest :
    	public CBase,
    	public MHTTPTransactionCallback,
    	public MHTTPDataSupplier
    
    {
    public:
    	static CNokiaTest* NewL();
    	~CNokiaTest();
    	
    	void StartL();
    	
    	static TInt IdleCallback(TAny *aPtr);
    	
    	// Implementation of MHTTPTransactionCallBack interface
    	void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
    	TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
    	
    	// Implementation of MHTTPDataSupplier interface
    	TBool GetNextDataPart(TPtrC8& aDataPart) { aDataPart.Set(KNullDesC8); return(ETrue); }
    	void ReleaseData() {}
    	TInt OverallDataSize() { return 0; }
    	TInt Reset() { return KErrNone; }
    	
    private:
    	CNokiaTest();
    	void ConstructL();
    
    	void StartHttpConnectionL();
    	TInt CheckConnection();
    	
    	CIdle* iIdle;
    	RHTTPSession iSession;
    	RHTTPTransaction iTransaction;
    	TBool iConnClosed;
    	TPtrC iMsgPtr;
    };
    
    #endif 	// #ifndef __CNOKIATEST_H
    And cpp file:
    Code:
    // CNokiaTest.cpp
    
    #include <e32base.h>
    #include <eikenv.h>
    #include <http/rhttpsession.h>
    #include <HttpStringConstants.h>
    #include <http/rhttpheaders.h>
    
    #include "CNokiaTest.h"
    
    _LIT(KConnIdle, "Idle");
    _LIT(KConnInit, "Initializing");
    _LIT(KConnConnecting, "Connecting");
    _LIT(KConnResponse, "Got response");
    _LIT(KConnResponseComplete, "Response complete");
    _LIT(KConnClosed, "Connection closed");
    _LIT(KConnFailed, "Connection failed");
    _LIT(KConnError, "Connection error");
    _LIT(KConnUnhandled, "Unhandled event");
    
    CNokiaTest::CNokiaTest() :
    	iIdle(NULL),
    	iConnClosed(EFalse),
    	iMsgPtr(KConnIdle)
    {
    }
    
    CNokiaTest::~CNokiaTest()
    {
    	delete iIdle;
    	iSession.Close();
    }
    
    CNokiaTest* CNokiaTest::NewL()
    {
    	CNokiaTest* result = new(ELeave) CNokiaTest();
    	CleanupStack::PushL(result);
    	result->ConstructL();
    	CleanupStack::Pop(result);
    	
    	return result;
    }
    
    void CNokiaTest::ConstructL()
    {
    	iIdle = CIdle::NewL(CActive::EPriorityIdle);
    	iSession.OpenL();
    }
    
    void CNokiaTest::StartL()
    {
    	// Start the HTTP connection; then start the idle AO.
    	StartHttpConnectionL();
    	
    	iIdle->Start(TCallBack(IdleCallback, this));
    }
    
    void CNokiaTest::StartHttpConnectionL()
    {
    	_LIT8(KUrl, "http://www.powerjuice.nl");
    	_LIT8(KContentType, "text/html");
    	
    	iConnClosed = EFalse;
    	iMsgPtr.Set(KConnInit);
    	
    	RStringPool string_pool = iSession.StringPool();
    	RStringF method = string_pool.StringF(HTTP::EPOST, RHTTPSession::GetTable());
    	TUriParser8 uri;
    	uri.Parse(KUrl);	
    	iTransaction = iSession.OpenTransactionL(uri, *this, method);
    	
    	RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
    	RStringF cont_type_str = string_pool.OpenFStringL(KContentType);
    	THTTPHdrVal cont_type(cont_type_str);
    	hdr.SetFieldL(string_pool.StringF(HTTP::EContentType,RHTTPSession::GetTable()), cont_type);
    	cont_type_str.Close();	
    
    	iTransaction.Request().SetBody(*this);
    	
    	iTransaction.SubmitL();
    	iMsgPtr.Set(KConnConnecting);
    }
    
    TInt CNokiaTest::IdleCallback(TAny *aPtr)
    {
    	CNokiaTest* test_obj = static_cast<CNokiaTest*>(aPtr);
    	return test_obj->CheckConnection();
    }
    
    TInt CNokiaTest::CheckConnection()
    {
    	TRAPD(err, CEikonEnv::Static()->BusyMsgL(iMsgPtr));
    	return (!iConnClosed);
    }
    
    void CNokiaTest::MHFRunL(RHTTPTransaction /* aTransaction */, const THTTPEvent& aEvent)
    {
    	switch (aEvent.iStatus)
    	{
    		case THTTPEvent::EGotResponseHeaders:
    		case THTTPEvent::EGotResponseBodyData:
    			iMsgPtr.Set(KConnResponse);
    		break;
    	
    		case THTTPEvent::EResponseComplete:
    			iMsgPtr.Set(KConnResponseComplete);
    		break;
    
    		case THTTPEvent::ESucceeded:
    			iMsgPtr.Set(KConnClosed);
    			iTransaction.Close();
    			iConnClosed = ETrue;
    		break;
    
    		case THTTPEvent::EFailed:
    			iMsgPtr.Set(KConnFailed);
    			iTransaction.Close();
    			iConnClosed = ETrue;
    		break;
    
    		default:
    		{
    			iMsgPtr.Set(KConnUnhandled);
    			// Stop the transaction handling in case of error
    			if (aEvent.iStatus < 0)
    			{
    				iTransaction.Close();
    				iConnClosed = ETrue;
    			}
    		}
    		break;
    	}
    }
    
    TInt CNokiaTest::MHFRunError(TInt /*aError*/, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/)
    {
    	iMsgPtr.Set(KConnError);
    	return KErrNone;
    }
    After making a connection, the display freezes for more than 20 seconds, which is enough for the View Server to panic.

    It should not freeze. This looks to be a bug in the HTTP server implementation on the Nokia 9500..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×