You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/06/16 19:45:01 UTC
[plc4x] 03/05: fix(plc4go/spi): avoid shutting down the shared executor
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 0784d3786f066b61c4a637f2d0063faf017971b6
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Jun 16 21:16:26 2023 +0200
fix(plc4go/spi): avoid shutting down the shared executor
---
plc4go/spi/transactions/RequestTransactionManager.go | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/plc4go/spi/transactions/RequestTransactionManager.go b/plc4go/spi/transactions/RequestTransactionManager.go
index e1ffd98ed2..786541d37d 100644
--- a/plc4go/spi/transactions/RequestTransactionManager.go
+++ b/plc4go/spi/transactions/RequestTransactionManager.go
@@ -41,6 +41,9 @@ var sharedExecutorInstance pool.Executor // shared instance
func init() {
sharedExecutorInstance = pool.NewFixedSizeExecutor(runtime.NumCPU(), 100, pool.WithExecutorOptionTracerWorkers(config.TraceTransactionManagerWorkers))
sharedExecutorInstance.Start()
+ runtime.SetFinalizer(sharedExecutorInstance, func(sharedExecutorInstance pool.Executor) {
+ sharedExecutorInstance.Stop()
+ })
}
type RequestTransactionRunnable func(RequestTransaction)
@@ -258,8 +261,12 @@ func (r *requestTransactionManager) CloseGraceful(timeout time.Duration) error {
r.runningRequestMutex.Lock()
defer r.runningRequestMutex.Unlock()
r.runningRequests = nil
- if err := r.executor.Close(); err != nil {
- return errors.Wrap(err, "error closing executor")
+ if r.executor != sharedExecutorInstance {
+ if err := r.executor.Close(); err != nil {
+ return errors.Wrap(err, "error closing executor")
+ }
+ } else {
+ r.log.Warn().Msg("not closing shared instance")
}
return nil
}