In event loop condition, only consider spdylay_session_want_{read,write}.

This commit is contained in:
Tatsuhiro Tsujikawa 2012-04-28 01:07:36 +09:00
parent a87303a731
commit 4d8273a052
4 changed files with 10 additions and 2 deletions

View File

@ -236,7 +236,8 @@ int SpdyEventHandler::fd() const
bool SpdyEventHandler::finish() 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) ssize_t SpdyEventHandler::send_data(const uint8_t *data, size_t len, int flags)

View File

@ -336,7 +336,7 @@ int communicate(const std::string& host, uint16_t port,
int timeout = config.timeout; int timeout = config.timeout;
bool ok = true; bool ok = true;
while(sc.want_read() || sc.want_write()) { while(!sc.finish()) {
int nfds = poll(pollfds, npollfds, timeout); int nfds = poll(pollfds, npollfds, timeout);
if(nfds == -1) { if(nfds == -1) {
perror("poll"); perror("poll");

View File

@ -101,6 +101,12 @@ bool Spdylay::want_write()
return spdylay_session_want_write(session_) || 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 int Spdylay::fd() const
{ {
return fd_; return fd_;

View File

@ -49,6 +49,7 @@ public:
ssize_t recv_data(uint8_t *data, size_t len, int flags); ssize_t recv_data(uint8_t *data, size_t len, int flags);
bool want_read(); bool want_read();
bool want_write(); bool want_write();
bool finish();
int fd() const; int fd() const;
int submit_request(const std::string& hostport, const std::string& path, int submit_request(const std::string& hostport, const std::string& path,
uint8_t pri, void *stream_user_data); uint8_t pri, void *stream_user_data);