Skip to content

Commit

Permalink
net: change SetAddressReuse() method to AllowAddressReuse()
Browse files Browse the repository at this point in the history
This makes the TCPSocketPosix method match with its UDP counterpart
in UDPSocketPosix.

Since there is just one caller that passes true to SetAddressReuse(),
it was fine to turn it into AllowAddressReuse().

BUG=None
TEST=net_unittests
R=eroman@chromium.org

Review-Url: https://codereview.chromium.org/2818263002
Cr-Commit-Position: refs/heads/master@{#464868}
  • Loading branch information
tfarina authored and Commit bot committed Apr 15, 2017
1 parent 9a35107 commit a0922c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions net/socket/tcp_socket_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ int TCPSocketPosix::GetPeerAddress(IPEndPoint* address) const {

int TCPSocketPosix::SetDefaultOptionsForServer() {
DCHECK(socket_);
return SetAddressReuse(true);
return AllowAddressReuse();
}

void TCPSocketPosix::SetDefaultOptionsForClient() {
Expand Down Expand Up @@ -399,29 +399,33 @@ void TCPSocketPosix::SetDefaultOptionsForClient() {
#endif
}

int TCPSocketPosix::SetAddressReuse(bool allow) {
int TCPSocketPosix::AllowAddressReuse() {
DCHECK(socket_);

return SetReuseAddr(socket_->socket_fd(), allow);
return SetReuseAddr(socket_->socket_fd(), true);
}

int TCPSocketPosix::SetReceiveBufferSize(int32_t size) {
DCHECK(socket_);

return SetSocketReceiveBufferSize(socket_->socket_fd(), size);
}

int TCPSocketPosix::SetSendBufferSize(int32_t size) {
DCHECK(socket_);

return SetSocketSendBufferSize(socket_->socket_fd(), size);
}

bool TCPSocketPosix::SetKeepAlive(bool enable, int delay) {
DCHECK(socket_);

return SetTCPKeepAlive(socket_->socket_fd(), enable, delay);
}

bool TCPSocketPosix::SetNoDelay(bool no_delay) {
DCHECK(socket_);

return SetTCPNoDelay(socket_->socket_fd(), no_delay) == OK;
}

Expand Down
5 changes: 3 additions & 2 deletions net/socket/tcp_socket_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class NET_EXPORT TCPSocketPosix {
virtual ~TCPSocketPosix();

int Open(AddressFamily family);

// Takes ownership of |socket_fd|.
int AdoptConnectedSocket(int socket_fd, const IPEndPoint& peer_address);

Expand Down Expand Up @@ -69,13 +70,13 @@ class NET_EXPORT TCPSocketPosix {

// Sets various socket options.
// The commonly used options for server listening sockets:
// - SetAddressReuse(true).
// - AllowAddressReuse().
int SetDefaultOptionsForServer();
// The commonly used options for client sockets and accepted sockets:
// - SetNoDelay(true);
// - SetKeepAlive(true, 45).
void SetDefaultOptionsForClient();
int SetAddressReuse(bool allow);
int AllowAddressReuse();
int SetReceiveBufferSize(int32_t size);
int SetSendBufferSize(int32_t size);
bool SetKeepAlive(bool enable, int delay);
Expand Down

0 comments on commit a0922c8

Please sign in to comment.