control/mirror: Use uint64_t and strtoull to get max_Bps into the mirror

This commit is contained in:
nick
2013-08-13 12:30:18 +01:00
parent 7128fcc901
commit cc468b0b17
3 changed files with 18 additions and 10 deletions

View File

@@ -319,7 +319,7 @@ int control_mirror(struct control_client* client, int linesc, char** lines)
struct flexnbd * flexnbd = client->flexnbd;
union mysockaddr *connect_to = xmalloc( sizeof( union mysockaddr ) );
union mysockaddr *connect_from = NULL;
uint64_t max_Bps = 0;
uint64_t max_Bps = UINT64_MAX;
int action_at_finish;
int raw_port;
@@ -367,7 +367,15 @@ int control_mirror(struct control_client* client, int linesc, char** lines)
}
if (linesc > 4) {
max_Bps = atoi(lines[4]);
errno = 0;
max_Bps = strtoull( lines[4], NULL, 10 );
if ( errno == ERANGE ) {
write_socket( "1: max_bps out of range" );
return -1;
} else if ( errno != 0 ) {
write_socket( "1: max_bps couldn't be parsed" );
return -1;
}
}

View File

@@ -82,8 +82,8 @@ struct mirror_ctrl {
struct mirror * mirror_alloc(
union mysockaddr * connect_to,
union mysockaddr * connect_from,
int max_Bps,
int action_at_finish,
uint64_t max_Bps,
enum mirror_finish_action action_at_finish,
struct mbox * commit_signal)
{
struct mirror * mirror;
@@ -178,7 +178,7 @@ struct mirror * mirror_create(
const char * filename,
union mysockaddr * connect_to,
union mysockaddr * connect_from,
int max_Bps,
uint64_t max_Bps,
int action_at_finish,
struct mbox * commit_signal)
{
@@ -816,8 +816,8 @@ struct mirror_super * mirror_super_create(
const char * filename,
union mysockaddr * connect_to,
union mysockaddr * connect_from,
int max_Bps,
int action_at_finish,
uint64_t max_Bps,
enum mirror_finish_action action_at_finish,
struct mbox * state_mbox)
{
struct mirror_super * super = xmalloc( sizeof( struct mirror_super) );

View File

@@ -73,7 +73,7 @@ struct mirror {
/* Not used yet. Will be a limiter, used to restrict migration speed.
* only dirty bytes (those going over the network) will be considered */
off64_t max_bytes_per_second;
uint64_t max_bytes_per_second;
enum mirror_finish_action action_at_finish;
@@ -124,8 +124,8 @@ struct mirror_super * mirror_super_create(
const char * filename,
union mysockaddr * connect_to,
union mysockaddr * connect_from,
int max_Bps,
int action_at_finish,
uint64_t max_Bps,
enum mirror_finish_action action_at_finish,
struct mbox * state_mbox
);
void * mirror_super_runner( void * serve_uncast );