Commit Graph

105 Commits

Author SHA1 Message Date
Alex Young
9002341e77 Fix the broken --rebind-port command-line option. 2012-07-12 10:45:19 +01:00
Alex Young
eb90308b6e Handle a failed disconnect correctly
If the sender disconnects its socket before sending the disconnect
message, the destination should restart the migration process.  This
patch makes sure that happens.
2012-07-12 09:39:39 +01:00
Alex Young
f3cebcdcd5 Test a source crashing after an entrust.
This adds a test for destination behaviour, in that if a source crashes
after sending an entrust message but before the destination can reply,
the destination must allow the source to reconnect and retry the mirror.
2012-07-11 15:19:50 +01:00
Alex Young
f3f017a87d Free all possibly held mutexes in error handlers
Now that we have 3 mutexes lying around, it's important that we check
and free these if necessary if error() is called in any thread that can
hold them.  To do this, we now have flexthread.c, which defines a
flexthread_mutex struct.  This is a wrapper around a pthread_mutex_t and
a pthread_t.  The idea is that in the error handler, the thread can
check whether it holds the mutex and can free it if and only if it does.
This is important because pthread fast mutexes can be freed by *any*
thread, not just the thread which holds them.

Note: it is only ever safe for a thread to check if it holds the mutex
itself.  It is *never* safe to check if another thread holds a mutex
without first locking that mutex, which makes the whole operation rather
pointless.
2012-07-11 09:43:16 +01:00
Alex Young
d16aebf36e Test that a disconnect after the write request but before the data is an error 2012-07-03 15:25:39 +01:00
Alex Young
ea4642a878 Check that a mirror write returning an error will cause a reconnect and retry 2012-07-02 15:04:45 +01:00
Alex Young
9850f5d0a4 Test that timing out a write causes a disconnect and a reconnect 2012-06-28 14:45:53 +01:00
Alex Young
4de4cee3d0 Test for acl rejection 2012-06-28 13:29:22 +01:00
Alex Young
c9fdd5a60e Handle ECONNRESET during a read request 2012-06-28 11:46:02 +01:00
Alex Young
cea9d97086 Missing file 2012-06-27 16:19:13 +01:00
Alex Young
ac3e6692a8 make sure that an invalid flexnbd signal fd can't break the serve accept loop 2012-06-27 16:17:51 +01:00
Alex Young
94b4fa887c Add mboxes 2012-06-27 15:45:33 +01:00
Alex Young
2078d17053 connect failure scenarios 2012-06-22 10:05:41 +01:00
Alex Young
80f298f6cd Make non-fatal errors return properly 2012-06-21 18:01:56 +01:00
Alex Young
f37a217cb9 Add listen mode 2012-06-21 18:01:50 +01:00
Alex Young
79ba1cf728 Make max_nbd_clients configurable per struct server 2012-06-21 17:22:34 +01:00
Alex Young
e21beb1866 Add the REQUEST_ENTRUST nbd request type 2012-06-21 17:12:06 +01:00
Alex Young
a3dc670939 Squash valgrind errors by making sure client threads get joined on termination 2012-06-21 17:11:12 +01:00
Alex Young
bafc3d3687 Make sure filename_incomplete gets freed 2012-06-21 15:58:32 +01:00
Alex Young
322eae137b Add a missed free() 2012-06-21 15:55:48 +01:00
Alex Young
43e95dc4db Make sure all the lines we read get freed (including the trailing blank) 2012-06-21 15:31:28 +01:00
Alex Young
cc22f50fe6 Avoid a use-after-free in serve.c 2012-06-21 14:15:58 +01:00
Alex Young
c054403208 Trim the length bitset_run_count looks at not to exceed the bits array 2012-06-21 12:05:01 +01:00
Alex Young
80fff4e0e6 Squash a valgrind error caused by debug output 2012-06-21 11:55:21 +01:00
Alex Young
4e8a9670e5 Merge 2012-06-21 11:37:18 +01:00
Alex Young
ed3090d6d5 Tweak struct initialisation to squash a valgrind error 2012-06-21 10:29:06 +01:00
Alex Young
50b0db7bf6 Reject mirroring if the remote size doesn't match the local size 2012-06-13 15:51:37 +01:00
Alex Young
c9ece5a63f Tidy mirror_runner somewhat 2012-06-13 15:45:59 +01:00
Alex Young
c2b6fac92d Fix an argv array reference (root cause of a bug from the last commit) 2012-06-13 13:52:15 +01:00
Alex Young
7d1c15b07a Fix two bugs in mirroring.
First, Leaving off the source address caused a segfault in the
command-sending process because there was no NULL check on the ARGV
entry.

