From 4d8273a05254d6f7dc6cdedcbc62611d94a8f039 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 28 Apr 2012 01:07:36 +0900 Subject: [PATCH] In event loop condition, only consider spdylay_session_want_{read,write}. --- examples/SpdyServer.cc | 3 ++- examples/spdycat.cc | 2 +- examples/spdylay_ssl.cc | 6 ++++++ examples/spdylay_ssl.h | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/SpdyServer.cc b/examples/SpdyServer.cc index 846ed863..3ce11bd7 100644 --- a/examples/SpdyServer.cc +++ b/examples/SpdyServer.cc @@ -236,7 +236,8 @@ int SpdyEventHandler::fd() const bool SpdyEventHandler::finish() { - return !want_read() && !want_write(); + return !spdylay_session_want_read(session_) && + !spdylay_session_want_write(session_); } ssize_t SpdyEventHandler::send_data(const uint8_t *data, size_t len, int flags) diff --git a/examples/spdycat.cc b/examples/spdycat.cc index 692a65a1..f8d74702 100644 --- a/examples/spdycat.cc +++ b/examples/spdycat.cc @@ -336,7 +336,7 @@ int communicate(const std::string& host, uint16_t port, int timeout = config.timeout; bool ok = true; - while(sc.want_read() || sc.want_write()) { + while(!sc.finish()) { int nfds = poll(pollfds, npollfds, timeout); if(nfds == -1) { perror("poll"); diff --git a/examples/spdylay_ssl.cc b/examples/spdylay_ssl.cc index 64f50c1a..105e778c 100644 --- a/examples/spdylay_ssl.cc +++ b/examples/spdylay_ssl.cc @@ -101,6 +101,12 @@ bool Spdylay::want_write() return spdylay_session_want_write(session_) || want_write_; } +bool Spdylay::finish() +{ + return !spdylay_session_want_read(session_) && + !spdylay_session_want_write(session_); +} + int Spdylay::fd() const { return fd_; diff --git a/examples/spdylay_ssl.h b/examples/spdylay_ssl.h index 84afdd08..961e3f72 100644 --- a/examples/spdylay_ssl.h +++ b/examples/spdylay_ssl.h @@ -49,6 +49,7 @@ public: ssize_t recv_data(uint8_t *data, size_t len, int flags); bool want_read(); bool want_write(); + bool finish(); int fd() const; int submit_request(const std::string& hostport, const std::string& path, uint8_t pri, void *stream_user_data);