endpoint: factor out code which locks endpoint before compilation into function
endpoint: factor out code which locks endpoint before compilation into function

In this function, we can defer the unlocking of the endpoint's mutex.

Signed-off by: Ian Vernon <ian@cilium.io>

scanf/cilium,scanf/cilium,cilium/cilium,tgraf/cilium,tklauser/cilium,tklauser/cilium,tgraf/cilium,scanf/cilium,cilium-team/cilium,michi-covalent/cilium,tgraf/cilium,scanf/cilium,cilium/cilium,tgraf/cilium,tklauser/cilium,scanf/cilium,scanf/cilium,tklauser/cilium,michi-covalent/cilium,michi-covalent/cilium,cilium/cilium,tklauser/cilium,cilium-team/cilium,michi-covalent/cilium,cilium/cilium,michi-covalent/cilium,tgraf/cilium,scanf/cilium,tgraf/cilium,cilium/cilium