void Invocation_popInvocation(bool wasException) { CallLocal* cl; Invocation* ctx = currentInvocation->previous; if(currentInvocation->invocation != 0) { if(!wasException) JNI_callVoidMethod(currentInvocation->invocation, s_Invocation_onExit); JNI_deleteGlobalRef(currentInvocation->invocation); } /* * Check for any DualState objects that became unreachable and can be freed. */ pljava_DualState_cleanEnqueuedInstances(); if(currentInvocation->hasConnected) SPI_finish(); JNI_popLocalFrame(0); if(ctx != 0) { PG_TRY(); { Backend_setJavaSecurity(ctx->trusted); } PG_CATCH(); { elog(FATAL, "Failed to reinstate untrusted security after a trusted call or vice versa"); } PG_END_TRY(); MemoryContextSwitchTo(ctx->upperContext); } /** * Reset all local wrappers that has been allocated during this call. Yank them * from the double linked list but do *not* remove them. */ cl = currentInvocation->callLocals; if(cl != 0) { CallLocal* first = cl; do { cl->pointer = 0; cl->invocation = 0; cl = cl->next; } while(cl != first); } currentInvocation = ctx; --s_callLevel; }
void Invocation_pushInvocation(Invocation* ctx, bool trusted) { JNI_pushLocalFrame(LOCAL_FRAME_SIZE); ctx->invocation = 0; ctx->function = 0; ctx->trusted = trusted; ctx->hasConnected = false; ctx->upperContext = CurrentMemoryContext; ctx->errorOccured = false; ctx->inExprContextCB = false; ctx->previous = currentInvocation; ctx->callLocals = 0; currentInvocation = ctx; Backend_setJavaSecurity(trusted); ++s_callLevel; }