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()
{
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)

View File

@ -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");

View File

@ -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_;

View File

@ -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);