- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
void check_manifest_line (int p) {
static char c[MAX_LINE_LEN + 1];
int l = p - START_MANIFEST_POSITION;
if (l <= MAX_LINE_LEN && l > 4) {
get_binlog_data (c, START_MANIFEST_POSITION, l);
c[l] = 0;
char *pp = c;
int op = -1;
if (l >= 6 && !memcmp (c, "start", 5)) {
op = 1;
pp += 5;
} else if (l >= 5 && !memcmp (c, "stop", 4)) {
op = 2;
pp += 4;
} else if (l >= 8 && !memcmp (c, "version", 7)) {
op = 3;
pp += 7;
}
if (is_whitespace (*pp) && op > 0) {
pp ++;
pp = eat_whitespace (pp);
if (!*pp) {
START_MANIFEST_POSITION = p + 1;
return;
}
if (op == 1 || op == 2) {
char *rr = pp;
pp = eat_not_whitespace (pp);
char *zz = pp;
pp = eat_whitespace (pp);
*zz = 0;
if (pp == c + l && zz - rr > 0) {
struct cluster *C = CC;
int x = BINLOG_NAME_LEN - 1;
while (x >= 0 && BINLOG_NAME[x] != '/') {
x--;
}
add_cluster (BINLOG_NAME, x + 1, rr, (MAIN_REPLICA ? 2 : 0) + (op == 2 ? 4 : 0) + (1 << 30));
CC = C;
}
} else {
assert (op == 3);
char *rr = pp;
pp = eat_not_whitespace (pp);
char *rr_end = pp;
pp = eat_whitespace (pp);
*rr_end = 0;
if (!*pp) {
START_MANIFEST_POSITION = p + 1;
return;
}
int version = atoi (pp);
pp = eat_not_whitespace (pp);
pp = eat_whitespace (pp);
if (!*pp) {
START_MANIFEST_POSITION = p + 1;
return;
}
long long size = atoll (pp);
pp = eat_not_whitespace (pp);
pp = eat_whitespace (pp);
if (pp == c + l && rr_end > rr && version > 0 && size >= 0) {
struct cluster *C = CC;
int x = BINLOG_NAME_LEN - 1;
while (x >= 0 && BINLOG_NAME[x] != '/') {
x --;
}
int rrlen = rr_end - rr;
int i;
for (i = 0; i < max_cluster; i++) if (Clusters[i]) {
//fprintf (stderr, "i = %d, binlog_name = %s, rr = %s, rrlen = %d\n", i, Clusters[i]->binlog_name, rr, rrlen);
const char *s = Clusters[i]->binlog_name;
int l = strlen (Clusters[i]->binlog_name) - 1;
while (l >= 0 && s[l] != '/') { l --; }
s = s + l + 1;
if (!memcmp (s, rr, rrlen) && s[rrlen] == '.') {
int old = atoi (s + rrlen + 1);
if (old >= version) {
vkprintf (0, "New version %d, old %d. Skipping\n", version, old);
START_MANIFEST_POSITION = p + 1;
return;
}
if (unlink (Clusters[i]->binlog_name) < 0) {
fprintf (stderr, "Can not delete old file %s: %m\n", Clusters[i]->binlog_name);
}
delete_cluster (i);
}
}
static char name[1024];
memcpy (name, rr, rrlen);
name[rrlen] = '.';
sprintf (name + rrlen + 1, "%06d", version);
add_cluster (BINLOG_NAME, x + 1, name, (MAIN_REPLICA ? 2 : 0) + (1 << 30));
LAST_SIZE = size;
CC = C;
}
}
}
}
START_MANIFEST_POSITION = p + 1;
j123123 05.07.2018 15:35 # 0
А 1024 точно хватит?
roskomgovno 05.07.2018 16:31 # 0
Desktop 06.07.2018 16:39 # +1
roskomgovno 06.07.2018 21:28 # +2
--Сколько букв в слове "тромбоэластограмма"?
--18
--ого, как ты так быстро посчитал?
--ну я просто в Вконтакте работаю