mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
Avoid some other O(N^2) hazards in list manipulation.
In the same spirit as 6301c3ada
, fix some more places where we were
using list_delete_first() in a loop and thereby risking O(N^2)
behavior. It's not clear that the lists manipulated in these spots
can get long enough to be really problematic ... but it's not clear
that they can't, either, and the fixes are simple enough.
As before, back-patch to v13.
Discussion: https://postgr.es/m/CD2F0E7F-9822-45EC-A411-AE56F14DEA9F@amazon.com
This commit is contained in:
@ -171,6 +171,7 @@ static void
|
||||
llvm_release_context(JitContext *context)
|
||||
{
|
||||
LLVMJitContext *llvm_context = (LLVMJitContext *) context;
|
||||
ListCell *lc;
|
||||
|
||||
/*
|
||||
* When this backend is exiting, don't clean up LLVM. As an error might
|
||||
@ -188,12 +189,9 @@ llvm_release_context(JitContext *context)
|
||||
llvm_context->module = NULL;
|
||||
}
|
||||
|
||||
while (llvm_context->handles != NIL)
|
||||
foreach(lc, llvm_context->handles)
|
||||
{
|
||||
LLVMJitHandle *jit_handle;
|
||||
|
||||
jit_handle = (LLVMJitHandle *) linitial(llvm_context->handles);
|
||||
llvm_context->handles = list_delete_first(llvm_context->handles);
|
||||
LLVMJitHandle *jit_handle = (LLVMJitHandle *) lfirst(lc);
|
||||
|
||||
#if LLVM_VERSION_MAJOR > 11
|
||||
{
|
||||
@ -221,6 +219,8 @@ llvm_release_context(JitContext *context)
|
||||
|
||||
pfree(jit_handle);
|
||||
}
|
||||
list_free(llvm_context->handles);
|
||||
llvm_context->handles = NIL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user