fixed unit test
This commit is contained in:
parent
167fc021ac
commit
0f6b34c260
|
@ -689,6 +689,7 @@ void send_content(socket_type& s, char const* file, int size, bool chunked)
|
||||||
|
|
||||||
void on_read(error_code const& ec, size_t bytes_transferred, size_t* bt, error_code* e, bool* done)
|
void on_read(error_code const& ec, size_t bytes_transferred, size_t* bt, error_code* e, bool* done)
|
||||||
{
|
{
|
||||||
|
DLOG(stderr, "on_read %d [ ec: %s ]\n", int(bytes_transferred), ec.message().c_str());
|
||||||
*bt = bytes_transferred;
|
*bt = bytes_transferred;
|
||||||
*e = ec;
|
*e = ec;
|
||||||
*done = true;
|
*done = true;
|
||||||
|
@ -697,6 +698,7 @@ void on_read(error_code const& ec, size_t bytes_transferred, size_t* bt, error_c
|
||||||
void on_read_timeout(error_code const& ec, bool* timed_out)
|
void on_read_timeout(error_code const& ec, bool* timed_out)
|
||||||
{
|
{
|
||||||
if (ec) return;
|
if (ec) return;
|
||||||
|
fprintf(stderr, "read timed out\n");
|
||||||
*timed_out = true;
|
*timed_out = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,10 +870,11 @@ void web_server_thread(int* port, bool ssl, bool chunked)
|
||||||
size_t received = 0;
|
size_t received = 0;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
bool timed_out = false;
|
bool timed_out = false;
|
||||||
|
DLOG(stderr, "async_read_some %d bytes [ len: %d ]\n", int(sizeof(buf) - len), len);
|
||||||
s.async_read_some(boost::asio::buffer(&buf[len]
|
s.async_read_some(boost::asio::buffer(&buf[len]
|
||||||
, sizeof(buf) - len), boost::bind(&on_read, _1, _2, &received, &ec, &done));
|
, sizeof(buf) - len), boost::bind(&on_read, _1, _2, &received, &ec, &done));
|
||||||
deadline_timer timer(ios);
|
deadline_timer timer(ios);
|
||||||
timer.expires_at(time_now() + seconds(2));
|
timer.expires_at(time_now_hires() + seconds(100));
|
||||||
timer.async_wait(boost::bind(&on_read_timeout, _1, &timed_out));
|
timer.async_wait(boost::bind(&on_read_timeout, _1, &timed_out));
|
||||||
|
|
||||||
while (!done && !timed_out)
|
while (!done && !timed_out)
|
||||||
|
|
Loading…
Reference in New Issue