Move updating the acl object into serve.c

* * *
Replacing the server acl sends an acl_updated signal
This commit is contained in:
Alex Young
2012-06-08 10:32:33 +01:00
parent 5fb0cd4cca
commit f7e1a098b1
5 changed files with 109 additions and 10 deletions

View File

@@ -273,8 +273,7 @@ int control_acl(struct control_params* client, int linesc, char** lines)
acl_destroy( new_acl );
}
else {
client->serve->acl = new_acl;
acl_destroy( old_acl );
server_replace_acl( client->serve, new_acl );
write_socket("0: updated");
}

View File

@@ -314,6 +314,20 @@ void server_close_clients( struct server *params )
}
void server_replace_acl( struct server *serve, struct acl * new_acl )
{
NULLCHECK(serve);
NULLCHECK(new_acl);
struct acl * old_acl = serve->acl;
serve->acl = new_acl;
if ( old_acl ) { acl_destroy( old_acl ); }
self_pipe_signal( serve->acl_updated_signal );
}
/** Accept either an NBD or control socket connection, dispatch appropriately */
void serve_accept_loop(struct server* params)
{
@@ -402,6 +416,7 @@ void serve_cleanup(struct server* params)
close(params->proxy_fd);
self_pipe_destroy( params->close_signal );
self_pipe_destroy( params->acl_updated_signal );
free(params->allocation_map);
@@ -426,9 +441,9 @@ void do_serve(struct server* params)
pthread_mutex_init(&params->l_io, NULL);
params->close_signal = self_pipe_create();
if ( NULL == params->close_signal) {
SERVER_ERROR( "close signal creation failed" );
}
NULLCHECK( params->close_signal );
params->acl_updated_signal = self_pipe_create();
NULLCHECK( params->acl_updated_signal );
serve_open_server_socket(params);
serve_open_control_socket(params);

View File

@@ -3,14 +3,14 @@
#define _GNU_SOURCE
#ifndef _LARGEFILE64_SOURCE
# define _LARGEFILE64_SOURCE
#endif
#define _LARGEFILE64_SOURCE
#include <sys/types.h>
#include <unistd.h>
#include "parse.h"
#include "acl.h"
#include <sys/types.h>
static const int block_allocation_resolution = 4096;//128<<10;
@@ -69,6 +69,11 @@ struct server {
/** to interrupt accept loop and clients, write() to close_signal[1] */
struct self_pipe * close_signal;
/** acl_updated_signal will be signalled after the acl struct
* has been replaced
*/
struct self_pipe * acl_updated_signal;
struct mirror_status* mirror;
int server_fd;
int control_fd;