Skip to content

CPU usage 100% ( Request hangs ) #496

@spritab

Description

@spritab

The http client application hangs in infinite loop in io_service::run, if server accept connection and do nothing. There are no reaction on closing socket at server side.
You can reproduce this using following steps:

  • run server using command at separate terminal:
while true; do echo "" | nc -l 8091; done
  • compile and run the program:
// main.cpp 
#include <iostream>
#include <boost/network/include/http/client.hpp>
int main ( int argc, char *argv[] )
{
  typedef boost::network::http::basic_client<
      boost::network::http::tags::http_async_8bit_tcp_resolve, 1, 1> 
      Client;
  Client client;
  Client::request req("http://localhost:8091");
  Client::response resp = client.get(req);
  std::cout << body(resp) << std::endl;
  return 0;
}

This program will work forever ( ever you terminate netcat ), and you can observe 100% CPU usage by this program at top utility.
system: Ubuntu 14.04 LTS 64bit
boost version: 1.54
cpp-netlib version: 0.11-devel (cpp-netlib-0.11.1-final also consists this isssue)

$ cat /usr/include/boost/version.hpp  | fgrep "#define BOOST_LIB_VERSION"
#define BOOST_LIB_VERSION "1_54"
$ git rev-parse HEAD
6e090b3d0b3c4f3b132432a6763594593cf7f365
$ git branch
* 0.11-devel
$ g++ --version
g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2

Jetty shows such server behaivior, when there are lack of memory.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions