×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    53

    Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    Hi,
    My code ia as follows

    Code:
    void CTRM_SymbianClientEngine::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent)
    	{
    	switch(aEvent.iStatus)
    		{
    
    		case THTTPEvent::EGotResponseHeaders:
    			{
    			_LIT(KA13,"Response text from MHFRunL->EGotResponseHeaders");
    							((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA13);
    	        RHTTPResponse resp = aTransaction.Response();
    			TBuf<30> buf;
    			buf.Copy(resp.StatusText().DesC());
    			((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(buf);
    			}
    			break;
    		case THTTPEvent::EGotResponseBodyData:
    			{
    			_LIT(KA14,"Response text from MHFRunL->EGotResponseBodyData");
    										((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA14);
    				 MHTTPDataSupplier* body=aTransaction.Response().Body();
    				 TPtrC8 dataChunk;
    				 
    				 TBool isLast=body->GetNextDataPart(dataChunk);
    				 
    				 TInt aPos=0;
    				 
    				
    				 
    				 if(iMhfState==0)
    					 {
    					 _LIT(KA15,"before seek  iMhfState==0");
    					 ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA15);
    					 iRLbsImage.Seek(ESeekCurrent,aPos);
    					 _LIT(KK," before write");
    					((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KK);
    					 iRLbsImage.Write(dataChunk);
    					 _LIT(KA17,"after write");
    	    			((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA17);
    					 }
    				 if(iMhfState==1)
    				 	 {
    				 	
    				 	 if(dataChunk.Length())
    				 		 {
    				 	 //iRLbsImage.Seek(ESeekStart,0);
    				 	 _LIT(KK," before write iMhfState==1");
    				 	((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KK);
    				 	iRLbsImage.Write(0,dataChunk);
    				 	 _LIT(KA17,"after write");
    					((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA17);
    				 	 iMhfState=0;
    				 		 }
    				 	 else
    				 		 {
    				 		_LIT(RR," empty datachunk");
    				 		((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(RR);
    				 		 }
    				 	 }
    				
    				 
    				 body->ReleaseData();
    				 
    			}
    			break;
    		case THTTPEvent::EResponseComplete:
    			{
    			_LIT(KA15,"Response text from MHFRunL->EResponseComplete");
    													((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA15);
    			}
    			break;
    		case THTTPEvent::ESucceeded:
    			{
    			_LIT(KA16,"Response text from MHFRunL->ESucceeded");
    													((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA16);
    			aTransaction.Close();
    			TInt er=iRLbsImage.Flush();
    			if(er==KErrNone)
    				{
    				_LIT(RR1," No err in flushig file");
    								 		((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(RR1);
    				}
    			else
    				{
    				_LIT(RR2,"err in flushing file");
    								 		((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(RR2);
    				}
    			iRLbsImage.Close();	
    			iMhfState=1;
    			//set image
    
    			CTRM_SymbianReadImageFromRFileConvertToBitmap* iImgConverter=CTRM_SymbianReadImageFromRFileConvertToBitmap::NewL();
    			iAppView->SetImgConverter(iImgConverter);
    			iImgConverter->ConvertFileToBitMap(KTxtFileName);//pass file name
    			}
    			break;
    		case THTTPEvent::EFailed:
    			{
    			_LIT(KA17,"Response text from MHFRunL->EFailed");
    													((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA17);
    													//((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA16);
    						aTransaction.Close();
    			}
    			break;
    		default:
    			{
    			_LIT(KA18,"Response text from MHFRunL->default");
    													((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA18);
    			if(aEvent.iStatus<0)
    				{
    				aTransaction.Close();
    				}
    			else
    				{
    				// Other events are not errors (e.g. permanent and temporary
    				    		          // redirections)
    				}
    			}
    			break;		
    }
    	}
    where iRLbsimage is a RFile obj....

    and its implementation is as follows
    Code:
    void CTRM_SymbianClientEngine::PrepareFileToReceiveGpsImage()
    	{
    	_LIT(KXMLFilePath,"c:\\Data\\Images");
    	TFileName aGpsImage;
    	aGpsImage.Append(KXMLFilePath);
    	aGpsImage.Append(_L("\\LbsSample.jpg"));
    	TInt i=CCoeEnv::Static()->FsSession().Delete(KXMLFilePath);
    	TInt err=iRLbsImage.Replace(CCoeEnv::Static()->FsSession(),aGpsImage,EFileWrite);
    	if(err==KErrNotFound)//file does not exist - create it
    		{
    		err=iRLbsImage.Create(CCoeEnv::Static()->FsSession(),aGpsImage,EFileWrite);
    
    		if(err!=KErrNone)
    			{
    			_LIT(KGpsFileNtCreated,"Gps File is not created");
    			((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KGpsFileNtCreated);
    			}
    		}
    	}
    Here I guess The reason for crash is as --------
    ------------------------------------------------
    the "aPos" argument of iRLbsImage.Seek function always points to the last position of the file accessed.

    So, in 1 st http request it works fine.
    But in case of 2nd one, the APos is required to have value zero. But I guess it actually acquires a value that was the previous position to which it wrote. And starting to write with this value of aPos, the value of aPos soon crosses the max value(that is the allowable size of file). So it crashes. Whether or not the app crashes, my right requirement is that the value of aPos should be zero at this point.

    Now I guess, using seek() may not be right issue for me..
    Then what function should I select.

    As per my requirements
    --------------------------
    The socket downloads images.
    each image comes in 4 parts---
    with 4 successive calls to

    Code:
               case THTTPEvent::EGotResponseBodyData:
               body->GetNextDataPart(dataChunk);
               body->ReleaseData();
    and finally a call to
    Code:
                case THTTPEvent::EResponseComplete:
                 where the image download completes.
    Last edited by sanee; 2008-11-03 at 07:05.

  2. #2
    Nokia Developer Champion
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    KERN-EXEC 0
    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 (the raw handle number).

    so maybe use close RFs, RFile, RSocket, RSocketServ handle, but your code use this handle again.
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  3. #3
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    53

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    here in my code RFile object is used....

    I think it is opened properly and closed properly.

    But there is this error......

    can I check programatically, if it points to something valid..

    Regards!

  4. #4
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    53

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    ok,
    Rfile.replace() is not working...

    in ist request it returns error code 0.
    In 2nd request it returns error code
    -14

    also....

    RFS:: Delete() returns error code -21 every time..


    What are the meaning of theses codes...
    Last edited by sanee; 2008-11-03 at 07:28.

  5. #5
    Nokia Developer Champion
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    -14 means KErrInUse, so the file opened by other app or your app other code.
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  6. #6
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    53

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    -21 means access denied..
    So, there is no access to delete the file using RFS::delete()

    and
    -14 means the file is in use..
    So, RFile:: Replace does not work..

    But prior to calling these , I have
    made a call to
    Rfile:: close()..

    But still I get these errors.
    Why?
    And how to solve?

  7. #7
    Nokia Developer Champion
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    RFS:: Delete() is delete a single file.
    but your code is TInt i=CCoeEnv::Static()->FsSession().Delete(KXMLFilePath);

    KXMLFilePath is path not a file.

    It is your mean what want delete this path?
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  8. #8
    Nokia Developer Champion
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    Quote Originally Posted by sanee View Post
    -21 means access denied..
    So, there is no access to delete the file using RFS::delete()

    and
    -14 means the file is in use..
    So, RFile:: Replace does not work..

    But prior to calling these , I have
    made a call to
    Rfile:: close()..

    But still I get these errors.
    Why?
    And how to solve?
    so you can try RFile::Open(CCoeEnv::Static()->FsSession(),aGpsImage, EFileWrite);

    if have any error, so the file opened by other code, you need log the file open and close number.
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  9. #9
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    53

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    sorry I could not get what u mean to write....
    Plz be simpler in words.
    of course RFile:: open() was not working....
    when I tried earlier....

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,566

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    It is hard to believe that you have not been provided this link http://wiki.forum.nokia.com/index.php/Error_codes earlier.
    I think the two error codes are coming for the same reason: KErrInUse comes because the file is already in use, KErrAccessDenied comes because you can not delete a file which is opened.
    Note that your file is getting closed only if the transaction ends with success. If it fails, the file is not going to be closed.

  11. #11
    Nokia Developer Champion
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    Quote Originally Posted by sanee View Post
    sorry I could not get what u mean to write....
    Plz be simpler in words.
    of course RFile:: open() was not working....
    when I tried earlier....
    so your problem is RFile::Replace not work. because other code open the file.

    1st, you need check it is open by the app or other app. you can use ActiveFile or Y-Browser do this work.

    close your app, and use file browser delete the file, if can delete, it is open by the app's other code.

    otherwise, it is open by other app. find it.
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  12. #12
    Nokia Developer Champion
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    2nd, if can delete the file, so check all code that called PrepareFileToReceiveGpsImage. or all code that open "LbsSample.jpg"'s RFile handle. check open and cose is matching...
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  13. #13
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    53

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    ok,
    I got that issue solved.....

    I had used all RFile::Close() properly.
    Then i thought Tha i pass the pathname of file to
    ImageDecoder.....

    Its closing was done in the destructor...

    I thought probably it may have the instance of RFile...

    So
    I delete the instance of imageDecoder in the RunL(), after
    doing all the work.....

    and now the application is ok with multiple requests to socket...


    But a new problem came.. Kern Exec 3.

    That ios NULL pOInter exception...
    While Trying to close the app.....

    This was not there till yesterday.....

    Huh, I may have introduced something....

    Anyway What is "Y-Browser" and "Active File"
    Are those sis files..

  14. #14
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    53

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    and this occurs only if i fetch data from socket
    and while closing ,
    kern exec 3 panic is there.......

  15. #15
    Nokia Developer Champion
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: Rfile and saving image file received in MHFRunL() of socket.. kern exec 0 panic

    Y-Browser, ActiveFile is s60 third parth file browser. It is more powerful.
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

Posting Permissions

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