mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 18:24:12 +08:00
lmdb: refine exit-codes in mdb_chk.
Change-Id: I003ff0d887e3e0fb0439d201efcf4a76e8e69aac
This commit is contained in:
parent
e7f58da2ac
commit
de0cf8dfbb
24
mdb_chk.c
24
mdb_chk.c
@ -54,6 +54,12 @@ static void signal_hanlder( int sig ) {
|
|||||||
|
|
||||||
#define MAX_DBI 32768
|
#define MAX_DBI 32768
|
||||||
|
|
||||||
|
#define EXIT_INTERRUPTED (EXIT_FAILURE+4)
|
||||||
|
#define EXIT_FAILURE_SYS (EXIT_FAILURE+3)
|
||||||
|
#define EXIT_FAILURE_MDB (EXIT_FAILURE+2)
|
||||||
|
#define EXIT_FAILURE_CHECK_MAJOR (EXIT_FAILURE+1)
|
||||||
|
#define EXIT_FAILURE_CHECK_MINOR EXIT_FAILURE
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
const char* dbi_names[MAX_DBI];
|
const char* dbi_names[MAX_DBI];
|
||||||
size_t dbi_pages[MAX_DBI];
|
size_t dbi_pages[MAX_DBI];
|
||||||
@ -484,7 +490,7 @@ static void usage(char *prog)
|
|||||||
" -d\t\tdisable page-by-page traversal of b-tree\n"
|
" -d\t\tdisable page-by-page traversal of b-tree\n"
|
||||||
" -s subdb\tprocess a specific subdatabase only\n"
|
" -s subdb\tprocess a specific subdatabase only\n"
|
||||||
" -c\t\tforce cooperative mode (don't try exclusive)\n", prog);
|
" -c\t\tforce cooperative mode (don't try exclusive)\n", prog);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_INTERRUPTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* meta_synctype(size_t sign) {
|
const char* meta_synctype(size_t sign) {
|
||||||
@ -520,7 +526,7 @@ int main(int argc, char *argv[])
|
|||||||
switch(i) {
|
switch(i) {
|
||||||
case 'V':
|
case 'V':
|
||||||
printf("%s\n", MDB_VERSION_STRING);
|
printf("%s\n", MDB_VERSION_STRING);
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
@ -569,7 +575,7 @@ int main(int argc, char *argv[])
|
|||||||
rc = mdb_env_create(&env);
|
rc = mdb_env_create(&env);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
error("mdb_env_create failed, error %d %s\n", rc, mdb_strerror(rc));
|
error("mdb_env_create failed, error %d %s\n", rc, mdb_strerror(rc));
|
||||||
return EXIT_FAILURE;
|
return rc < 0 ? EXIT_FAILURE_MDB : EXIT_FAILURE_SYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = mdb_env_get_maxkeysize(env);
|
rc = mdb_env_get_maxkeysize(env);
|
||||||
@ -791,14 +797,18 @@ bailout:
|
|||||||
if (env)
|
if (env)
|
||||||
mdb_env_close(env);
|
mdb_env_close(env);
|
||||||
free(walk.pagemap);
|
free(walk.pagemap);
|
||||||
if (rc)
|
if (rc) {
|
||||||
return EXIT_FAILURE + 2;
|
if (rc < 0)
|
||||||
|
return gotsignal ? EXIT_INTERRUPTED : EXIT_FAILURE_SYS;
|
||||||
|
return EXIT_FAILURE_MDB;
|
||||||
|
}
|
||||||
|
|
||||||
total_problems += problems_meta;
|
total_problems += problems_meta;
|
||||||
if (total_problems || problems_maindb || problems_freedb) {
|
if (total_problems || problems_maindb || problems_freedb) {
|
||||||
print("Total %zu error(s) is detected.\n", total_problems);
|
print("Total %zu error(s) is detected.\n", total_problems);
|
||||||
if (problems_meta || problems_maindb || problems_freedb)
|
if (problems_meta || problems_maindb || problems_freedb)
|
||||||
return EXIT_FAILURE + 1;
|
return EXIT_FAILURE_CHECK_MAJOR;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE_CHECK_MINOR;
|
||||||
}
|
}
|
||||||
print("No error is detected.\n");
|
print("No error is detected.\n");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user