Commit Graph

767 Commits

Author SHA1 Message Date
Tomasz Grabiec
14a8110d1f future: Avoid copying of the result in get0()
Even though we accept std::tuple<T...>&&, 'x' is an l-value reference
inside get0().
2015-06-23 14:28:01 +03:00
Avi Kivity
ab7be2890f core: rename distributed<Service> to seastar::sharded<Service>
distributed<> has the connotation of being distributed across the network.
Sharded is more in line with seastar terms.

Keep the distributed<> name and header file as an alias, for
compatibility.
2015-06-22 12:58:56 +03:00
Avi Kivity
b879fabf36 reactor: block SIGALRM while we're still not ready to handle it
If some code sets up a timer before we've set up the SIGALRM signal handler,
we die.  Block it in the meantime.
2015-06-22 12:48:50 +03:00
Tomasz Grabiec
e5e7348f76 core: Reimplement keep_doing() using repeat() 2015-06-22 09:08:38 +02:00
Tomasz Grabiec
61992f84c5 core: Introduce repeat()
It's like do_until(), but the stop condition is calculated by the
callback instead of being supplied separately.
2015-06-22 09:08:38 +02:00
Avi Kivity
bd3044a38d do_with: doc: mark cherry_pick_tuple as internal 2015-06-21 23:37:12 +03:00
Avi Kivity
9679075b30 shared_mutex: reinstate FIFO ordering
Noticed by Nadav.
2015-06-21 20:54:53 +03:00
Avi Kivity
18fd73b065 gate: fix doc typo 2015-06-21 20:36:15 +03:00
Avi Kivity
a2ec5ebe87 doc: add gate class to fiber module 2015-06-21 20:35:54 +03:00
Avi Kivity
ac94c1d68e doc: add fiber module to main page 2015-06-21 20:33:34 +03:00
Avi Kivity
d9bfbe55c8 core: introduce shared_mutex class
Similar to std::shared_mutex, allows shared and exclusive locking of a
resource (also known as a reader/writer lock).  This implementation is
strictly FIFO.
2015-06-21 20:28:43 +03:00
Avi Kivity
a99956db8e future-util: implement range-based map_reduce() variant 2015-06-21 20:21:24 +03:00
Avi Kivity
33a4f1b32b reactor: move destructor to .cc file
It's totally uninteresting to anyone else.
2015-06-21 18:02:28 +03:00
Avi Kivity
cebe81082b reactor: destroy system timer in destructor
Keeping the timer armed can cause a signal to be sent, which will not
be handled, terminating the program too early.
2015-06-21 17:59:18 +03:00
Avi Kivity
614da559d0 semaphore: provide broken() variant accepting an std::exception_ptr 2015-06-21 11:44:57 +03:00
Nadav Har'El
9b884b3435 reactor: more information on ignored exceptional future
When an exceptional future is ignored, we print a message, and for an
std::exception we print its what(). However, it would be useful to also
see the exception's type. We already had such exception type printing
code for engine_exit(), and this patch extracts that code into a separate
function, and also uses it to print the warning message when an exceptional
future is ignored.

For example, in one test before this patch I see:
 WARNING: exceptional future ignored: _Map_base::at

After this patch,
 WARNING: exceptional future ignored of type 'std::out_of_range': _Map_base::at

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-06-20 11:07:09 +03:00
Nadav Har'El
13a68fa62c pipe: fix syntax error in pipe reader
I'm not sure how my compiler didn't complain earlier...

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-06-20 11:07:06 +03:00
Avi Kivity
39218c32f7 core: extend do_with() to support multiple parameters
do_with(1, 2, 3, [] (int& v1, int& v2, int& v3) {
      return make_ready_future<int>(v1 + v2 + v3);
  });
2015-06-19 20:24:56 +03:00
Avi Kivity
6595ad0bde core: introduce gate class
Gate allows stopping new incoming requests, and detecting when the last
in-progress request has left.
2015-06-19 19:03:15 +03:00
Nadav Har'El
2f4e123eab core: pipe for passing data between fibers
Our queue<T> is a convenient mechanism for passing data between a producer
fiber (a set of consecutive continuations) and a consumer fiber.

However, queue<T> is difficult to use *correctly*. The biggest problem is
how to handle premature stopping: What if one of the two fibers (the reader
or the writer) stops prematurely, and will never read or write any more?
When queue<T> is used naively, the other fiber will just hang indefinitely
while it waits to read from the empty queue, or write to the full queue.

The solution proposed in this patch is a new pipe mechanism, implemented
internally over a queue. pipe<T>() returns two separate objects - a pipe
reader, and a pipe writer. Typically each object is std::move()ed into a
different fiber. When a fiber stops and its captured variables are destroyed,
one end of the pipe is destroyed, and that causes the other end's operations
to return immediately (if the other end was already blocked, it will resume
immediately, and return an exceptions). This behavior is analogous to
Unix's EOF or broken-pipe behavior.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-06-19 19:03:13 +03:00
Gleb Natapov
f7f445d563 distributed: deallocate _instance array during stop.
Otherwise tester may crash if _instances destructor is called when thread
responsible for the allocation (which tester spawned to run seastar in)
no longer running.
2015-06-18 14:43:38 +03:00
Gleb Natapov
3c4dcd871a add default and move constructor/assignment to server_socket 2015-06-18 14:43:16 +03:00
Glauber Costa
92803a2db3 touch_directory: EEXIST-ignoring make directory
There are many situations in which we would like to make sure a directory
exists.  We can do that by creating the directory we want, and just ignoring
the relevant error.

