Don't lose packets writen during upgrade after a re-open

After a close, reset the prevBufferLen along with the buffers,
so a drain event after upgrade won't remove any packets that have been
queued up during upgrading.
Merge pull request #179 from jbowes/dont-lose-packets-after-close

Don't lose packets writen during upgrade after a re-open