Skip to content

worker: release messages without defer#167

Open
ddevault wants to merge 1 commit into
gocelery:masterfrom
ddevault:master
Open

worker: release messages without defer#167
ddevault wants to merge 1 commit into
gocelery:masterfrom
ddevault:master

Conversation

@ddevault
Copy link
Copy Markdown

@ddevault ddevault commented Mar 1, 2021

defer causes the function calls to occur at the termination of the
function, rather than at the end of the current block. This causes
defers within a loop to build up a large list of calls in memory and
doesn't run them until the worker terminates, causing a memory leak.

This also fixes a nil pointer dereference when the result is nil - for
example, if runTaskFunc's taskFunc.Call calls a worker function with no
return value.

defer causes the function calls to occur at the termination of the
function, rather than at the end of the current block. This causes
defers within a loop to build up a large list of calls in memory and
doesn't run them until the worker terminates, causing a memory leak.

This also fixes a nil pointer dereference when the result is nil - for
example, if runTaskFunc's taskFunc.Call calls a worker function with no
return value.
@ddevault
Copy link
Copy Markdown
Author

ddevault commented Mar 1, 2021

The lint error appears to be unrelated to my change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant