Commit Graph

1820 Commits

Author SHA1 Message Date
Avi Kivity
c1906a3d2a future: add futurize::make_exception_future()
Add a way to create an exceptional future of a type that is not directly
known.
2015-07-18 11:14:19 +03:00
Avi Kivity
f2577c8af3 function_traits: export the function signature as a type
This makes it easy to further examine using pattern matching instead
of std::index_sequence.
2015-07-18 11:14:19 +03:00
Tomasz Grabiec
db331efaa1 tests: Add test for exception propagation from make_lw_shared() 2015-07-17 16:31:43 +03:00
Tomasz Grabiec
0bfcf27b15 core: lw_shared_ptr: Don't mark make() as noexcept
The constructor or operator new may throw, and we don't want to
std::terminate() on that occasion.
2015-07-17 16:31:42 +03:00
Avi Kivity
2878bc887d Merge "Add rpc/rpc_types.hh" from Asias 2015-07-16 10:04:32 +03:00
Asias He
624388ae4b rpc: Move stats to rpc_types.hh
It will be needed by user does not want to include rpc.hh
2015-07-16 14:55:51 +08:00
Asias He
6ad04ff5e8 rpc: Introduce rpc/rpc_types.hh
Include rpc_types.hh instead of rpc.hh when no_wait_type and friends are
needed.
2015-07-16 14:55:50 +08:00
Avi Kivity
f256243ebd memory: fix debug build break (statistics) 2015-07-15 18:17:49 +03:00
Avi Kivity
248aa4f55e reactor: wire up free memory and reclaim counters to collected 2015-07-15 18:09:13 +03:00
Avi Kivity
a597d37bc1 memory: add statistics for reclaim operations and free memory 2015-07-15 18:08:54 +03:00
Amnon Heiman
53745dc357 Adding a void_json object to the json_elements
There are cases where a handler that returns a json element needs to
return a successfull empty response. This is common in async operation.
Though it is legit to return an empty string in this situation, it is
cleaner to return an empty response.

This adds a json_void class, that a method that needs to return a value
(i.e. the json_function) can return and the formatter will set the
response to empty.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-07-14 11:22:32 +03:00
Amnon Heiman
7b355a6a02 json-api: Add an assignment operator to the json_list obj
This patch adds a general assignment operator to the json_list object.
It can accept any data structure that support const range iteration and
that its contained object can be assigned to the json_list object.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-07-14 10:41:40 +03:00
Glauber Costa
62364fcdd7 sstring: add compare method for parts of a sstring
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-14 09:26:03 +03:00
Avi Kivity
66451d5a9c tcp: fix assertion failure on connection reset
The connection reset code posted an exception on the _data_received promise
to break a waiter (if any), but left the optional<promise<>> engaged.  This
caused the connection destructor to attempt to post a new exception on the
same promise, which is not legal.

Fix by disengaging the optional promise, and give the same treatment to
_all_data_acked_promise.
2015-07-13 19:07:35 +03:00
Glauber Costa
d162922e03 core: simplify do_flush_directory
files can be copied now. No need to play the unique_ptr card anymore.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-12 19:58:31 +03:00
Avi Kivity
2a622304ed file: make files copyable
Often a single file is used in multiple fibers, and so it is wrapped in a
lw_shared_ptr.  Remove the need for this by making files internally reference
counted.
2015-07-12 18:11:46 +03:00
Glauber Costa
50e2f24dfa core: add recursive_touch directory
Often, when we create a directory, it is useful to make sure that the path
leading to it exists.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-12 18:05:08 +03:00
Avi Kivity
c84b6a948f Merge "fstream optimizations"
file::size() was excessively slow, and fstreams were needlessly calling
it.  Optimize file::size(), and also make fstream not call it.
2015-07-12 16:56:01 +03:00
Avi Kivity
35f29dcdb4 fstream: add read-until-end tests without knowning the file size beforehand 2015-07-12 16:52:24 +03:00
Avi Kivity
d170efbfcb fstream: optimize file_data_source_impl
file_data_source_impl always calls file::size(), which can be slow.  This
slows down applications that create many short-lived input streams on the
same file (for random-access processing of a subset of the data).

Fix by not calling size(), and letting the file code handle short reads
itself.
2015-07-09 18:40:05 +03:00
Avi Kivity
ea67ca03af file: fix file::size() signature
file::size() uses size_t as an alias for uint64_t, but it isn't.  Use the
right type.
2015-07-09 15:07:58 +03:00
Avi Kivity
e96d07d614 file: optimize file::size() for posix
lseek() won't block, so use it for fetching the size of a file directly
from the reactor thread, instead of an iothread.
2015-07-09 15:01:42 +03:00
Nadav Har'El
913ee1e8ac reactor: circumvent ASAN false positive
Our debugging builds always produce the annoying false warning like:

==1199==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x62300003d500

This error could be silenced by setting ASAN_OPTIONS=alloc_dealloc_mismatch=0
(and we do this in test.py), but it's still annoying for manual runs, and
can mask real bugs of this type.

The problem appears to be that the address sanitizer doesn't understand
our new(with_align(..)) trick we used to allocate the reactor object,
and when we eventually use ordinary "delete" on this object, it thinks
we mixed malloc and delete.

This patch uses posix_memalign() and free() to allocate and free the
reactor structure, and ASAN stops complaining.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-07-08 11:02:19 +03:00
Avi Kivity
19206a038f reactor: stop using SIGALRM
SIGALRM is used by the boost unit test library, which interferes with our
use.  This causes spurious unit test failures.

