Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keepalive #5518

Merged
merged 7 commits into from
Aug 23, 2019
Merged

Keepalive #5518

merged 7 commits into from
Aug 23, 2019

Conversation

akashihi
Copy link
Contributor

2056

#2056

A keepalive will be a nice addition to the current http server.

Copy link
Contributor

@gardster gardster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add keep_alive information and corresponding constants (5 seconds, 512 connections to the documentation)

src/server/request_parser.cpp Outdated Show resolved Hide resolved
@akashihi
Copy link
Contributor Author

Please add keep_alive information and corresponding constants (5 seconds, 512 connections to the documentation)

done

@gardster
Copy link
Contributor

Code looks good to me.
Please add the corresponding changelog entry.
Also there are several commits about node flags. Do they relevant for your change?

@akashihi
Copy link
Contributor Author

Please add the corresponding changelog entry.
Done
Also there are several commits about node flags. Do they relevant for your change?
Rebase glitch, should be fixed now

Copy link
Contributor

@gardster gardster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gardster gardster merged commit 88979d0 into Project-OSRM:master Aug 23, 2019
@akashihi akashihi deleted the keepalive branch August 26, 2019 08:08
datendelphin added a commit to fossgis-routing-server/osrm-backend that referenced this pull request Nov 19, 2020
  - Changes from 5.22.0
    - Build:
      - FIXED: pessimistic calls to std::move [Project-OSRM#5560](Project-OSRM#5561)
    - Features:
      - ADDED: new API parameter - `snapping=any|default` to allow snapping to previously unsnappable edges [Project-OSRM#5361](Project-OSRM#5361)
      - ADDED: keepalive support to the osrm-routed HTTP server [Project-OSRM#5518](Project-OSRM#5518)
      - ADDED: flatbuffers output format support [Project-OSRM#5513](Project-OSRM#5513)
      - ADDED: Global 'skip_waypoints' option [Project-OSRM#5556](Project-OSRM#5556)
      - FIXED: Install the libosrm_guidance library correctly [Project-OSRM#5604](Project-OSRM#5604)
      - FIXED: Http Handler can now deal witch optional whitespace between header-key and -value [Project-OSRM#5606](Project-OSRM#5606)
    - Routing:
      - CHANGED: allow routing past `barrier=arch` [Project-OSRM#5352](Project-OSRM#5352)
      - CHANGED: default car weight was reduced to 2000 kg. [Project-OSRM#5371](Project-OSRM#5371)
      - CHANGED: default car height was reduced to 2 meters. [Project-OSRM#5389](Project-OSRM#5389)
      - FIXED: treat `bicycle=use_sidepath` as no access on the tagged way. [Project-OSRM#5622](Project-OSRM#5622)
      - FIXED: fix table result when source and destination on same one-way segment. [Project-OSRM#5828](Project-OSRM#5828)
      - FIXED: fix occasional segfault when swapping data with osrm-datastore and using `exclude=` [Project-OSRM#5844](Project-OSRM#5844)
      - FIXED: fix crash in MLD alternative search if source or target are invalid [Project-OSRM#5851](Project-OSRM#5851)
    - Misc:
      - CHANGED: Reduce memory usage for raster source handling. [Project-OSRM#5572](Project-OSRM#5572)
      - CHANGED: Add cmake option `ENABLE_DEBUG_LOGGING` to control whether output debug logging. [Project-OSRM#3427](Project-OSRM#3427)
      - CHANGED: updated extent of Hong Kong as left hand drive country. [Project-OSRM#5535](Project-OSRM#5535)
      - FIXED: corrected error message when failing to snap input coordinates [Project-OSRM#5846](Project-OSRM#5846)
    - Infrastructure
      - REMOVED: STXXL support removed as STXXL became abandonware. [Project-OSRM#5760](Project-OSRM#5760)
@hy05190134
Copy link

void Connection::start()
29 {
30 TCP_socket.async_read_some(
31 boost::asio::buffer(incoming_data_buffer),
32 strand.wrap(boost::bind(&Connection::handle_read,
33 this->shared_from_this(),
34 boost::asio::placeholders::error,
35 boost::asio::placeholders::bytes_transferred)));
36
37 if (keep_alive)
38 {
39 // Ok, we know it is not a first request, as we switched to keepalive
40 timer.cancel();
41 timer.expires_from_now(boost::posix_time::seconds(keepalive_timeout));
42 timer.async_wait(std::bind(
43 &Connection::handle_timeout, this->shared_from_this(), std::placeholders::_1));
44 }
45 }
46
47 void Connection::handle_read(const boost::system::error_code &error, std::size_t bytes_transferred)
48 {
49 if (error)
50 {
51 return;
52 }
53
54 if (keep_alive)
55 {
56 timer.cancel();
57 timer.expires_from_now(boost::posix_time::seconds(0));
58 }

I wonder the keepalive whether work since you set expire_from_now in start() then expires_from_now in handle_read(), but every start() will execute handle_read()

@hy05190134
Copy link

@akashihi @gardster

@hy05190134
Copy link

void Connection::handle_read(const boost::system::error_code &error, std::size_t bytes_transferred)
48 {
49 if (error)
50 {
51 return;
52 }
53

when read some bytes error, why not execute handle_shutdown right now?

@mjjbell
Copy link
Member

mjjbell commented Feb 17, 2022

when read some bytes error, why not execute handle_shutdown right now?

This was added recently to fix a file exhaustion issue - see #6112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants