tls: proper .destroySoon
authorFedor Indutny <fedor.indutny@gmail.com>
Thu, 30 May 2013 09:35:24 +0000 (13:35 +0400)
committerFedor Indutny <fedor.indutny@gmail.com>
Thu, 30 May 2013 09:50:13 +0000 (13:50 +0400)
commit9ee86b718c8079474b2647385404042fd94fd116
treeaf7eb520f8ba02119122cc8b031cfb17f378a1a4
parent9826b1549396ed05011d523ab5bf7a344b8cb8b6
tls: proper .destroySoon

1. Emit `sslOutEnd` only when `_internallyPendingBytes() === 0`.
2. Read before checking `._halfRead`, otherwise we'll see only previous
   value, and will invoke `._write` callback improperly.
3. Wait for both `end` and `finish` events in `.destroySoon`.
4. Unpipe encrypted stream from socket to prevent write after destroy.
lib/tls.js