It is a lot of code though, and I believe it is an idiom common enough to exist
on its own.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-06-18 12:51:49 +03:00
Raphael S. Carvalho
534401c91f fstream: use dma_alignment constant instead of a hardcoded value
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-06-18 12:49:33 +03:00
Raphael S. Carvalho
02bdf380c4 fstream: abort instead of silently returning a ready future
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-06-18 12:49:33 +03:00
Gleb Natapov
a2c1ab66b7 semaphore: fix access to freed memory in wait(timeout)
wait() with timeout takes reference to an entry, but when
circular_buffer is resized it may be moved, so freed instance will be
accessed on timeout. Fix it by using std::list instead.
2015-06-18 12:35:25 +03:00
Tomasz Grabiec
cf42e4c1a4 core: Fix enable_lw_shared_from_this<T>::shared_from_this() const
Compilation failed when shared_from_this() was called on a const object.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
2015-06-16 20:32:08 +03:00
Tomasz Grabiec
8efcec1949 core: enable_lw_shared_from_this: Add missing move and copy constructors
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
2015-06-16 20:32:07 +03:00
Avi Kivity
c477f0e208 thread: remove obsolete FIXME 2015-06-16 17:10:22 +03:00
Avi Kivity
edcd346d83 thread: fix thread-created-within-thread
The thread switching code assumed that we will always switch out of a
thread due to being blocked on an unavailable future.  This allows
the core to store the blocked thread's context in the synthetic
continuation chained to that future (which switched back to that thread).

That assumption failed in one place: when we create a thread from within a
thread.  In that case we switch to the new thread immediately, but forget
all about the old thread.  We never come back to the old thread, and anything
that depends on it hangs.

Fix by creating a linked list of active thread contexts.  These are all
threads that have been "preempted" by the act of creating a new thread,
terminated by the main, unthreaded, reactor context.  This gives us a place
to store those threads and we come back to them and continue where we left
off.

Reported by Pekka.
2015-06-16 17:04:02 +03:00
Avi Kivity
201486ad89 Merge branch 'master' of github.com:cloudius-systems/seastar 2015-06-16 15:37:16 +03:00
Avi Kivity
8dc71b7b8b net: wire up connected_socket shutdown methods and expose to user 2015-06-16 12:02:32 +03:00
Avi Kivity
661d459fff net: wire up server_socket shutdown method and expose to callers 2015-06-16 12:02:30 +03:00
Avi Kivity
f0ae995817 distributed: document 2015-06-15 23:17:06 +03:00
Avi Kivity
31d3801215 reactor: wire up shutdown() on pollable_fd 2015-06-15 16:38:52 +03:00
Avi Kivity
2a24e8f5ca reactor: add methods to abort futures waiting on fd event
If they're waiting, blow them away with an exception, and unsubscribe the
events from epoll.
2015-06-15 16:37:43 +03:00
Avi Kivity
1b99b1f170 queue: add method to abort a queue
Destroy all queued objects, blow waiting readers or writers with an
exception.
2015-06-15 16:35:48 +03:00
Avi Kivity
c653cc1910 posix: wire up shutdown() API 2015-06-15 16:35:22 +03:00
Avi Kivity
a4c711afd4 future: fix future<>::get0()
Empty tuples don't have a first element.
2015-06-15 11:43:38 +03:00
Avi Kivity
ddaaa315c8 future: add a get0() helper to get the first/only member of the result tuple
Reviewed-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-15 11:29:02 +03:00
Avi Kivity
053566b3e9 deleter: document 2015-06-15 08:47:44 +03:00
Avi Kivity
1769cb4520 temporary_buffer: document 2015-06-14 23:52:25 +03:00
Avi Kivity
25420a6fdf core: add support for --cpuset command line option
Syntax: [cpu-]cpu(,[cpu-]cpu=)...
Default: all processors
2015-06-14 16:11:31 +03:00
Avi Kivity
f85a2b48bb resource: support using only a subset of a machine's processors
This is useful for running multiple seastar applications on the same
machine, for testing purposes.
2015-06-14 16:10:21 +03:00
Gleb Natapov
361db498d1 semaphore: add wait() with timeout support 2015-06-14 16:02:19 +03:00
Gleb Natapov
f19ba7c334 Add timer move constructor 2015-06-14 16:02:18 +03:00
Gleb Natapov
1b2bf57a2b move timer out of reactor.hh to its own header 2015-06-14 16:02:16 +03:00
Avi Kivity
0b0ad13418 doc: prevent -- from becoming an emdash 2015-06-14 09:20:38 +03:00
Avi Kivity
5251c2523a thread: point out async() as an easy way to launch a thread 2015-06-14 09:14:30 +03:00
Avi Kivity
980a7dc881 thread: more documentation 2015-06-14 08:56:42 +03:00