Commit Graph

38 Commits

Author SHA1 Message Date
Amnon Heiman
427a6165b3 using the routes and request from the http directory
This use the routes and the reqeuest found in the http directory and
move all files but main to the http directory

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-03-08 21:55:57 +02:00
Amnon Heiman
100a667ab8 httpd to use the reply class and support error code 2015-03-08 21:55:57 +02:00
Amnon Heiman
8a760f23f9 Break the httpd implementation to a library/main
We would like to extend the httpd capabilities and use it for the API
implementation.

The first step is to make it a library with main that calls an instanse.
This break the implementation to a header file, implementation and main,
that simply calls the implementation.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-03-08 21:55:57 +02:00
Amnon Heiman
722bf0fe1f request_parser is missing pragma once 2015-03-08 21:55:57 +02:00
Tomasz Grabiec
83963b23d3 Replace rescue() usages with then_wrapped()
They are pretty much the same. This change removes rescue().
2015-03-04 17:34:59 +01:00
Avi Kivity
7f8d88371a Add LICENSE, NOTICE, and copyright headers to all source files.
The two files imported from the OSv project retain their original licenses.
2015-02-19 16:52:34 +02:00
Avi Kivity
ee58c77008 httpd: fix unbounded memory use in eerror handling
httpd uses recursion for its read loop:

  future<> read() {
     _read_buf.consume().then([] {
        ...
        if more work:
           return read();
     });
  }

However, after error handling was added, it looks like this:

  future<> read() {
     _read_buf.consume().then([] {
        ...
        if more work:
           return read();
     }).rescue(...);
  }

The problem is that rescue() is called for every iteration of the loop,
instead of for the loop in its entirety.  This means that a rescue
continuation is allocated for every processed request, but they will only
be called after the entire loop terminates.  This results in tons of
allocated memory.

Fix by moving error handling to the end of the loop (and incidentally using
do_until() instead of recursion).
2015-02-10 12:00:32 +02:00
Asias He
2289b03354 httpd: Fix RST handling
I found wrk sometimes sends RST instead a FIN to close a connection. In
this case, we will reset the connection and go to CLOSED state. However
httpd will not delete this, so we will have leaked connections in CLOSED
state.

Fix by handling the exception and sending an empty response as we do in
EOF case. Here we do not pass the exception to upper layer again,
otherwise httpd will be very noise.
2015-02-05 16:57:58 +08:00
Avi Kivity
24d5c319a3 httpd: return Server and Date headers
Required by some benchmarks.
2015-01-27 18:57:59 +02:00
Gleb Natapov
7a92efe8d1 core: add local engine accessor function
Do not use thread local engine variable directly, but use accessor
instead.
2015-01-27 14:46:49 +02:00
Takuya ASADA
e1552ad3b6 core: rename smp.hh to distributed.hh
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-01-14 11:16:09 +02:00
Avi Kivity
6b5973af70 app-template: don't alias boost::program_options as bpo in a header file
We only have one global namespace, let's work together to keep it free
of pollution.
2014-12-01 17:56:34 +02:00
Avi Kivity
0903e36179 httpd: export statistics via collectd 2014-11-23 19:28:54 +02:00
Avi Kivity
6f48e27bfd httpd: simplify connection termination
The current implementation uses a sort of "manual reference counting"; any
place which may be the last one using the connection checks if it is indeed
the last one, and if so, deletes the connection object.

With recent changes this has become unwields, as there are too many cases
to track.

To fix, we separate the connection into two streams: a read() stream that
is internally serialized (only one request is parsed at a time) and that
returns when there are no more requests to parse, and a respond() stream
that is also internally serialized, and termiantes when the last response
has been written.  The caller then waits on the two streams with when_all().
2014-10-30 14:09:47 +02:00
Avi Kivity
4af8036677 http: convert to use distributed<> infrastructure 2014-10-26 13:34:31 +02:00
Asias He
c3d225eb5f httpd: Support close initiated on server side
This makes ab work:

$ ab -n 1000 http://ip:10000/
2014-10-23 12:57:32 +03:00
Asias He
0b3fc256b6 httpd: Drop dead code 2014-10-23 10:30:40 +03:00
Asias He
b7ab4621fe httpd: Allow tune the http server port 2014-10-23 10:30:40 +03:00
Asias He
5d19306435 httpd: Delete connection when client closes
When client closes the connection in one direction, make httpd close the
other direction too. This way, httpd will send back a <FIN> packet to
client after receiving client's <FIN> packet.
2014-10-22 10:27:27 +03:00
Tomasz Grabiec
5d6eaaea33 ragel: reset string builder on init
Otherwise it will contain stale data from previous unsuccessful pass.
2014-10-16 12:24:30 +02:00
Tomasz Grabiec
eac955cc73 core: simplify output_stream::write() and flush() results
The result is not used for anything and I am not sure what it could be
used for, as the result carries little (write) to none (flush)
information. So I went ahead and simplified it to be future<> so that
it is easier to return it in places which expect future<>.
2014-10-09 20:02:11 +03:00
Gleb Natapov
304f6a317e Run httpd on all available cpus 2014-10-07 11:04:07 +03:00
Tomasz Grabiec
3775dae6fb net: convert ipv4_addr.host from array to uint32_t
It will be easier to convert it to a format on which the native stack
works.
2014-10-06 18:34:28 +02:00
Avi Kivity
c8b602e713 httpd: switch to circular_buffer 2014-10-02 14:32:34 +03:00
Avi Kivity
1472c24533 httpd: replace custom parser with Ragel based parser 2014-09-29 15:17:42 +03:00
Tomasz Grabiec
4f94fc46ce httpd: use app_template 2014-09-24 15:11:35 +03:00
Gleb Natapov
736b07b2b6 Run http with smp
This patches shows what change is needed for http to run with multiple
event loops. This is not very useful still because actual work is not
yet distributed.
2014-09-24 13:12:38 +03:00
Avi Kivity
46402831ae httpd: remove unused fields to make clang happy 2014-09-22 17:18:06 +03:00
Tomasz Grabiec
52ab797536 rename engine::start() to engine::when_started()
The imperative form suggests that in addition to returning a future it
performs some action and thus is needed regardless of whether we want
to add a callback or not. But in fact it does not do anything, just
gives away a future.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
2014-09-16 09:59:13 +03:00
Avi Kivity
e0c111563f httpd: simplify exception handler
No need to rename 'this' (still strange that it has to be used as
this->maybe_done()).
2014-09-15 09:50:13 +03:00
Avi Kivity
b81869e541 httpd: use modern future chaining style
There's no need to create a temporary promise and pass it around; instead
use future chaining to accomplish the same result.
2014-09-15 09:43:15 +03:00
Asias He
9b294f2829 httpd: Print port info on startup
Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
2014-09-13 07:23:40 +03:00
Avi Kivity
b6d85fc6a6 s/the_reactor/engine/g
Things named "engine" are 20% faster.
2014-09-10 15:46:33 +03:00
Avi Kivity
bb26a0c08a httpd: allow switching network stack 2014-09-10 13:46:54 +03:00
Avi Kivity
3b0a9d89d9 core: abstract connected sockets
Instead of returning a pollable_fd from server_socket::accept(), return
a new abstract class connected_socket, which is able to provide an
input_stream and an output_stream to the caller.
2014-09-04 12:31:02 +03:00
Avi Kivity
6c1aabd7e1 core: abstrace reactor::listen()
Instead of returning the Unix-tied pollable_fd, return an abstract
server_socket class which is then implement atop pollable_fd, but can
be replaced with a native implementation.
2014-09-04 12:11:17 +03:00
Avi Kivity
065de692db core: rename input_stream_buffer and output_stream_buffer
Since they are going to be the abstract interface to both the bsd socket
layer and the native tcp stack, rename them to more generic names -
input_stream and output_stream.
2014-09-04 11:24:08 +03:00
Avi Kivity
c77f77ee3f build: organize files into a directory structure 2014-08-31 21:29:13 +03:00