Reformat binlog router.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -68,7 +68,8 @@ extern uint32_t extract_field(uint8_t *src, int bits);
|
|||||||
static void printVersion(const char *progname);
|
static void printVersion(const char *progname);
|
||||||
static void printUsage(const char *progname);
|
static void printUsage(const char *progname);
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] =
|
||||||
|
{
|
||||||
{"debug", no_argument, 0, 'd'},
|
{"debug", no_argument, 0, 'd'},
|
||||||
{"version", no_argument, 0, 'V'},
|
{"version", no_argument, 0, 'V'},
|
||||||
{"fix", no_argument, 0, 'f'},
|
{"fix", no_argument, 0, 'f'},
|
||||||
@ -82,15 +83,16 @@ char *binlog_check_version = "1.1.0";
|
|||||||
int
|
int
|
||||||
MaxScaleUptime()
|
MaxScaleUptime()
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
ROUTER_INSTANCE *inst;
|
ROUTER_INSTANCE *inst;
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
char path[PATH_MAX+1] = "";
|
char path[PATH_MAX + 1] = "";
|
||||||
unsigned long filelen = 0;
|
unsigned long filelen = 0;
|
||||||
struct stat statb;
|
struct stat statb;
|
||||||
char c;
|
char c;
|
||||||
@ -102,7 +104,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "dVfM?", long_options, &option_index)) >= 0)
|
while ((c = getopt_long(argc, argv, "dVfM?", long_options, &option_index)) >= 0)
|
||||||
{
|
{
|
||||||
switch (c) {
|
switch (c)
|
||||||
|
{
|
||||||
case 'd':
|
case 'd':
|
||||||
debug_out = 1;
|
debug_out = 1;
|
||||||
break;
|
break;
|
||||||
@ -128,7 +131,8 @@ int main(int argc, char **argv) {
|
|||||||
mxs_log_set_augmentation(0);
|
mxs_log_set_augmentation(0);
|
||||||
mxs_log_set_priority_enabled(LOG_DEBUG, debug_out);
|
mxs_log_set_priority_enabled(LOG_DEBUG, debug_out);
|
||||||
|
|
||||||
if ((inst = calloc(1, sizeof(ROUTER_INSTANCE))) == NULL) {
|
if ((inst = calloc(1, sizeof(ROUTER_INSTANCE))) == NULL)
|
||||||
|
{
|
||||||
MXS_ERROR("Memory allocation failed for ROUTER_INSTANCE");
|
MXS_ERROR("Memory allocation failed for ROUTER_INSTANCE");
|
||||||
|
|
||||||
mxs_log_flush_sync();
|
mxs_log_flush_sync();
|
||||||
@ -137,7 +141,8 @@ int main(int argc, char **argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv[num_args] == NULL) {
|
if (argv[num_args] == NULL)
|
||||||
|
{
|
||||||
printf("ERROR: No binlog file was specified\n");
|
printf("ERROR: No binlog file was specified\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -145,9 +150,13 @@ int main(int argc, char **argv) {
|
|||||||
strncpy(path, argv[num_args], PATH_MAX);
|
strncpy(path, argv[num_args], PATH_MAX);
|
||||||
|
|
||||||
if (fix_file)
|
if (fix_file)
|
||||||
|
{
|
||||||
fd = open(path, O_RDWR, 0666);
|
fd = open(path, O_RDWR, 0666);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
fd = open(path, O_RDONLY, 0666);
|
fd = open(path, O_RDONLY, 0666);
|
||||||
|
}
|
||||||
|
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
@ -165,18 +174,26 @@ int main(int argc, char **argv) {
|
|||||||
inst->binlog_fd = fd;
|
inst->binlog_fd = fd;
|
||||||
|
|
||||||
if (mariadb10_compat == 1)
|
if (mariadb10_compat == 1)
|
||||||
|
{
|
||||||
inst->mariadb10_compat = 1;
|
inst->mariadb10_compat = 1;
|
||||||
|
}
|
||||||
|
|
||||||
ptr = strrchr(path, '/');
|
ptr = strrchr(path, '/');
|
||||||
if (ptr)
|
if (ptr)
|
||||||
strncpy(inst->binlog_name, ptr+1, BINLOG_FNAMELEN);
|
{
|
||||||
|
strncpy(inst->binlog_name, ptr + 1, BINLOG_FNAMELEN);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
strncpy(inst->binlog_name, path, BINLOG_FNAMELEN);
|
strncpy(inst->binlog_name, path, BINLOG_FNAMELEN);
|
||||||
|
}
|
||||||
|
|
||||||
MXS_NOTICE("maxbinlogcheck %s", binlog_check_version);
|
MXS_NOTICE("maxbinlogcheck %s", binlog_check_version);
|
||||||
|
|
||||||
if (fstat(inst->binlog_fd, &statb) == 0)
|
if (fstat(inst->binlog_fd, &statb) == 0)
|
||||||
|
{
|
||||||
filelen = statb.st_size;
|
filelen = statb.st_size;
|
||||||
|
}
|
||||||
|
|
||||||
MXS_NOTICE("Checking %s (%s), size %lu bytes", path, inst->binlog_name, filelen);
|
MXS_NOTICE("Checking %s (%s), size %lu bytes", path, inst->binlog_name, filelen);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user