When the application only uses RHTTPSession and RHTTPTransaction for HTTP operations, the panic of CONE 36 is generated after the program on the simulator exits, the corresponding description "Open handles were found during application shutdown" can be found through the SDK. That is to say, when the program exits, there are still system resources not released (R class). What is the cause of the problem? The entire process of the analysis program shows that the application first submits the first request through RHTTPTransaction: SubmitL (), and the system displays the Access Point Selection dialog box, after we select an access point, the system starts the initial connection of our application to establish the network. In fact, this process is completed through RConnection: Start, after the connection is established, it is associated with the application, and our program does not explicitly Close the connection through RConnection: Close () when exiting, this causes the panic CONE 36 to be generated because the resources are not released. There are two solutions: 1. Our program creates a connection through RConnection and closes the connection when the program exits: Class CHTTPEngine: public CBase, Public MHTTPTransactionCallback, Public MHTTPDataSupplier, Public MHTTPAuthenticationCallback { ....................... Private: ....................... RSocketServ iSocketServ; RConnection iConnection; RHTTPSession iSession; RHTTPTransaction iTransaction; } // To facilitate code demonstration, synchronous connection is used. Void CHTTPEngine: ConnectL () { ISocketServ. Connect (); IConnection. Open (iSocketServ ); IConnection. Start (); User: WaitForRequest (status); // wait for connecting User: LeaveIfError (status. Int ()); ISession. OpenL () RHTTPConnectionInfo connInfo = iSession. ConnectionInfo (); RStringPool pool = iSession. StringPool (); // Set the connection for the HTTP session ConnInfo. SetPropertyL (pool. StringF (HTTP: EHttpSocketServ, RHTTPSession: GetTable (), THTTPHdrVal (iSocketServ. Handle ())); TInt connPtr = REINTERPRET_CAST (TInt, & iConnection ); ConnInfo. SetPropertyL (pool. StringF (HTTP: EHttpSocketConnection, RHTTPSession: GetTable (), THTTPHdrVal (connPtr )); } CHTTPEngine ::~ CHTTPEngine () { ........................ IConnection. Close (); ISocketServ. Close (); ISession. Close (); .................... } 2. Get the associated object at exit without using the additional RSocketServ and RConnection, and then close the connection: CHTTPEngine ::~ CHTTPEngine () { RHTTPConnectionInfo connInfo = iSession. ConnectionInfo (); RStringPool pool = iSession. StringPool (); // Sets the reverse operation for the HTTP session THTTPHdrVal val; TBool ret = connInfo. Property (pool. StringF (HTTP: EHttpSocketServ, RHTTPSession: GetTable (), val ); RSocketServ socketServ; RConnection * connection = NULL; If (ret) { SocketServ. SetHandle (val. Int ()); Ret = connInfo. Property (pool. StringF (HTTP: EHttpSocketConnection, RHTTPSession: GetTable (), val ); If (ret) { Connection = REINTERPRET_CAST (RConnection *, val. Int ()); } If (connection) { Connection-> Close (); } SocketServ. Close (); } ISession. Close (); .................... } The first method is to establish a connection by yourself. The asynchronous mechanism is usually used to increase the complexity of the program. However, you can use another version of RConnection: Start () to Start (TConnPref & aPref, TRequestStatus & aStatus) in the hide Access Point Selection dialog box, set the Access Point by yourself. The second method is suitable for applications that do not care about access points without additional operations. |