Second, while the migration thread sent a signal to the server to close
on successful completion, it didn't wait until the close actually
happened before releasing the IO lock.  This meant that any client
thread waiting on that IO lock could have a read or a write queued up
which could succeed despite the server shutdown.  This would have meant
dataloss as the guest would see a successful write to the wrong instance
of the file.  This patch adds a noddy serve_wait_for_close() function
which the mirror_runner calls to ensure that any clients will reject
operations they're waiting to complete.

This patch also adds a simple scenario test for migration, and fixes
TempFileWriter#read_original.
2012-06-13 13:44:21 +01:00
Alex Young
b986f6b63e Take _GNU_SOURCE out of source and put it in CFLAGS 2012-06-13 09:59:08 +01:00
Alex Young
c7525f87dc Removed proxying completely and fixed the pthread_join bug revealed in the process 2012-06-12 15:08:07 +01:00
Alex Young
2a71b4e7a4 Fix broken error checking around pthread functions 2012-06-11 16:08:19 +01:00
Alex Young
5996c8f7ba Simplify a FATAL_IF_NEGATIVE 2012-06-11 15:31:59 +01:00
Alex Young
4c52bcd870 Make the error and fatal functions swallow semicolons properly 2012-06-11 15:26:42 +01:00
Alex Young
13a6a403a4 Make the error and fatal macros swallow semicolons properly 2012-06-11 15:23:06 +01:00
Alex Young
83b8b9eaac Add general-purpose ERROR/FATAL_IF and ERROR/FATAL_UNLESS macros 2012-06-11 15:20:05 +01:00
Alex Young
e2d3161a4a Set default log level to warn to shut the tests up 2012-06-11 14:59:26 +01:00
Alex Young
710d8254d4 Make sure all ifs are braced 2012-06-11 14:34:17 +01:00
Alex Young
25fc0969cf Make the compiler stricter and tidy up code to make the subsequent errors and warnings go away 2012-06-11 13:57:03 +01:00
Alex Young
8825f86726 Merge 2012-06-11 13:49:56 +01:00
Alex Young
b5427d13db Explicitly check for which fd is acceptable in server_accept 2012-06-11 13:49:35 +01:00
nick
893db71d7c Whitespace 2012-06-11 13:05:22 +01:00
nick
224bdcbf87 Fix handling ACLs where > 1 entry exists 2012-06-11 12:56:45 +01:00
Matthew Bloch
e8b5fae7ab Merge, just renaming old error macros. 2012-06-09 02:37:23 +01:00
Matthew Bloch
b546539ab8 Rewrote error & log functions to be more general, use longjmp to get out of
trouble and into predictable cleanup functions (one for each of serve,
client & control contexts).  We use 'fatal' to mean 'kill the thread' and
'error' to mean 'don't kill the thread', assuming some recovery action,
except I don't use error anywhere yet.
2012-06-09 02:25:12 +01:00
Alex Young
b7096ef908 Audit client connections on acl update 2012-06-08 18:03:41 +01:00
Alex Young
35ca93b42c Lock around acl updates 2012-06-08 11:02:40 +01:00
Alex Young
f7e1a098b1 Move updating the acl object into serve.c
* * *
Replacing the server acl sends an acl_updated signal
2012-06-08 10:32:33 +01:00
Alex Young
5fb0cd4cca Fix O_NONBLOCK setting on self_pipes 2012-06-08 10:11:06 +01:00