Move the mirror commit state mbox to struct control
The mirror_super signals the commit state to the control thread via an mbox, and this mbox is moved to control. It was owned by mirror_super, but the problem with that is that mirror_super can free the mbox before the control client has been scheduled to receive the message. If it's owned by the control object, that can't happen.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "mirror.h"
|
||||
#include "control.h"
|
||||
#include "flexnbd.h"
|
||||
#include "mbox.h"
|
||||
|
||||
struct control {
|
||||
struct flexnbd * flexnbd;
|
||||
@@ -15,14 +16,32 @@ struct control {
|
||||
pthread_t thread;
|
||||
|
||||
struct self_pipe * close_signal;
|
||||
|
||||
/* This is owned by the control object, and used by a
|
||||
* mirror_super to communicate the state of a mirror attempt as
|
||||
* early as feasible. It can't be owned by the mirror_super
|
||||
* object because the mirror_super object can be freed at any
|
||||
* time (including while the control_client is waiting on it),
|
||||
* whereas the control object lasts for the lifetime of the
|
||||
* process (and we can only have a mirror thread if the control
|
||||
* thread has started it).
|
||||
*/
|
||||
struct mbox * mirror_state_mbox;
|
||||
};
|
||||
|
||||
struct control_client{
|
||||
int socket;
|
||||
struct flexnbd * flexnbd;
|
||||
|
||||
/* Passed in on creation. We know it's all right to do this
|
||||
* because we know there's only ever one control_client.
|
||||
*/
|
||||
struct mbox * mirror_state_mbox;
|
||||
};
|
||||
|
||||
struct control * control_create(struct flexnbd *, const char * control_socket_name);
|
||||
struct control * control_create(
|
||||
struct flexnbd *,
|
||||
const char * control_socket_name );
|
||||
void control_signal_close( struct control * );
|
||||
void control_destroy( struct control * );
|
||||
|
||||
|
Reference in New Issue
Block a user