summaryrefslogtreecommitdiffstats
path: root/net/tools/flip_server
diff options
context:
space:
mode:
authordougk <dougk@chromium.org>2015-03-10 11:24:57 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-10 18:25:35 +0000
commit80b1342589acaa8630d221eb4a7fecf6191d88b9 (patch)
tree00a00316e6e3c4e1fc317ca77c968351963c72c9 /net/tools/flip_server
parent387d731890b6331fad8e9c1cc6a147444fb31acc (diff)
downloadchromium_src-80b1342589acaa8630d221eb4a7fecf6191d88b9.zip
chromium_src-80b1342589acaa8630d221eb4a7fecf6191d88b9.tar.gz
chromium_src-80b1342589acaa8630d221eb4a7fecf6191d88b9.tar.bz2
make EpollServer with with Posix poll(), take 2.
This is in lieu of https://codereview.chromium.org/960503005/ BUG=461857 Review URL: https://codereview.chromium.org/987803002 Cr-Commit-Position: refs/heads/master@{#319926}
Diffstat (limited to 'net/tools/flip_server')
-rw-r--r--net/tools/flip_server/acceptor_thread.cc5
-rw-r--r--net/tools/flip_server/sm_connection.cc31
2 files changed, 19 insertions, 17 deletions
diff --git a/net/tools/flip_server/acceptor_thread.cc b/net/tools/flip_server/acceptor_thread.cc
index 2b65e5d..ceba935 100644
--- a/net/tools/flip_server/acceptor_thread.cc
+++ b/net/tools/flip_server/acceptor_thread.cc
@@ -76,7 +76,8 @@ SMConnection* SMAcceptorThread::FindOrMakeNewSMConnection() {
}
void SMAcceptorThread::InitWorker() {
- epoll_server_.RegisterFD(acceptor_->listen_fd_, this, EPOLLIN | EPOLLET);
+ epoll_server_.RegisterFD(acceptor_->listen_fd_, this,
+ PollBits(NET_POLLIN | NET_POLLET));
}
void SMAcceptorThread::HandleConnection(int server_fd,
@@ -197,7 +198,7 @@ void SMAcceptorThread::Run() {
}
void SMAcceptorThread::OnEvent(int fd, EpollEvent* event) {
- if (event->in_events | EPOLLIN) {
+ if (event->in_events | NET_POLLIN) {
VLOG(2) << ACCEPTOR_CLIENT_IDENT
<< "Acceptor: Accepting based upon epoll events";
AcceptFromListenFD();
diff --git a/net/tools/flip_server/sm_connection.cc b/net/tools/flip_server/sm_connection.cc
index 4acdea4..435bb2e 100644
--- a/net/tools/flip_server/sm_connection.cc
+++ b/net/tools/flip_server/sm_connection.cc
@@ -65,8 +65,8 @@ EpollServer* SMConnection::epoll_server() { return epoll_server_; }
void SMConnection::ReadyToSend() {
VLOG(2) << log_prefix_ << ACCEPTOR_CLIENT_IDENT
- << "Setting ready to send: EPOLLIN | EPOLLOUT";
- epoll_server_->SetFDReady(fd_, EPOLLIN | EPOLLOUT);
+ << "Setting ready to send: POLLIN | POLLOUT";
+ epoll_server_->SetFDReady(fd_, NET_POLLIN | NET_POLLOUT);
}
void SMConnection::EnqueueDataFrame(DataFrame* df) {
@@ -150,7 +150,8 @@ void SMConnection::InitSMConnection(SMConnectionPoolInterface* connection_pool,
read_buffer_.Clear();
- epoll_server_->RegisterFD(fd_, this, EPOLLIN | EPOLLOUT | EPOLLET);
+ epoll_server_->RegisterFD(fd_, this,
+ PollBits(NET_POLLIN | NET_POLLOUT | NET_POLLET));
if (use_ssl) {
ssl_ = CreateSSLContext(ssl_state_->ssl_ctx);
@@ -256,14 +257,14 @@ void SMConnection::Cleanup(const char* cleanup) {
void SMConnection::HandleEvents() {
VLOG(2) << log_prefix_ << ACCEPTOR_CLIENT_IDENT
- << "Received: " << EpollServer::EventMaskToString(events_).c_str();
+ << "Received: " << PollBits(events_).ToString();
- if (events_ & EPOLLIN) {
+ if (events_ & NET_POLLIN) {
if (!DoRead())
goto handle_close_or_error;
}
- if (events_ & EPOLLOUT) {
+ if (events_ & NET_POLLOUT) {
// Check if we have connected or not
if (connection_complete_ == false) {
int sock_error;
@@ -292,7 +293,7 @@ void SMConnection::HandleEvents() {
goto handle_close_or_error;
}
- if (events_ & (EPOLLHUP | EPOLLERR)) {
+ if (events_ & (NET_POLLHUP | NET_POLLERR)) {
VLOG(1) << log_prefix_ << ACCEPTOR_CLIENT_IDENT << "!!! Got HUP or ERR";
goto handle_close_or_error;
}
@@ -429,7 +430,7 @@ bool SMConnection::DoRead() {
case SSL_ERROR_WANT_WRITE:
case SSL_ERROR_WANT_ACCEPT:
case SSL_ERROR_WANT_CONNECT:
- events_ &= ~EPOLLIN;
+ events_ &= ~NET_POLLIN;
VLOG(2) << log_prefix_ << ACCEPTOR_CLIENT_IDENT
<< "DoRead: SSL WANT_XXX: " << err;
goto done;
@@ -445,7 +446,7 @@ bool SMConnection::DoRead() {
if (bytes_read == -1) {
switch (stored_errno) {
case EAGAIN:
- events_ &= ~EPOLLIN;
+ events_ &= ~NET_POLLIN;
VLOG(2) << log_prefix_ << ACCEPTOR_CLIENT_IDENT
<< "Got EAGAIN while reading";
goto done;
@@ -509,13 +510,13 @@ bool SMConnection::DoConsumeReadData() {
VLOG(2) << log_prefix_ << ACCEPTOR_CLIENT_IDENT
<< "HandleRequestFullyRead: Setting EPOLLOUT";
HandleResponseFullyRead();
- events_ |= EPOLLOUT;
+ events_ |= NET_POLLOUT;
} else if (sm_interface_->Error()) {
LOG(ERROR) << log_prefix_ << ACCEPTOR_CLIENT_IDENT
<< "Framer error detected: Setting EPOLLOUT: "
<< sm_interface_->ErrorAsString();
// this causes everything to be closed/cleaned up.
- events_ |= EPOLLOUT;
+ events_ |= NET_POLLOUT;
return false;
}
read_buffer_.GetReadablePtr(&bytes, &size);
@@ -539,7 +540,7 @@ bool SMConnection::DoWrite() {
sm_interface_->GetOutput();
}
if (output_list_.empty()) {
- events_ &= ~EPOLLOUT;
+ events_ &= ~NET_POLLOUT;
}
}
while (!output_list_.empty()) {
@@ -549,7 +550,7 @@ bool SMConnection::DoWrite() {
VLOG(2) << log_prefix_ << ACCEPTOR_CLIENT_IDENT
<< " byte sent >= max bytes sent per write: Setting EPOLLOUT: "
<< bytes_sent;
- events_ |= EPOLLOUT;
+ events_ |= NET_POLLOUT;
break;
}
if (sm_interface_ && output_list_.size() < 2) {
@@ -581,7 +582,7 @@ bool SMConnection::DoWrite() {
if (bytes_written == -1) {
switch (stored_errno) {
case EAGAIN:
- events_ &= ~EPOLLOUT;
+ events_ &= ~NET_POLLOUT;
VLOG(2) << log_prefix_ << ACCEPTOR_CLIENT_IDENT
<< "Got EAGAIN while writing";
goto done;
@@ -603,7 +604,7 @@ bool SMConnection::DoWrite() {
continue;
} else if (bytes_written == -2) {
// -2 handles SSL_ERROR_WANT_* errors
- events_ &= ~EPOLLOUT;
+ events_ &= ~NET_POLLOUT;
goto done;
}
VLOG(1) << log_prefix_ << ACCEPTOR_CLIENT_IDENT