(session, error)
| 1193 | } |
| 1194 | |
| 1195 | function finishSessionClose(session, error) { |
| 1196 | debugSessionObj(session, 'finishSessionClose'); |
| 1197 | |
| 1198 | const socket = session[kSocket]; |
| 1199 | cleanupSession(session); |
| 1200 | |
| 1201 | if (socket && !socket.destroyed) { |
| 1202 | socket.on('close', () => { |
| 1203 | emitClose(session, error); |
| 1204 | }); |
| 1205 | if (session.closed) { |
| 1206 | // If we're gracefully closing the socket, call resume() so we can detect |
| 1207 | // the peer closing in case binding.Http2Session is already gone. |
| 1208 | socket.resume(); |
| 1209 | } |
| 1210 | |
| 1211 | // Always wait for writable side to finish. |
| 1212 | socket.end((err) => { |
| 1213 | debugSessionObj(session, 'finishSessionClose socket end', err, error); |
| 1214 | // If session.destroy() was called, destroy the underlying socket. Delay |
| 1215 | // it a bit to try to avoid ECONNRESET on Windows. |
| 1216 | if (!session.closed) { |
| 1217 | setImmediate(() => { |
| 1218 | socket.destroy(error); |
| 1219 | }); |
| 1220 | } |
| 1221 | }); |
| 1222 | } else { |
| 1223 | process.nextTick(emitClose, session, error); |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | function closeSession(session, code, error) { |
| 1228 | debugSessionObj(session, 'start closing/destroying', error); |
no test coverage detected
searching dependent graphs…