| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f7ed473 commit d6fbd81
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -760,7 +760,7 @@ function afterWrite(status, handle, req, err) { | |||
| 760 | 760 | } | |
| 761 | 761 | ||
| 762 | 762 | if (status < 0) { | |
| 763 | - var ex = exceptionWithHostPort(status, 'write', req.address, req.port); | ||
| 763 | + var ex = errnoException(status, 'write', req.error); | ||
| 764 | 764 | debug('write failure', ex); | |
| 765 | 765 | self._destroy(ex, req.cb); | |
| 766 | 766 | return; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,8 +22,15 @@ class StreamReq { | |||
| 22 | 22 | explicit StreamReq(DoneCb cb) : cb_(cb) { | |
| 23 | 23 | } | |
| 24 | 24 | ||
| 25 | - inline void Done(int status) { | ||
| 26 | - cb_(static_cast<Req*>(this), status); | ||
| 25 | + inline void Done(int status, const char* error_str = nullptr) { | ||
| 26 | + Req* req = static_cast<Req*>(this); | ||
| 27 | + Environment* env = req->env(); | ||
| 28 | + if (error_str != nullptr) { | ||
| 29 | + req->object()->Set(env->error_string(), | ||
| 30 | + OneByteString(env->isolate(), error_str)); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + cb_(req, status); | ||
| 27 | 34 | } | |
| 28 | 35 | ||
| 29 | 36 | private: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,15 +92,15 @@ void TLSWrap::MakePending() { | |||
| 92 | 92 | } | |
| 93 | 93 | ||
| 94 | 94 | ||
| 95 | - bool TLSWrap::InvokeQueued(int status) { | ||
| 95 | + bool TLSWrap::InvokeQueued(int status, const char* error_str) { | ||
| 96 | 96 | if (pending_write_items_.IsEmpty()) | |
| 97 | 97 | return false; | |
| 98 | 98 | ||
| 99 | 99 | // Process old queue | |
| 100 | 100 | WriteItemList queue; | |
| 101 | 101 | pending_write_items_.MoveBack(&queue); | |
| 102 | 102 | while (WriteItem* wi = queue.PopFront()) { | |
| 103 | - wi->w_->Done(status); | ||
| 103 | + wi->w_->Done(status, error_str); | ||
| 104 | 104 | delete wi; | |
| 105 | 105 | } | |
| 106 | 106 | ||
@@ -484,11 +484,12 @@ bool TLSWrap::ClearIn() { | |||
| 484 | 484 | ||
| 485 | 485 | // Error or partial write | |
| 486 | 486 | int err; | |
| 487 | - Local<Value> arg = GetSSLError(written, &err, &error_); | ||
| 487 | + const char* error_str = nullptr; | ||
| 488 | + Local<Value> arg = GetSSLError(written, &err, &error_str); | ||
| 488 | 489 | if (!arg.IsEmpty()) { | |
| 489 | 490 | MakePending(); | |
| 490 | - if (!InvokeQueued(UV_EPROTO)) | ||
| 491 | - ClearError(); | ||
| 491 | + InvokeQueued(UV_EPROTO, error_str); | ||
| 492 | + delete[] error_str; | ||
| 492 | 493 | clear_in_->Reset(); | |
| 493 | 494 | } | |
| 494 | 495 | ||
@@ -589,8 +590,15 @@ int TLSWrap::DoWrite(WriteWrap* w, | |||
| 589 | 590 | return 0; | |
| 590 | 591 | } | |
| 591 | 592 | ||
| 592 | - if (ssl_ == nullptr) | ||
| 593 | + if (ssl_ == nullptr) { | ||
| 594 | + ClearError(); | ||
| 595 | + | ||
| 596 | + static char msg[] = "Write after DestroySSL"; | ||
| 597 | + char* tmp = new char[sizeof(msg)]; | ||
| 598 | + memcpy(tmp, msg, sizeof(msg)); | ||
| 599 | + error_ = tmp; | ||
| 593 | 600 | return UV_EPROTO; | |
| 601 | + } | ||
| 594 | 602 | ||
| 595 | 603 | crypto::MarkPopErrorOnReturn mark_pop_error_on_return; | |
| 596 | 604 | ||
@@ -775,7 +783,7 @@ void TLSWrap::DestroySSL(const FunctionCallbackInfo<Value>& args) { | |||
| 775 | 783 | wrap->MakePending(); | |
| 776 | 784 | ||
| 777 | 785 | // And destroy | |
| 778 | - wrap->InvokeQueued(UV_ECANCELED); | ||
| 786 | + wrap->InvokeQueued(UV_ECANCELED, "Canceled because of SSL destruction"); | ||
| 779 | 787 | ||
| 780 | 788 | // Destroy the SSL structure and friends | |
| 781 | 789 | wrap->SSLWrap<TLSWrap>::DestroySSL(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,7 +89,7 @@ class TLSWrap : public AsyncWrap, | |||
| 89 | 89 | bool ClearIn(); | |
| 90 | 90 | void ClearOut(); | |
| 91 | 91 | void MakePending(); | |
| 92 | - bool InvokeQueued(int status); | ||
| 92 | + bool InvokeQueued(int status, const char* error_str = nullptr); | ||
| 93 | 93 | ||
| 94 | 94 | inline void Cycle() { | |
| 95 | 95 | // Prevent recursion | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,29 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + | ||
| 4 | + if (!common.hasCrypto) { | ||
| 5 | + console.log('1..0 # Skipped: missing crypto'); | ||
| 6 | + return; | ||
| 7 | + } | ||
| 8 | + | ||
| 9 | + const assert = require('assert'); | ||
| 10 | + const https = require('https'); | ||
| 11 | + const net = require('net'); | ||
| 12 | + | ||
| 13 | + const server = net.createServer(function(s) { | ||
| 14 | + s.once('data', function() { | ||
| 15 | + s.end('I was waiting for you, hello!', function() { | ||
| 16 | + s.destroy(); | ||
| 17 | + }); | ||
| 18 | + }); | ||
| 19 | + }); | ||
| 20 | + | ||
| 21 | + server.listen(common.PORT, function() { | ||
| 22 | + const req = https.request({ port: common.PORT }); | ||
| 23 | + req.end(); | ||
| 24 | + | ||
| 25 | + req.once('error', common.mustCall(function(err) { | ||
| 26 | + assert(/unknown protocol/.test(err.message)); | ||
| 27 | + server.close(); | ||
| 28 | + })); | ||
| 29 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments