summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-15 20:46:32 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-15 20:46:32 +0000
commit051e4ecafeb6da960517224bdd0348dae7e43784 (patch)
treefe54348a4cd34c6d6bc6fad3d013788349729b27 /net
parenta82151cc51eab71162a356a8b9f83885d9386ef8 (diff)
downloadchromium_src-051e4ecafeb6da960517224bdd0348dae7e43784.zip
chromium_src-051e4ecafeb6da960517224bdd0348dae7e43784.tar.gz
chromium_src-051e4ecafeb6da960517224bdd0348dae7e43784.tar.bz2
Move MapWinsockError() and MapPosixError() to net_errors.h.
Added new net::MapSystemError() that is now used in place of MapWinsockError() and MapPosixError() BUG=None TEST=compiles Review URL: http://codereview.chromium.org/6694032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78279 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/net_errors.h5
-rw-r--r--net/base/net_errors_posix.cc55
-rw-r--r--net/base/net_errors_win.cc52
-rw-r--r--net/base/winsock_util.cc45
-rw-r--r--net/base/winsock_util.h3
-rw-r--r--net/net.gyp2
-rw-r--r--net/socket/tcp_client_socket_libevent.cc57
-rw-r--r--net/socket/tcp_client_socket_win.cc14
-rw-r--r--net/udp/udp_socket_libevent.cc71
-rw-r--r--net/udp/udp_socket_win.cc18
10 files changed, 149 insertions, 173 deletions
diff --git a/net/base/net_errors.h b/net/base/net_errors.h
index 847b215..5ae8b27 100644
--- a/net/base/net_errors.h
+++ b/net/base/net_errors.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -36,6 +36,9 @@ inline bool IsCertificateError(int error) {
return error <= ERR_CERT_BEGIN && error > ERR_CERT_END;
}
+// Map system error code to Error.
+Error MapSystemError(int os_error);
+
} // namespace net
#endif // NET_BASE_NET_ERRORS_H__
diff --git a/net/base/net_errors_posix.cc b/net/base/net_errors_posix.cc
new file mode 100644
index 0000000..e977ef4
--- /dev/null
+++ b/net/base/net_errors_posix.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/net_errors.h"
+
+#include <errno.h>
+
+#include "base/logging.h"
+
+namespace net {
+
+Error MapSystemError(int os_error) {
+ // There are numerous posix error codes, but these are the ones we thus far
+ // find interesting.
+ switch (os_error) {
+ case EAGAIN:
+#if EWOULDBLOCK != EAGAIN
+ case EWOULDBLOCK:
+#endif
+ return ERR_IO_PENDING;
+ case EACCES:
+ return ERR_ACCESS_DENIED;
+ case ENETDOWN:
+ return ERR_INTERNET_DISCONNECTED;
+ case ETIMEDOUT:
+ return ERR_TIMED_OUT;
+ case ECONNRESET:
+ case ENETRESET: // Related to keep-alive
+ case EPIPE:
+ return ERR_CONNECTION_RESET;
+ case ECONNABORTED:
+ return ERR_CONNECTION_ABORTED;
+ case ECONNREFUSED:
+ return ERR_CONNECTION_REFUSED;
+ case EHOSTUNREACH:
+ case EHOSTDOWN:
+ case ENETUNREACH:
+ return ERR_ADDRESS_UNREACHABLE;
+ case EADDRNOTAVAIL:
+ return ERR_ADDRESS_INVALID;
+ case EMSGSIZE:
+ return ERR_MSG_TOO_BIG;
+ case ENOTCONN:
+ return ERR_SOCKET_NOT_CONNECTED;
+ case 0:
+ return OK;
+ default:
+ LOG(WARNING) << "Unknown error " << os_error
+ << " mapped to net::ERR_FAILED";
+ return ERR_FAILED;
+ }
+}
+
+} // namespace net
diff --git a/net/base/net_errors_win.cc b/net/base/net_errors_win.cc
new file mode 100644
index 0000000..d0f5829
--- /dev/null
+++ b/net/base/net_errors_win.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/net_errors.h"
+
+#include <winsock2.h>
+
+#include "base/logging.h"
+
+namespace net {
+
+// Map winsock error to Chromium error.
+Error MapSystemError(int os_error) {
+ // There are numerous Winsock error codes, but these are the ones we thus far
+ // find interesting.
+ switch (os_error) {
+ case WSAEACCES:
+ return ERR_ACCESS_DENIED;
+ case WSAENETDOWN:
+ return ERR_INTERNET_DISCONNECTED;
+ case WSAETIMEDOUT:
+ return ERR_TIMED_OUT;
+ case WSAECONNRESET:
+ case WSAENETRESET: // Related to keep-alive
+ return ERR_CONNECTION_RESET;
+ case WSAECONNABORTED:
+ return ERR_CONNECTION_ABORTED;
+ case WSAECONNREFUSED:
+ return ERR_CONNECTION_REFUSED;
+ case WSA_IO_INCOMPLETE:
+ case WSAEDISCON:
+ return ERR_CONNECTION_CLOSED;
+ case WSAEHOSTUNREACH:
+ case WSAENETUNREACH:
+ return ERR_ADDRESS_UNREACHABLE;
+ case WSAEADDRNOTAVAIL:
+ return ERR_ADDRESS_INVALID;
+ case WSAENOTCONN:
+ return ERR_SOCKET_NOT_CONNECTED;
+ case WSAEAFNOSUPPORT:
+ return ERR_ADDRESS_UNREACHABLE;
+ case ERROR_SUCCESS:
+ return OK;
+ default:
+ LOG(WARNING) << "Unknown error " << os_error
+ << " mapped to net::ERR_FAILED";
+ return ERR_FAILED;
+ }
+}
+
+} // namespace net
diff --git a/net/base/winsock_util.cc b/net/base/winsock_util.cc
index a3548d4..02f59d6 100644
--- a/net/base/winsock_util.cc
+++ b/net/base/winsock_util.cc
@@ -48,49 +48,4 @@ bool ResetEventIfSignaled(WSAEVENT hEvent) {
return true;
}
-// Map winsock error to Chromium error.
-int MapWinsockError(int os_error) {
- // There are numerous Winsock error codes, but these are the ones we thus far
- // find interesting.
- switch (os_error) {
- case WSAEACCES:
- return ERR_ACCESS_DENIED;
- case WSAENETDOWN:
- return ERR_INTERNET_DISCONNECTED;
- case WSAETIMEDOUT:
- return ERR_TIMED_OUT;
- case WSAECONNRESET:
- case WSAENETRESET: // Related to keep-alive
- return ERR_CONNECTION_RESET;
- case WSAECONNABORTED:
- return ERR_CONNECTION_ABORTED;
- case WSAECONNREFUSED:
- return ERR_CONNECTION_REFUSED;
- case WSA_IO_INCOMPLETE:
- case WSAEDISCON:
- // WSAEDISCON is returned by WSARecv or WSARecvFrom for message-oriented
- // sockets (where a return value of zero means a zero-byte message) to
- // indicate graceful connection shutdown. We should not ever see this
- // error code for TCP sockets, which are byte stream oriented.
- LOG(DFATAL) << "Unexpected error " << os_error
- << " mapped to net::ERR_UNEXPECTED";
- return ERR_UNEXPECTED;
- case WSAEHOSTUNREACH:
- case WSAENETUNREACH:
- return ERR_ADDRESS_UNREACHABLE;
- case WSAEADDRNOTAVAIL:
- return ERR_ADDRESS_INVALID;
- case WSAENOTCONN:
- return ERR_SOCKET_NOT_CONNECTED;
- case WSAEAFNOSUPPORT:
- return ERR_ADDRESS_UNREACHABLE;
- case ERROR_SUCCESS:
- return OK;
- default:
- LOG(WARNING) << "Unknown error " << os_error
- << " mapped to net::ERR_FAILED";
- return ERR_FAILED;
- }
-}
-
} // namespace net
diff --git a/net/base/winsock_util.h b/net/base/winsock_util.h
index c26e63f..f1e39cb 100644
--- a/net/base/winsock_util.h
+++ b/net/base/winsock_util.h
@@ -23,9 +23,6 @@ void AssertEventNotSignaled(WSAEVENT hEvent);
// optimization. The code still works if this function simply returns false.
bool ResetEventIfSignaled(WSAEVENT hEvent);
-// Map winsock error to Chromium error.
-int MapWinsockError(int os_error);
-
} // namespace net
#endif // NET_BASE_WINSOCK_UTIL_H_
diff --git a/net/net.gyp b/net/net.gyp
index 7fa024a..730ad4a 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -123,6 +123,8 @@
'base/net_error_list.h',
'base/net_errors.cc',
'base/net_errors.h',
+ 'base/net_errors_posix.cc',
+ 'base/net_errors_win.cc',
'base/net_log.cc',
'base/net_log.h',
'base/net_log_event_type_list.h',
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index 7282fd4..c94276b 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -69,45 +69,6 @@ void SetTCPKeepAlive(int fd) {
#endif
}
-// Convert values from <errno.h> to values from "net/base/net_errors.h"
-int MapPosixError(int os_error) {
- // There are numerous posix error codes, but these are the ones we thus far
- // find interesting.
- switch (os_error) {
- case EAGAIN:
-#if EWOULDBLOCK != EAGAIN
- case EWOULDBLOCK:
-#endif
- return ERR_IO_PENDING;
- case EACCES:
- return ERR_ACCESS_DENIED;
- case ENETDOWN:
- return ERR_INTERNET_DISCONNECTED;
- case ETIMEDOUT:
- return ERR_TIMED_OUT;
- case ECONNRESET:
- case ENETRESET: // Related to keep-alive
- case EPIPE:
- return ERR_CONNECTION_RESET;
- case ECONNABORTED:
- return ERR_CONNECTION_ABORTED;
- case ECONNREFUSED:
- return ERR_CONNECTION_REFUSED;
- case EHOSTUNREACH:
- case EHOSTDOWN:
- case ENETUNREACH:
- return ERR_ADDRESS_UNREACHABLE;
- case EADDRNOTAVAIL:
- return ERR_ADDRESS_INVALID;
- case 0:
- return OK;
- default:
- LOG(WARNING) << "Unknown error " << os_error
- << " mapped to net::ERR_FAILED";
- return ERR_FAILED;
- }
-}
-
int MapConnectError(int os_error) {
switch (os_error) {
case EACCES:
@@ -115,7 +76,7 @@ int MapConnectError(int os_error) {
case ETIMEDOUT:
return ERR_CONNECTION_TIMED_OUT;
default: {
- int net_error = MapPosixError(os_error);
+ int net_error = MapSystemError(os_error);
if (net_error == ERR_FAILED)
return ERR_CONNECTION_FAILED; // More specific than ERR_FAILED.
@@ -253,7 +214,7 @@ int TCPClientSocketLibevent::DoConnect() {
// Create a non-blocking socket.
connect_os_error_ = CreateSocket(current_ai_);
if (connect_os_error_)
- return MapPosixError(connect_os_error_);
+ return MapSystemError(connect_os_error_);
// Connect the socket.
if (!use_tcp_fastopen_) {
@@ -280,7 +241,7 @@ int TCPClientSocketLibevent::DoConnect() {
&write_watcher_)) {
connect_os_error_ = errno;
DVLOG(1) << "WatchFileDescriptor failed: " << connect_os_error_;
- return MapPosixError(connect_os_error_);
+ return MapSystemError(connect_os_error_);
}
return ERR_IO_PENDING;
@@ -395,14 +356,14 @@ int TCPClientSocketLibevent::Read(IOBuffer* buf,
}
if (errno != EAGAIN && errno != EWOULDBLOCK) {
DVLOG(1) << "read failed, errno " << errno;
- return MapPosixError(errno);
+ return MapSystemError(errno);
}
if (!MessageLoopForIO::current()->WatchFileDescriptor(
socket_, true, MessageLoopForIO::WATCH_READ,
&read_socket_watcher_, &read_watcher_)) {
DVLOG(1) << "WatchFileDescriptor failed on read, errno " << errno;
- return MapPosixError(errno);
+ return MapSystemError(errno);
}
read_buf_ = buf;
@@ -433,13 +394,13 @@ int TCPClientSocketLibevent::Write(IOBuffer* buf,
return nwrite;
}
if (errno != EAGAIN && errno != EWOULDBLOCK)
- return MapPosixError(errno);
+ return MapSystemError(errno);
if (!MessageLoopForIO::current()->WatchFileDescriptor(
socket_, true, MessageLoopForIO::WATCH_WRITE,
&write_socket_watcher_, &write_watcher_)) {
DVLOG(1) << "WatchFileDescriptor failed on write, errno " << errno;
- return MapPosixError(errno);
+ return MapSystemError(errno);
}
write_buf_ = buf;
@@ -610,7 +571,7 @@ void TCPClientSocketLibevent::DidCompleteRead() {
LogByteTransfer(net_log_, NetLog::TYPE_SOCKET_BYTES_RECEIVED, result,
read_buf_->data());
} else {
- result = MapPosixError(errno);
+ result = MapSystemError(errno);
}
if (result != ERR_IO_PENDING) {
@@ -637,7 +598,7 @@ void TCPClientSocketLibevent::DidCompleteWrite() {
LogByteTransfer(net_log_, NetLog::TYPE_SOCKET_BYTES_SENT, result,
write_buf_->data());
} else {
- result = MapPosixError(errno);
+ result = MapSystemError(errno);
}
if (result != ERR_IO_PENDING) {
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
index 6d733fa..d33bd40 100644
--- a/net/socket/tcp_client_socket_win.cc
+++ b/net/socket/tcp_client_socket_win.cc
@@ -37,7 +37,7 @@ int MapConnectError(int os_error) {
case WSAETIMEDOUT:
return ERR_CONNECTION_TIMED_OUT;
default: {
- int net_error = MapWinsockError(os_error);
+ int net_error = MapSystemError(os_error);
if (net_error == ERR_FAILED)
return ERR_CONNECTION_FAILED; // More specific than ERR_FAILED.
@@ -316,7 +316,7 @@ int TCPClientSocketWin::DoConnect() {
connect_os_error_ = CreateSocket(ai);
if (connect_os_error_ != 0)
- return MapWinsockError(connect_os_error_);
+ return MapSystemError(connect_os_error_);
DCHECK(!core_);
core_ = new Core(this);
@@ -526,7 +526,7 @@ int TCPClientSocketWin::Read(IOBuffer* buf,
} else {
int os_error = WSAGetLastError();
if (os_error != WSA_IO_PENDING)
- return MapWinsockError(os_error);
+ return MapSystemError(os_error);
}
core_->WatchForRead();
waiting_read_ = true;
@@ -578,7 +578,7 @@ int TCPClientSocketWin::Write(IOBuffer* buf,
} else {
int os_error = WSAGetLastError();
if (os_error != WSA_IO_PENDING)
- return MapWinsockError(os_error);
+ return MapSystemError(os_error);
}
core_->WatchForWrite();
waiting_write_ = true;
@@ -743,7 +743,7 @@ void TCPClientSocketWin::DidCompleteConnect() {
if (rv == SOCKET_ERROR) {
NOTREACHED();
os_error = WSAGetLastError();
- result = MapWinsockError(os_error);
+ result = MapSystemError(os_error);
} else if (events.lNetworkEvents & FD_CONNECT) {
os_error = events.iErrorCode[FD_CONNECT_BIT];
result = MapConnectError(os_error);
@@ -776,7 +776,7 @@ void TCPClientSocketWin::DidCompleteRead() {
LogByteTransfer(net_log_, NetLog::TYPE_SOCKET_BYTES_RECEIVED, num_bytes,
core_->read_buffer_.buf);
}
- DoReadCallback(ok ? num_bytes : MapWinsockError(WSAGetLastError()));
+ DoReadCallback(ok ? num_bytes : MapSystemError(WSAGetLastError()));
}
void TCPClientSocketWin::DidCompleteWrite() {
@@ -789,7 +789,7 @@ void TCPClientSocketWin::DidCompleteWrite() {
waiting_write_ = false;
int rv;
if (!ok) {
- rv = MapWinsockError(WSAGetLastError());
+ rv = MapSystemError(WSAGetLastError());
} else {
rv = static_cast<int>(num_bytes);
if (rv > core_->write_buffer_length_ || rv < 0) {
diff --git a/net/udp/udp_socket_libevent.cc b/net/udp/udp_socket_libevent.cc
index 15a149b96..0396ea9 100644
--- a/net/udp/udp_socket_libevent.cc
+++ b/net/udp/udp_socket_libevent.cc
@@ -29,55 +29,6 @@
namespace net {
-namespace {
-
-// Convert values from <errno.h> to values from "net/base/net_errors.h"
-int MapPosixError(int os_error) {
- // There are numerous posix error codes, but these are the ones we thus far
- // find interesting.
- switch (os_error) {
- case EAGAIN:
-#if EWOULDBLOCK != EAGAIN
- case EWOULDBLOCK:
-#endif
- return ERR_IO_PENDING;
- case EACCES:
- return ERR_ACCESS_DENIED;
- case ENETDOWN:
- return ERR_INTERNET_DISCONNECTED;
- case ETIMEDOUT:
- return ERR_TIMED_OUT;
- case ECONNRESET:
- case ENETRESET: // Related to keep-alive
- case EPIPE:
- return ERR_CONNECTION_RESET;
- case ECONNABORTED:
- return ERR_CONNECTION_ABORTED;
- case ECONNREFUSED:
- return ERR_CONNECTION_REFUSED;
- case EHOSTUNREACH:
- case EHOSTDOWN:
- case ENETUNREACH:
- return ERR_ADDRESS_UNREACHABLE;
- case EADDRNOTAVAIL:
- return ERR_ADDRESS_INVALID;
- case EMSGSIZE:
- return ERR_MSG_TOO_BIG;
- case ENOTCONN:
- return ERR_SOCKET_NOT_CONNECTED;
- case 0:
- return OK;
- default:
- LOG(WARNING) << "Unknown error " << os_error
- << " mapped to net::ERR_FAILED";
- return ERR_FAILED;
- }
-}
-
-} // namespace
-
-//-----------------------------------------------------------------------------
-
UDPSocketLibevent::UDPSocketLibevent(net::NetLog* net_log,
const net::NetLog::Source& source)
: socket_(kInvalidSocket),
@@ -138,7 +89,7 @@ int UDPSocketLibevent::GetPeerAddress(IPEndPoint* address) const {
socklen_t addr_len = sizeof(addr_storage);
struct sockaddr* addr = reinterpret_cast<struct sockaddr*>(&addr_storage);
if (getpeername(socket_, addr, &addr_len))
- return MapPosixError(errno);
+ return MapSystemError(errno);
scoped_ptr<IPEndPoint> address(new IPEndPoint());
if (!address->FromSockAddr(addr, addr_len))
return ERR_FAILED;
@@ -160,7 +111,7 @@ int UDPSocketLibevent::GetLocalAddress(IPEndPoint* address) const {
socklen_t addr_len = sizeof(addr_storage);
struct sockaddr* addr = reinterpret_cast<struct sockaddr*>(&addr_storage);
if (getsockname(socket_, addr, &addr_len))
- return MapPosixError(errno);
+ return MapSystemError(errno);
scoped_ptr<IPEndPoint> address(new IPEndPoint());
if (!address->FromSockAddr(addr, addr_len))
return ERR_FAILED;
@@ -188,7 +139,7 @@ int UDPSocketLibevent::Read(IOBuffer* buf,
socket_, true, MessageLoopForIO::WATCH_READ,
&read_socket_watcher_, &read_watcher_)) {
PLOG(ERROR) << "WatchFileDescriptor failed on read";
- return MapPosixError(errno);
+ return MapSystemError(errno);
}
read_buf_ = buf;
@@ -230,13 +181,13 @@ int UDPSocketLibevent::Write(IOBuffer* buf,
return nwrite;
}
if (errno != EAGAIN && errno != EWOULDBLOCK)
- return MapPosixError(errno);
+ return MapSystemError(errno);
if (!MessageLoopForIO::current()->WatchFileDescriptor(
socket_, true, MessageLoopForIO::WATCH_WRITE,
&write_socket_watcher_, &write_watcher_)) {
DVLOG(1) << "WatchFileDescriptor failed on write, errno " << errno;
- return MapPosixError(errno);
+ return MapSystemError(errno);
}
write_buf_ = buf;
@@ -260,7 +211,7 @@ int UDPSocketLibevent::Connect(const IPEndPoint& address) {
rv = HANDLE_EINTR(connect(socket_, addr, addr_len));
if (rv < 0)
- return MapPosixError(errno);
+ return MapSystemError(errno);
remote_address_.reset(new IPEndPoint(address));
return rv;
@@ -281,7 +232,7 @@ int UDPSocketLibevent::Bind(const IPEndPoint& address) {
rv = bind(socket_, addr, addr_len);
if (rv < 0)
- return MapPosixError(errno);
+ return MapSystemError(errno);
local_address_.reset(new IPEndPoint(address));
return rv;
@@ -323,9 +274,9 @@ void UDPSocketLibevent::DidCompleteRead() {
int UDPSocketLibevent::CreateSocket(const IPEndPoint& address) {
socket_ = socket(address.GetFamily(), SOCK_DGRAM, 0);
if (socket_ == kInvalidSocket)
- return MapPosixError(errno);
+ return MapSystemError(errno);
if (SetNonBlocking(socket_)) {
- const int err = MapPosixError(errno);
+ const int err = MapSystemError(errno);
Close();
return err;
}
@@ -338,7 +289,7 @@ void UDPSocketLibevent::DidCompleteWrite() {
static base::StatsCounter write_bytes("udp.write_bytes");
write_bytes.Add(result);
} else {
- result = MapPosixError(errno);
+ result = MapSystemError(errno);
}
if (result != ERR_IO_PENDING) {
@@ -374,7 +325,7 @@ int UDPSocketLibevent::InternalRead(IOBuffer* buf, int buf_len) {
result = ERR_FAILED;
}
} else {
- result = MapPosixError(errno);
+ result = MapSystemError(errno);
}
return result;
}
diff --git a/net/udp/udp_socket_win.cc b/net/udp/udp_socket_win.cc
index a7af53e..a34fb0c 100644
--- a/net/udp/udp_socket_win.cc
+++ b/net/udp/udp_socket_win.cc
@@ -86,7 +86,7 @@ int UDPSocketWin::GetPeerAddress(IPEndPoint* address) const {
int addr_len = sizeof(addr_storage);
struct sockaddr* addr = reinterpret_cast<struct sockaddr*>(&addr_storage);
if (getpeername(socket_, addr, &addr_len))
- return MapWinsockError(WSAGetLastError());
+ return MapSystemError(WSAGetLastError());
scoped_ptr<IPEndPoint> address(new IPEndPoint());
if (!address->FromSockAddr(addr, addr_len))
return ERR_FAILED;
@@ -108,7 +108,7 @@ int UDPSocketWin::GetLocalAddress(IPEndPoint* address) const {
socklen_t addr_len = sizeof(addr_storage);
struct sockaddr* addr = reinterpret_cast<struct sockaddr*>(&addr_storage);
if (getsockname(socket_, addr, &addr_len))
- return MapWinsockError(WSAGetLastError());
+ return MapSystemError(WSAGetLastError());
scoped_ptr<IPEndPoint> address(new IPEndPoint());
if (!address->FromSockAddr(addr, addr_len))
return ERR_FAILED;
@@ -187,7 +187,7 @@ int UDPSocketWin::Connect(const IPEndPoint& address) {
rv = connect(socket_, addr, addr_len);
if (rv < 0)
- return MapWinsockError(WSAGetLastError());
+ return MapSystemError(WSAGetLastError());
remote_address_.reset(new IPEndPoint(address));
return rv;
@@ -208,7 +208,7 @@ int UDPSocketWin::Bind(const IPEndPoint& address) {
rv = bind(socket_, addr, addr_len);
if (rv < 0)
- return MapWinsockError(WSAGetLastError());
+ return MapSystemError(WSAGetLastError());
local_address_.reset(new IPEndPoint(address));
return rv;
@@ -218,7 +218,7 @@ int UDPSocketWin::CreateSocket(const IPEndPoint& address) {
socket_ = WSASocket(address.GetFamily(), SOCK_DGRAM, IPPROTO_UDP, NULL, 0,
WSA_FLAG_OVERLAPPED);
if (socket_ == INVALID_SOCKET)
- return MapWinsockError(WSAGetLastError());
+ return MapSystemError(WSAGetLastError());
return OK;
}
@@ -249,7 +249,7 @@ void UDPSocketWin::DidCompleteRead() {
BOOL ok = WSAGetOverlappedResult(socket_, &read_overlapped_,
&num_bytes, FALSE, &flags);
WSAResetEvent(read_overlapped_.hEvent);
- int result = ok ? num_bytes : MapWinsockError(WSAGetLastError());
+ int result = ok ? num_bytes : MapSystemError(WSAGetLastError());
if (ok) {
if (!ProcessSuccessfulRead(num_bytes))
result = ERR_FAILED;
@@ -278,7 +278,7 @@ void UDPSocketWin::DidCompleteWrite() {
BOOL ok = WSAGetOverlappedResult(socket_, &write_overlapped_,
&num_bytes, FALSE, &flags);
WSAResetEvent(write_overlapped_.hEvent);
- int result = ok ? num_bytes : MapWinsockError(WSAGetLastError());
+ int result = ok ? num_bytes : MapSystemError(WSAGetLastError());
if (ok)
ProcessSuccessfulWrite(num_bytes);
write_iobuffer_ = NULL;
@@ -320,7 +320,7 @@ int UDPSocketWin::InternalRead(IOBuffer* buf, int buf_len) {
} else {
int os_error = WSAGetLastError();
if (os_error != WSA_IO_PENDING)
- return MapWinsockError(os_error);
+ return MapSystemError(os_error);
}
read_watcher_.StartWatching(read_overlapped_.hEvent, &read_delegate_);
return ERR_IO_PENDING;
@@ -357,7 +357,7 @@ int UDPSocketWin::InternalWrite(IOBuffer* buf, int buf_len) {
} else {
int os_error = WSAGetLastError();
if (os_error != WSA_IO_PENDING)
- return MapWinsockError(os_error);
+ return MapSystemError(os_error);
}
write_watcher_.StartWatching(write_overlapped_.hEvent, &write_delegate_);