| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 69d6e97 commit 86f2e86
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -986,6 +986,8 @@ function emitClose(self, error) { | |||
| 986 | 986 | } | |
| 987 | 987 | ||
| 988 | 988 | function finishSessionDestroy(session, error) { | |
| 989 | + debugSessionObj(session, 'finishSessionDestroy'); | ||
| 990 | + | ||
| 989 | 991 | const socket = session[kSocket]; | |
| 990 | 992 | if (!socket.destroyed) | |
| 991 | 993 | socket.destroy(error); | |
@@ -1354,16 +1356,12 @@ class Http2Session extends EventEmitter { | |||
| 1354 | 1356 | const handle = this[kHandle]; | |
| 1355 | 1357 | ||
| 1356 | 1358 | // Destroy the handle if it exists at this point | |
| 1357 | - if (handle !== undefined) | ||
| 1359 | + if (handle !== undefined) { | ||
| 1360 | + handle.ondone = finishSessionDestroy.bind(null, this, error); | ||
| 1358 | 1361 | handle.destroy(code, socket.destroyed); | |
| 1359 | - | ||
| 1360 | - // If the socket is alive, use setImmediate to destroy the session on the | ||
| 1361 | - // next iteration of the event loop in order to give data time to transmit. | ||
| 1362 | - // Otherwise, destroy immediately. | ||
| 1363 | - if (!socket.destroyed) | ||
| 1364 | - setImmediate(finishSessionDestroy, this, error); | ||
| 1365 | - else | ||
| 1362 | + } else { | ||
| 1366 | 1363 | finishSessionDestroy(this, error); | |
| 1364 | + } | ||
| 1367 | 1365 | } | |
| 1368 | 1366 | ||
| 1369 | 1367 | // Closing the session will: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -683,6 +683,13 @@ void Http2Session::Close(uint32_t code, bool socket_closed) { | |||
| 683 | 683 | ||
| 684 | 684 | flags_ |= SESSION_STATE_CLOSED; | |
| 685 | 685 | ||
| 686 | + // If we are writing we will get to make the callback in OnStreamAfterWrite. | ||
| 687 | + if ((flags_ & SESSION_STATE_WRITE_IN_PROGRESS) == 0) { | ||
| 688 | + Debug(this, "make done session callback"); | ||
| 689 | + HandleScope scope(env()->isolate()); | ||
| 690 | + MakeCallback(env()->ondone_string(), 0, nullptr); | ||
| 691 | + } | ||
| 692 | + | ||
| 686 | 693 | // If there are outstanding pings, those will need to be canceled, do | |
| 687 | 694 | // so on the next iteration of the event loop to avoid calling out into | |
| 688 | 695 | // javascript since this may be called during garbage collection. | |
@@ -1485,6 +1492,12 @@ void Http2Session::OnStreamAfterWrite(WriteWrap* w, int status) { | |||
| 1485 | 1492 | stream_->ReadStart(); | |
| 1486 | 1493 | } | |
| 1487 | 1494 | ||
| 1495 | + if ((flags_ & SESSION_STATE_CLOSED) != 0) { | ||
| 1496 | + HandleScope scope(env()->isolate()); | ||
| 1497 | + MakeCallback(env()->ondone_string(), 0, nullptr); | ||
| 1498 | + return; | ||
| 1499 | + } | ||
| 1500 | + | ||
| 1488 | 1501 | // If there is more incoming data queued up, consume it. | |
| 1489 | 1502 | if (stream_buf_offset_ > 0) { | |
| 1490 | 1503 | ConsumeHTTP2Data(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments