mozilla-services/heka — pull request #334 by benmmurphy (2013-07-17 15:59:24+00:00)
Title: fix memory and socket leak in carbon output

defer functions only run at the end of the function. if you have loop that reads from channel and creates defer in each loop iteration then you will leak memory for every function it saves and the connection won't be closed until the channel is closed which is probably never.

so i just moved the contents of the loop inside of the function. sadly the diff is not very intelligent :( the only thing that i think is different is that the loop no longer updates the err return variable. seeing as the err return variable could be overwritten by a successful iteration of the loop i don't think this is a problem.