Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
819a647
esm: fix esm load bug
ZYSzys May 13, 2019
cc3ca08
test: clearing require cache crashes esm loader
aduh95 May 2, 2019
8f780e8
deps: cherry-pick 88f8fe1 from upstream V8
hashseed Nov 20, 2018
609d2b9
deps: V8: backport f27ac28
targos Jun 4, 2019
5ffe047
tls: renegotiate should take care of its own state
sam-github Feb 7, 2019
08a32fb
src: elevate v8 namespaces for node_process.cc
Jayasankar-m Nov 23, 2018
65ef26f
async_hooks: avoid double-destroy HTTPParser
Flarna May 30, 2019
0dee607
src: extract common Bind method
maclover7 Aug 14, 2018
14090b5
worker: fix nullptr deref after MessagePort deser failure
addaleax Dec 16, 2018
a8f78f0
src: fulfill Maybe contract in InlineDecoder
addaleax Dec 19, 2018
b7dbc1c
src: fix warning in cares_wrap.cc
cjihrig Dec 26, 2018
b3d8a1b
doc: add missing changes entry
BridgeAR Nov 30, 2018
76af23a
src: remove internalBinding('config').warningFile
joyeecheung Dec 11, 2018
044e753
stream: make _read() be called indefinitely if the user wants so
mcollina Feb 15, 2019
274b97c
stream: do not unconditionally call `_read()` on `resume()`
addaleax Mar 28, 2019
f34bb96
process: make stdout and stderr emit 'close' on destroy
mcollina Mar 15, 2019
f3841c6
stream: convert existing buffer when calling .setEncoding
addaleax May 28, 2019
ad588eb
doc: adjust TOC margins
silverwind Jun 5, 2019
b689008
src: in-source comments and minor TLS cleanups
sam-github Jan 16, 2019
f9e8e88
src: fix Get() usage in tls_wrap.cc
cjihrig Nov 3, 2018
99dad28
tls: add CHECK for impossible condition
addaleax Mar 21, 2019
75052ca
tls: add debugging to native TLS code
addaleax Mar 21, 2019
35be08a
test: clean up build files
Jun 19, 2019
39637cb
test: skip tests related to CI failures on AIX
sam-github Jun 28, 2019
2ae9916
test: skip stringbytes-external-exceed-max on AIX
sam-github Jul 2, 2019
ada0ed5
test: fix pty test hangs on aix
bnoordhuis Jul 8, 2019
c59e0c2
deps: updated openssl upgrade instructions
sam-github Jun 12, 2019
9e62852
deps: upgrade openssl sources to 1.1.1c
sam-github Jun 12, 2019
8f5d6cf
deps: update archs files for OpenSSL-1.1.1c
sam-github Jun 12, 2019
4a607fa
tools: replace rollup with ncc
Trott Dec 3, 2018
f332265
test: remove `util.inherits()` usage
ZYSzys Dec 28, 2018
0339fba
src: handle empty Maybe in uv binding initialize
addaleax Dec 17, 2018
a395299
2019-07-31, Version 10.16.1 'Dubnium' (LTS)
BethGriggs Jul 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
src: extract common Bind method
`TCPWrap::Bind` and `TCPWrap::Bind6` share a large amount of
functionality, so a common `Bind` was extracted to remove duplication.

Backport-PR-URL: #28222
PR-URL: #22315
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
  • Loading branch information
maclover7 authored and BethGriggs committed Jul 16, 2019
commit 0dee60740917cc9034497a60c6d7227cb2ec9682
39 changes: 19 additions & 20 deletions src/tcp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,28 @@ void TCPWrap::Open(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(err);
}


void TCPWrap::Bind(const FunctionCallbackInfo<Value>& args) {
template <typename T>
void TCPWrap::Bind(
const FunctionCallbackInfo<Value>& args,
int family,
std::function<int(const char* ip_address, int port, T* addr)> uv_ip_addr) {
TCPWrap* wrap;
ASSIGN_OR_RETURN_UNWRAP(&wrap,
args.Holder(),
args.GetReturnValue().Set(UV_EBADF));
Environment* env = wrap->env();
node::Utf8Value ip_address(env->isolate(), args[0]);
int port;
unsigned int flags = 0;
if (!args[1]->Int32Value(env->context()).To(&port)) return;
sockaddr_in addr;
int err = uv_ip4_addr(*ip_address, port, &addr);
if (family == AF_INET6 &&
!args[2]->Uint32Value(env->context()).To(&flags)) {
return;
}

T addr;
int err = uv_ip_addr(*ip_address, port, &addr);

if (err == 0) {
err = uv_tcp_bind(&wrap->handle_,
reinterpret_cast<const sockaddr*>(&addr),
Expand All @@ -239,24 +249,13 @@ void TCPWrap::Bind(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(err);
}

void TCPWrap::Bind(const FunctionCallbackInfo<Value>& args) {
Bind<sockaddr_in>(args, AF_INET, uv_ip4_addr);
}


void TCPWrap::Bind6(const FunctionCallbackInfo<Value>& args) {
TCPWrap* wrap;
ASSIGN_OR_RETURN_UNWRAP(&wrap,
args.Holder(),
args.GetReturnValue().Set(UV_EBADF));
Environment* env = wrap->env();
node::Utf8Value ip6_address(env->isolate(), args[0]);
int port;
if (!args[1]->Int32Value(env->context()).To(&port)) return;
sockaddr_in6 addr;
int err = uv_ip6_addr(*ip6_address, port, &addr);
if (err == 0) {
err = uv_tcp_bind(&wrap->handle_,
reinterpret_cast<const sockaddr*>(&addr),
0);
}
args.GetReturnValue().Set(err);
Bind<sockaddr_in6>(args, AF_INET6, uv_ip6_addr);
}


Expand Down
5 changes: 5 additions & 0 deletions src/tcp_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ class TCPWrap : public ConnectionWrap<TCPWrap, uv_tcp_t> {
static void Connect(const v8::FunctionCallbackInfo<v8::Value>& args,
std::function<int(const char* ip_address, T* addr)> uv_ip_addr);
static void Open(const v8::FunctionCallbackInfo<v8::Value>& args);
template <typename T>
static void Bind(
const v8::FunctionCallbackInfo<v8::Value>& args,
int family,
std::function<int(const char* ip_address, int port, T* addr)> uv_ip_addr);

#ifdef _WIN32
static void SetSimultaneousAccepts(
Expand Down