Switch to a real-time signal instead.
2015-07-07 18:00:35 +03:00
Avi Kivity
7ad4483879 Revert "build: allow the compiler to be a script"
This reverts commit 68b192d1be5efb50e49e46f19370ed49d9d28e30; it fails
unconditionally, causing debug symbols (for example) not to be emitted.
2015-07-07 17:17:46 +03:00
Gleb Natapov
3dbccbc5b5 rpc: read value from a tuple before moving it
Noticed by Tomek.
2015-07-07 13:21:11 +03:00
Nadav Har'El
9b63b02328 doc: fix small mixup in reference (pipe.hh)
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-07-07 12:57:09 +03:00
Avi Kivity
0c848e9a4e rpc: add missing move()s in get_reply()
If the reply is a movable-but-not-copyable type, then we must move it into
the returned future.  Also faster even if the type is copyable.
2015-07-07 12:56:33 +03:00
Avi Kivity
af30fe11df doc: more info in fiber module reference table 2015-07-07 00:38:53 +03:00
Avi Kivity
1501b273f6 doc: add reference section to fiber module 2015-07-07 00:29:23 +03:00
Avi Kivity
89931d53fa semaphore: document 2015-07-07 00:10:51 +03:00
Avi Kivity
5338a6a8db Merge branch 'master' of github.com:cloudius-systems/seastar 2015-07-06 11:12:36 +03:00
Amnon Heiman
2c08647a6e scollectd: change get_collectd_value() to use const ref
After the implementation of the code that uses the scollectd API was
modified, the get_collectd_value gets the collectd ID as a const
reference, to remove unnessary creation of shared_ptr.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
2015-07-06 11:09:32 +03:00
Raphael S. Carvalho
f6fdde0ff6 core: make gate_closed_exception::what a public member
gate_closed_exception::what() is currently a private member, thus
calling the method when handling the exception isn't possible.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-07-06 10:25:21 +03:00
Avi Kivity
68b192d1be build: allow the compiler to be a script 2015-07-06 10:24:54 +03:00
Glauber Costa
a4a23f8eb0 gate: introduce with_gate idiom
Execute a function making sure it is wrapped in a gate.

This can afford to be considerably simpler than do_with, since we are not
playing any games with object creation, and the gate itself can be assumed to
be relatively long lived.

Among other things, this will allow us to make changes to enter / leave without
breaking existing code, and experiment with stronger ways of doing leave - as
Avi suggested recently.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-05 19:07:08 +03:00
Avi Kivity
b67cded40d tests: print error code for failed test 2015-07-05 17:50:53 +03:00
Takuya ASADA
15d009d39e udp: auto close on destruction of channel
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
2015-07-05 11:30:08 +03:00
Gleb Natapov
d0003e4f29 rpc: handler smart pointer return value from rpc handler
Currently if rpc handler returns smart pointer rpc will try to serialize
the pointer object as opposite to an object the ptr is pointing to.
This patch fixes it by serializing real object instead of a pointer.
2015-07-02 16:46:23 +03:00
Gleb Natapov
7d33cf62a5 Add is_smart_ptr metafunction to detect know smart pointers objects 2015-07-02 16:46:23 +03:00
Avi Kivity
033e46c7b0 sharded: speed up compilation
- unify three invoke_on() variants by using futurize<>
 - move type calculation out of method signature
2015-07-02 15:33:35 +03:00
Avi Kivity
00da6d85c3 future: optimize for compile time
.then()'s return type is a complex template, which needs to be mangled into
the function's name.  Move the return type into a defaulted template type
parameter, so that the entire type expression is eliminated, being replaced
by the result type.

Saves about 1% compile time and 3% object size on futures_test.o.
2015-07-02 12:47:07 +03:00
Glauber Costa
641034075b sprint: use sstring as a parameter to sprint
We can use sstring as an argument to sprint. In some cases, we already have the
string in a variable and end up being forced to call c_str() from the caller
site. Accepting sstring as a parameter makes for a cleaner interface.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-06-30 19:11:18 +03:00
Nadav Har'El
770e6b7816 future: add handle_exception() method
This patch adds a "class future" method for handling an exception result
of the future. It is impossible to discard a future's exception while passing
through the value of the result (what will we pass in the case of
exception?), so we discard the result as well.

An example of how this can be used, to log an error (but otherwise do
nothing) if removing a file fails:

  remove_file(filename).handle_exception(
    [] (std::exception_ptr eptr) {
      print("Exception when deleting file: %s", eptr);
    });

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-06-30 14:57:53 +03:00
Avi Kivity
7842ac8db6 doc: document file I/O 2015-06-28 22:42:06 +03:00
Avi Kivity
8ca32adbde Merge "file::close() support"
close() is a blocking call, so it must be called in the I/O thread, not
the main reactor thread.  To do that, we need a file::close() method that
can return a future.
2015-06-28 21:50:46 +03:00
Avi Kivity
ae38e95bb2 file: uninline posix_file_impl destructor 2015-06-28 20:42:30 +03:00
Avi Kivity
7e66cc02e1 tests: close file in fileiotest 2015-06-28 20:40:37 +03:00
Avi Kivity
8039544806 file: warn if file::close() was not called in time 2015-06-28 20:39:06 +03:00
Avi Kivity
c05c7c09cf fstream: close file on stream close 2015-06-28 20:36:23 +03:00