Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Unified Diff: runtime/bin/socket_base_fuchsia.cc

Issue 2910853002: [Fuchsia] EventHandler: epoll -> ports v2 (Closed)
Patch Set: Fix typo Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/process_fuchsia.cc ('k') | runtime/bin/socket_fuchsia.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_base_fuchsia.cc
diff --git a/runtime/bin/socket_base_fuchsia.cc b/runtime/bin/socket_base_fuchsia.cc
index 6087f75ba16434fc734ddc3fd884795c224b3c5b..68e8e472243004a15c8dffa86b984187a29e8d95 100644
--- a/runtime/bin/socket_base_fuchsia.cc
+++ b/runtime/bin/socket_base_fuchsia.cc
@@ -21,6 +21,7 @@
#include <sys/stat.h> // NOLINT
#include <unistd.h> // NOLINT
+#include "bin/eventhandler.h"
#include "bin/fdutils.h"
#include "bin/file.h"
#include "bin/socket_base_fuchsia.h"
@@ -87,8 +88,10 @@ bool SocketBase::IsBindError(intptr_t error_number) {
intptr_t SocketBase::Available(intptr_t fd) {
- intptr_t available = FDUtils::AvailableBytes(fd);
- LOG_INFO("SocketBase::Available(%ld) = %ld\n", fd, available);
+ IOHandle* handle = reinterpret_cast<IOHandle*>(fd);
+ ASSERT(handle->fd() >= 0);
+ intptr_t available = FDUtils::AvailableBytes(handle->fd());
+ LOG_INFO("SocketBase::Available(%ld) = %ld\n", handle->fd(), available);
return available;
}
@@ -97,21 +100,22 @@ intptr_t SocketBase::Read(intptr_t fd,
void* buffer,
intptr_t num_bytes,
SocketOpKind sync) {
- ASSERT(fd >= 0);
- LOG_INFO("SocketBase::Read: calling read(%ld, %p, %ld)\n", fd, buffer,
- num_bytes);
- ssize_t read_bytes = NO_RETRY_EXPECTED(read(fd, buffer, num_bytes));
+ IOHandle* handle = reinterpret_cast<IOHandle*>(fd);
+ ASSERT(handle->fd() >= 0);
+ LOG_INFO("SocketBase::Read: calling read(%ld, %p, %ld)\n", handle->fd(),
+ buffer, num_bytes);
+ intptr_t read_bytes = handle->Read(buffer, num_bytes);
ASSERT(EAGAIN == EWOULDBLOCK);
if ((sync == kAsync) && (read_bytes == -1) && (errno == EWOULDBLOCK)) {
// If the read would block we need to retry and therefore return 0
// as the number of bytes written.
read_bytes = 0;
} else if (read_bytes == -1) {
- LOG_ERR("SocketBase::Read: read(%ld, %p, %ld) failed\n", fd, buffer,
- num_bytes);
+ LOG_ERR("SocketBase::Read: read(%ld, %p, %ld) failed\n", handle->fd(),
+ buffer, num_bytes);
} else {
- LOG_INFO("SocketBase::Read: read(%ld, %p, %ld) succeeded\n", fd, buffer,
- num_bytes);
+ LOG_INFO("SocketBase::Read: read(%ld, %p, %ld) succeeded\n", handle->fd(),
+ buffer, num_bytes);
}
return read_bytes;
}
@@ -132,21 +136,22 @@ intptr_t SocketBase::Write(intptr_t fd,
const void* buffer,
intptr_t num_bytes,
SocketOpKind sync) {
- ASSERT(fd >= 0);
- LOG_INFO("SocketBase::Write: calling write(%ld, %p, %ld)\n", fd, buffer,
- num_bytes);
- ssize_t written_bytes = NO_RETRY_EXPECTED(write(fd, buffer, num_bytes));
+ IOHandle* handle = reinterpret_cast<IOHandle*>(fd);
+ ASSERT(handle->fd() >= 0);
+ LOG_INFO("SocketBase::Write: calling write(%ld, %p, %ld)\n", handle->fd(),
+ buffer, num_bytes);
+ intptr_t written_bytes = handle->Write(buffer, num_bytes);
ASSERT(EAGAIN == EWOULDBLOCK);
if ((sync == kAsync) && (written_bytes == -1) && (errno == EWOULDBLOCK)) {
// If the would block we need to retry and therefore return 0 as
// the number of bytes written.
written_bytes = 0;
} else if (written_bytes == -1) {
- LOG_ERR("SocketBase::Write: write(%ld, %p, %ld) failed\n", fd, buffer,
- num_bytes);
+ LOG_ERR("SocketBase::Write: write(%ld, %p, %ld) failed\n", handle->fd(),
+ buffer, num_bytes);
} else {
- LOG_INFO("SocketBase::Write: write(%ld, %p, %ld) succeeded\n", fd, buffer,
- num_bytes);
+ LOG_INFO("SocketBase::Write: write(%ld, %p, %ld) succeeded\n", handle->fd(),
+ buffer, num_bytes);
}
return written_bytes;
}
@@ -164,11 +169,12 @@ intptr_t SocketBase::SendTo(intptr_t fd,
intptr_t SocketBase::GetPort(intptr_t fd) {
- ASSERT(fd >= 0);
+ IOHandle* handle = reinterpret_cast<IOHandle*>(fd);
+ ASSERT(handle->fd() >= 0);
RawAddr raw;
socklen_t size = sizeof(raw);
- LOG_INFO("SocketBase::GetPort: calling getsockname(%ld)\n", fd);
- if (NO_RETRY_EXPECTED(getsockname(fd, &raw.addr, &size))) {
+ LOG_INFO("SocketBase::GetPort: calling getsockname(%ld)\n", handle->fd());
+ if (NO_RETRY_EXPECTED(getsockname(handle->fd(), &raw.addr, &size))) {
return 0;
}
return SocketAddress::GetAddrPort(raw);
@@ -176,10 +182,11 @@ intptr_t SocketBase::GetPort(intptr_t fd) {
SocketAddress* SocketBase::GetRemotePeer(intptr_t fd, intptr_t* port) {
- ASSERT(fd >= 0);
+ IOHandle* handle = reinterpret_cast<IOHandle*>(fd);
+ ASSERT(handle->fd() >= 0);
RawAddr raw;
socklen_t size = sizeof(raw);
- if (NO_RETRY_EXPECTED(getpeername(fd, &raw.addr, &size))) {
+ if (NO_RETRY_EXPECTED(getpeername(handle->fd(), &raw.addr, &size))) {
return NULL;
}
*port = SocketAddress::GetAddrPort(raw);
@@ -289,8 +296,9 @@ AddressList<InterfaceSocketAddress>* SocketBase::ListInterfaces(
void SocketBase::Close(intptr_t fd) {
- ASSERT(fd >= 0);
- NO_RETRY_EXPECTED(close(fd));
+ IOHandle* handle = reinterpret_cast<IOHandle*>(fd);
+ ASSERT(handle->fd() >= 0);
+ NO_RETRY_EXPECTED(close(handle->fd()));
}
@@ -302,8 +310,9 @@ bool SocketBase::GetNoDelay(intptr_t fd, bool* enabled) {
bool SocketBase::SetNoDelay(intptr_t fd, bool enabled) {
+ IOHandle* handle = reinterpret_cast<IOHandle*>(fd);
int on = enabled ? 1 : 0;
- return NO_RETRY_EXPECTED(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
+ return NO_RETRY_EXPECTED(setsockopt(handle->fd(), IPPROTO_TCP, TCP_NODELAY,
reinterpret_cast<char*>(&on),
sizeof(on))) == 0;
}
« no previous file with comments | « runtime/bin/process_fuchsia.cc ('k') | runtime/bin/socket_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698