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 printUsage(const char *progname);
|
||||
|
||||
static struct option long_options[] = {
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"debug", no_argument, 0, 'd'},
|
||||
{"version", no_argument, 0, 'V'},
|
||||
{"fix", no_argument, 0, 'f'},
|
||||
@ -82,15 +83,16 @@ char *binlog_check_version = "1.1.0";
|
||||
int
|
||||
MaxScaleUptime()
|
||||
{
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ROUTER_INSTANCE *inst;
|
||||
int fd;
|
||||
int ret;
|
||||
char *ptr;
|
||||
char path[PATH_MAX+1] = "";
|
||||
char path[PATH_MAX + 1] = "";
|
||||
unsigned long filelen = 0;
|
||||
struct stat statb;
|
||||
char c;
|
||||
@ -102,7 +104,8 @@ int main(int argc, char **argv) {
|
||||
|
||||
while ((c = getopt_long(argc, argv, "dVfM?", long_options, &option_index)) >= 0)
|
||||
{
|
||||
switch (c) {
|
||||
switch (c)
|
||||
{
|
||||
case 'd':
|
||||
debug_out = 1;
|
||||
break;
|
||||
@ -128,7 +131,8 @@ int main(int argc, char **argv) {
|
||||
mxs_log_set_augmentation(0);
|
||||
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_log_flush_sync();
|
||||
@ -137,7 +141,8 @@ int main(int argc, char **argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argv[num_args] == NULL) {
|
||||
if (argv[num_args] == NULL)
|
||||
{
|
||||
printf("ERROR: No binlog file was specified\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -145,9 +150,13 @@ int main(int argc, char **argv) {
|
||||
strncpy(path, argv[num_args], PATH_MAX);
|
||||
|
||||
if (fix_file)
|
||||
{
|
||||
fd = open(path, O_RDWR, 0666);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd = open(path, O_RDONLY, 0666);
|
||||
}
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
@ -165,18 +174,26 @@ int main(int argc, char **argv) {
|
||||
inst->binlog_fd = fd;
|
||||
|
||||
if (mariadb10_compat == 1)
|
||||
{
|
||||
inst->mariadb10_compat = 1;
|
||||
}
|
||||
|
||||
ptr = strrchr(path, '/');
|
||||
if (ptr)
|
||||
strncpy(inst->binlog_name, ptr+1, BINLOG_FNAMELEN);
|
||||
{
|
||||
strncpy(inst->binlog_name, ptr + 1, BINLOG_FNAMELEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(inst->binlog_name, path, BINLOG_FNAMELEN);
|
||||
}
|
||||
|
||||
MXS_NOTICE("maxbinlogcheck %s", binlog_check_version);
|
||||
|
||||
if (fstat(inst->binlog_fd, &statb) == 0)
|
||||
{
|
||||
filelen = statb.st_size;
|
||||
}
|
||||
|
||||
MXS_NOTICE("Checking %s (%s), size %lu bytes", path, inst->binlog_name, filelen);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user