From 2e0dce343b43934b1e78f1516012ff659d0428e3 Mon Sep 17 00:00:00 2001 From: Denys Smirnov Date: Thu, 31 Jan 2019 15:02:54 +0200 Subject: [PATCH] always honor user-provided timeout, even if there is none set Signed-off-by: Denys Smirnov --- daemon/pool.go | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/daemon/pool.go b/daemon/pool.go index 86622f0..5db528c 100644 --- a/daemon/pool.go +++ b/daemon/pool.go @@ -18,12 +18,6 @@ import ( "gopkg.in/src-d/go-errors.v1" ) -const ( - // DefaultPoolTimeout is the time a request to the DriverPool can wait - // before getting a driver assigned. - DefaultPoolTimeout = 5 * time.Second -) - var ( // DefaultMaxInstancesPerDriver is the maximum number of instances of // the same driver which can be launched following the default @@ -190,9 +184,11 @@ type FunctionCtx func(ctx context.Context, d Driver) error // It gets a driver from the pool and forwards the request to it. If all drivers // are busy, it will return an error after the timeout passes. If the DriverPool // is closed, an error will be returned. +// +// Deprecated: use ExecuteCtx instead. func (dp *DriverPool) Execute(c FunctionCtx, timeout time.Duration) error { if timeout == 0 { - timeout = DefaultPoolTimeout + timeout = 5 * time.Second } ctx, cancel := context.WithTimeout(context.Background(), timeout) @@ -209,12 +205,6 @@ func (dp *DriverPool) ExecuteCtx(rctx context.Context, c FunctionCtx) error { sp, ctx := opentracing.StartSpanFromContext(rctx, "bblfshd.pool.Execute") defer sp.Finish() - if _, ok := ctx.Deadline(); !ok { - var cancel func() - ctx, cancel = context.WithTimeout(ctx, DefaultPoolTimeout) - defer cancel() - } - d, err := dp.getDriver(ctx) if err != nil { return err @@ -333,10 +323,6 @@ func (q *driverQueue) Get() (driver Driver, more bool) { } func (q *driverQueue) GetWithContext(ctx context.Context) (driver Driver, more bool, err error) { - if _, ok := ctx.Deadline(); !ok { - return nil, true, ErrInvalidPoolTimeout.New(time.Duration(0)) - } - select { case d, more := <-q.c: q.n.Add(-1)