Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User badzio's Avatar
    Join Date
    Jun 2008
    Location
    Poland
    Posts
    60
    Hi,

    I've following classess:
    class CMyHttp: public CBase, public MHTTPDataSupplier, public MHTTPAuthenticationCallback
    class CMyNet: public CActive, public MHttpObserver
    class CMyHttpHandler: public CBase, public MHTTPTransactionCallback
    where MHttpObserver is my interface.
    object of CMyHttp is created in CMyNet class, I passed CMyNet object to CMyHttp, each event MHTTPTransactionCallback::MHFRunL call some function from CMyNet/MHttpObserver.
    CMyNet is active object with own, separated thread.
    What I do is:
    1) from main application thread I complete CMyNet::iStatus
    2) in RunL (it works in separated thread) I create CMyHttp object. CMyHttp creates RHTTPSession and RHTTPTransaction, opens session, sends http request RHTTPTransaction::SubmitL()
    3) server answers very slowly (no idea why, it doesn't matter), I'd wait about 2minutes than I get correct http response
    4) I don't want wait so long, so I cancel operation. From main thread I call CMyNet::Cancel().
    5) In CMyNet:oCancel() I delete CMyHttp.
    6) In CHttpConnection::~CHttpConnection I close RHTTPSession and delete RHTTPTransaction. But RHTTPSession::Close() causes panic KERN-EXEC 0.
    Of course, if I wait till http response and after that close RHTTPSession than it works fine. Problem is only in mentioned case - if RHTTPSession::Close() is called between RHTTPTransaction::SubmitL and http respond.
    What do I do wrong? Any idea?

    PS I'm talking about S60 FP1, emulator and device
    Last edited by badzio; 2009-05-20 at 20:51. Reason: add platform

  2. #2
    Registered User badzio's Avatar
    Join Date
    Jun 2008
    Location
    Poland
    Posts
    60
    Something more...
    I wait for http response. In MHttpTransactionCallback::MHFRunL I check aEvent.iStatus, if it's equal THTTPEvent::EGotResponseBodyData I analyze response and decide to break transaction. than I call RHttpTransaction.Close() and from CMyNet delete CMyHttp. Destructor is called, then RHttpSession.Close() is called and application hangt, nothing happens. No crash, no panic, no error, just nothing

  3. #3
    Regular Contributor keerthi.ck06's Avatar
    Join Date
    Dec 2008
    Location
    Bangalore
    Posts
    174
    try to close all these then http transaction will close
    RHTTPSession::Close(),RConnection::Close(),RSocketServ::Close().

  4. #4
    Registered User badzio's Avatar
    Join Date
    Jun 2008
    Location
    Poland
    Posts
    60
    I tried. But as I wrote - RHttpSession::Close() causes panic kern-exec 0

  5. #5
    Super Contributor kishore84's Avatar
    Join Date
    Jul 2007
    Posts
    596
    Quote Originally Posted by badzio View Post
    I tried. But as I wrote - RHttpSession::Close() causes panic kern-exec 0
    To cancel a trasaction cancel RHTTPTransaction object i.e RHTTPTransaction close
    is sufficient.

    Also show me the exact code (I want the closing sequence )how u r caceling the request.

  6. #6
    Registered User badzio's Avatar
    Join Date
    Jun 2008
    Location
    Poland
    Posts
    60
    Code:
    class CMyHttp: public CBase, public MHTTPDataSupplier, public MHTTPAuthenticationCallback
    {
    	MHttpObserver iObserver;
    	CMyHttpHandler* iHttpHandler;
    	RHTTPSession iSession;
    	RHTTPTransaction iTransaction;
    }
    
    class CMyNet: public CActive, public MHttpObserver
    {
    	CMyNet& iHttp;
    	CMyHttp* iThis;
    	public:
    	static CancelProcess();
    }
    
    class CMyHttpHandler: public CBase, public MHTTPTransactionCallback
    {
    }
    
    CMyHttp::~CMyHttp()
    {
    	iSession.Close(); //<- this line causes panic in main thread
    	delete iTransaction;
    	iTransaction = NULL;
    }
    
    // please remember that CMyNet has own, separated thread, runl is running this separated thread, CActiveScheduler has been also started in this thread
    CMyNet::RunL()
    {
    	switch (iStatus.Int())
    	{
    	case X:
    		iHttp = new CMyHttp(*this);
    		iHttp->Start();
    		iStatus = KRequestPending;
    		SetActive();
    	break;
    	}
    }
    
    //this function is called from main thread
    CMyNet::CancelProcess()
    {
    	iThis->Cancel();
    }
    
    CMyNet::DoCancel()
    {
    	delete iHttp;
    	iHttp = NULL;
    }
    Problem occurs only in one case - CMyNet::CancelProcess() is called between iTransaction.SumbitL() and response from server

  7. #7
    Super Contributor kishore84's Avatar
    Join Date
    Jul 2007
    Posts
    596
    Just try like below
    Code:
    CMyHttp::~CMyHttp()
    {
            iTransaction.Close();
    	iSession.Close(); //<- this line causes panic in main thread
    }
    Also ur code does not look very good. u don't need to delete ur entire sesiion while caneling a transaction.

    here is a nice exp u can check
    http://www.forum.nokia.com/info/sw.n...I_Example.html
    Last edited by kishore84; 2009-05-21 at 12:19.

  8. #8
    Registered User badzio's Avatar
    Join Date
    Jun 2008
    Location
    Poland
    Posts
    60
    I'm doing this similar way like in example.
    I've found the reason of kern-exec 0. My application has 2 threads - main thread A and separated thread B. RunL is running in thread B. But when I call Cancel() from thread A than DoCancel is running also in thread A, not B.

  9. #9
    Super Contributor kishore84's Avatar
    Join Date
    Jul 2007
    Posts
    596
    Quote Originally Posted by badzio View Post
    I'm doing this similar way like in example.
    I've found the reason of kern-exec 0. My application has 2 threads - main thread A and separated thread B. RunL is running in thread B. But when I call Cancel() from thread A than DoCancel is running also in thread A, not B.
    woh i c !!any way have u seen the reason of kwernexec 0
    Code:
    This panic is raised when the Kernel cannot find an object in the object index for the current process or current thread using the specified object index number .
    See in this type of implementation as mentioned by u there are a lot of possibilities of pbs u may get into . Normal thing is the active object of different threads can't share resouces bet them. So u may submit ur transaction in one thread and I am wondering how ur 2nd thread's active object get notified to the events ?????

  10. #10
    Registered User badzio's Avatar
    Join Date
    Jun 2008
    Location
    Poland
    Posts
    60
    Now I don't call Cancel(), just request iStatus with KErrCancel and process that in runl. but if I cancel operation before establishing connection than panic e32user-cbase 46.
    rhttpsession is opened and installed but rconnection wasn't started. next I cancel operation, rhttpsession is close (rconnection isn't stopped because didn't start). when application exits runl than e32user-cbase 46 is raised
    BTW normally I don't try to share variables between threads. the only are static variables. communication between threads is via requeststatus or rmessage

Similar Threads

  1. IO exception in HTTP operation
    By J2me_champ in forum Mobile Java General
    Replies: 7
    Last Post: 2009-10-12, 17:56
  2. How to cancel a http request
    By deepakk in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2008-10-15, 09:42
  3. Error in HTTP operation
    By fethy in forum Mobile Java General
    Replies: 10
    Last Post: 2007-08-30, 11:53
  4. How to cancel a http connection mid-way
    By capricious28 in forum Mobile Java General
    Replies: 0
    Last Post: 2007-08-10, 10:42
  5. how to abort or cancel a http connection
    By yavour in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2007-01-17, 20:26

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved