Exemple #1
0
/*
 *	AbortOutOfAnyTransaction
 *
 *	This routine is provided for error recovery purposes.  It aborts any
 *	active transaction or transaction block, leaving the system in a known
 *	idle state.
 */
void
AbortOutOfAnyTransaction(void)
{
	TransactionState s = CurrentTransactionState;

	/*
	 * Get out of any low-level transaction
	 */
	switch (s->state)
	{
		case TRANS_START:
		case TRANS_INPROGRESS:
		case TRANS_COMMIT:
			/* In a transaction, so clean up */
			AbortTransaction();
			CleanupTransaction();
			break;
		case TRANS_ABORT:
			/* AbortTransaction already done, still need Cleanup */
			CleanupTransaction();
			break;
		case TRANS_DEFAULT:
			/* Not in a transaction, do nothing */
			break;
	}

	/*
	 * Now reset the high-level state
	 */
	s->blockState = TBLOCK_DEFAULT;
}
// ----------------------------------------------------------------------------
// CWmDrmDlaDefaultHttpManager::HandleDownloadComplete
// Close HTTP connection and clean up instance variables.
//
// Must be called to complete client's request and cleanup, either on
// successful download, or some error condition
// ----------------------------------------------------------------------------
void CWmDrmDlaDefaultHttpManager::HandleDownloadComplete( TInt aError )
    {
    LOGFN( "CWmDrmDlaDefaultHttpManager::HandleDownloadComplete" );
    LOG2( "aError: %d", aError );
    CleanupTransaction();

    iInCallback = ETrue;
    iObserver.OnTransactionComplete( aError );
    iInCallback = EFalse;

    if ( iDataSupplier )
        {
        iDataSupplier->ReleaseData();
        iDataSupplier = NULL;
        }
    }
// ----------------------------------------------------------------------------
// CWmDrmDlaDefaultHttpManager::DoStartL
// ----------------------------------------------------------------------------
void CWmDrmDlaDefaultHttpManager::DoStartL(
    const TDesC8& aUrl,
    const RArray<CWmDrmDlaDefaultHttpManager::THeader>& aHeaders )
    {
    LOGFN( "CWmDrmDlaDefaultHttpManager::DoStartL" );
    CleanupTransaction();

    // Store callers URL
    iSrcAddress = aUrl.AllocL();

    // Store headers
    TInt nofheaders = aHeaders.Count();
    for ( TInt i = 0; i < nofheaders; i++ )
        {
        iHdrFields.AppendL( aHeaders[i].iField );
        iHdrValues.AppendL( aHeaders[i].iVal.AllocL() );
        }

    if ( (iState == EOpen) && iKeepAlive )
        {
        TConnectionInfo connectionInfo;
        TRAPD(err, GetConnectionInfoL(connectionInfo) );
        if ( err || ( connectionInfo.iIapId != iIapNumber &&
             iIapNumber != 0 && connectionInfo.iIapId != 0 ) )
            {
            CleanupConnection();
            iState = EStart;
            }
        }
    else
        {
        iState = EConstructed == iState ? EStart : EOpen;
        }

    iError = KErrNone;
    iCredentialsOk = ETrue;

    CompleteSelf();
    }
Exemple #4
0
/*
 *	AbortCurrentTransaction
 */
void
AbortCurrentTransaction(void)
{
	TransactionState s = CurrentTransactionState;

	switch (s->blockState)
	{
			/*
			 * if we aren't in a transaction block, we just do the basic
			 * abort & cleanup transaction.
			 */
		case TBLOCK_DEFAULT:
			AbortTransaction();
			CleanupTransaction();
			break;

			/*
			 * If we are in the TBLOCK_BEGIN it means something screwed up
			 * right after reading "BEGIN TRANSACTION" so we enter the
			 * abort state.  Eventually an "END TRANSACTION" will fix
			 * things.
			 */
		case TBLOCK_BEGIN:
			s->blockState = TBLOCK_ABORT;
			AbortTransaction();
			/* CleanupTransaction happens when we exit TBLOCK_ABORT */
			break;

			/*
			 * This is the case when are somewhere in a transaction block
			 * which aborted so we abort the transaction and set the ABORT
			 * state.  Eventually an "END TRANSACTION" will fix things and
			 * restore us to a normal state.
			 */
		case TBLOCK_INPROGRESS:
			s->blockState = TBLOCK_ABORT;
			AbortTransaction();
			/* CleanupTransaction happens when we exit TBLOCK_ABORT */
			break;

			/*
			 * Here, the system was fouled up just after the user wanted
			 * to end the transaction block so we abort the transaction
			 * and put us back into the default state.
			 */
		case TBLOCK_END:
			s->blockState = TBLOCK_DEFAULT;
			AbortTransaction();
			CleanupTransaction();
			break;

			/*
			 * Here, we are already in an aborted transaction state and
			 * are waiting for an "END TRANSACTION" to come along and lo
			 * and behold, we abort again! So we just remain in the abort
			 * state.
			 */
		case TBLOCK_ABORT:
			break;

			/*
			 * Here we were in an aborted transaction block which just
			 * processed the "END TRANSACTION" command but somehow aborted
			 * again.. since we must have done the abort processing, we
			 * clean up and return to the default state.
			 */
		case TBLOCK_ENDABORT:
			CleanupTransaction();
			s->blockState = TBLOCK_DEFAULT;
			break;
	}
}
Exemple #5
0
/*
 *	CommitTransactionCommand
 */
void
CommitTransactionCommand(void)
{
	TransactionState s = CurrentTransactionState;

	switch (s->blockState)
	{
			/*
			 * If we aren't in a transaction block, just do our usual
			 * transaction commit.
			 */
		case TBLOCK_DEFAULT:
			CommitTransaction();
			break;

			/*
			 * This is the case right after we get a "BEGIN TRANSACTION"
			 * command, but the user hasn't done anything else yet, so we
			 * change to the "transaction block in progress" state and
			 * return.
			 */
		case TBLOCK_BEGIN:
			s->blockState = TBLOCK_INPROGRESS;
			break;

			/*
			 * This is the case when we have finished executing a command
			 * someplace within a transaction block.  We increment the
			 * command counter and return.
			 */
		case TBLOCK_INPROGRESS:
			CommandCounterIncrement();
			break;

			/*
			 * This is the case when we just got the "END TRANSACTION"
			 * statement, so we commit the transaction and go back to the
			 * default state.
			 */
		case TBLOCK_END:
			CommitTransaction();
			s->blockState = TBLOCK_DEFAULT;
			break;

			/*
			 * Here we are in the middle of a transaction block but one of
			 * the commands caused an abort so we do nothing but remain in
			 * the abort state.  Eventually we will get to the "END
			 * TRANSACTION" which will set things straight.
			 */
		case TBLOCK_ABORT:
			break;

			/*
			 * Here we were in an aborted transaction block which just
			 * processed the "END TRANSACTION" command from the user, so
			 * clean up and return to the default state.
			 */
		case TBLOCK_ENDABORT:
			CleanupTransaction();
			s->blockState = TBLOCK_DEFAULT;
			break;
	}
}