Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf16c31e

Browse files
committed
Add AGMDB_getErrorInfo() function for printing the error log.
1 parent639acaf commitf16c31e

File tree

2 files changed

+127
-8
lines changed

2 files changed

+127
-8
lines changed

‎apache2/ag_mdb/ag_mdb.cpp‎

Lines changed: 111 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ int Lock_create(struct agmdb_lock *new_lock, const char* lock_name, int lock_nam
7777
if(new_mutex ==NULL)
7878
return AGMDB_ERROR_LOCK_WIN_MUTEX_CREATE_FAIL;
7979
if((GetLastError() == ERROR_ALREADY_EXISTS) != lock_exists)// One lock exists, another not.
80-
returnAGMDB_ERROR_LOCK_WIN_ONLY_ONE_LCOK_EXISTS;
80+
returnAGMDB_ERROR_LOCK_WIN_ONLY_ONE_LOCK_EXISTS;
8181
new_lock->write_lock_handle =OpenMutex(
8282
MUTEX_ALL_ACCESS,//
8383
false,//
@@ -901,7 +901,7 @@ int AGMDB_setExpireTime(struct agmdb_handler *dbm, unsigned int expire_time){
901901
return AGMDB_ERROR_HANDLE_NULL;
902902

903903
if(expire_time <0)
904-
returnAGMDB_ERROR_SET_NAGATIVE_EXIPRE_TIME;
904+
returnAGMDB_ERROR_SET_NEGATIVE_EXIPRE_TIME;
905905
*SHM_EXPIRE_TIME((const PTR_VOID)(dbm->shm_base)) = expire_time;
906906
return AGMDB_SUCCESS;
907907
}
@@ -1077,15 +1077,121 @@ int AGMDB_removeStale(struct agmdb_handler *dbm) {
10771077
return AGMDB_SUCCESS;
10781078
}
10791079

1080-
constchar*AGMDB_getErrorInfo(int error_code){
1081-
returnNULL;
1082-
}
10831080
/**
10841081
**========================================================
10851082
** AG Memory Database Debug API
10861083
**========================================================
10871084
*/
10881085

1086+
/**
1087+
** Get the detail information of an error.
1088+
** @param error_no: the error code returned by a function.
1089+
** return: The error information.
1090+
*/
1091+
constchar*AGMDB_getErrorInfo(int error_no){
1092+
switch(error_no){
1093+
case AGMDB_SUCCESS:
1094+
return"Success!";
1095+
case AGMDB_ERROR_LOCK_OP_NEGATIVE_VAL:
1096+
return"When operating the lock, the operation value is negative!";
1097+
1098+
case AGMDB_ERROR_LOCK_LINUX_SEM_CREATE_FAIL:
1099+
return"In Linux system, failed when creating the semaphore. Please check the semaphore limit of the system.";
1100+
case AGMDB_ERROR_LOCK_LINUX_SEM_OPEN_FAIL:
1101+
return"In Linux system, failed when opening an existed semaphore. Please check the semaphore limit and permission settings.";
1102+
case AGMDB_ERROR_LOCK_LINUX_SEM_INIT_FAIL:
1103+
return"In Linux system, failed when initializing the semaphore value. Please check the existence and permission of the semaphore.";
1104+
case AGMDB_ERROR_LOCK_LINUX_SEM_MODIFY_FAIL:
1105+
return"In Linux system, failed when modifying the semaphore value. Please check the existence and permission of the semaphore.";
1106+
1107+
case AGMDB_ERROR_LOCK_WIN_NAME_INVALID_STRING:
1108+
return"In Windows system, the name of lock is not a valid string. Please check the data_dir setting in configuration file.";
1109+
case AGMDB_ERROR_LOCK_WIN_MUTEX_CREATE_FAIL:
1110+
return"In Windows system, failed when creating the mutex object.";
1111+
case AGMDB_ERROR_LOCK_WIN_ONLY_ONE_LOCK_EXISTS:
1112+
return"In Windows system, one and only one lock has existed.";
1113+
case AGMDB_ERROR_LOCK_WIN_GET_MUTEX_FAIL:
1114+
return"In Windows system, failed when getting the mutex object. Possible reason is deadlock or permission issue.";
1115+
case AGMDB_ERROR_LOCK_WIN_RELEASE_MUTEX_FAIL:
1116+
return"In Windows system, failed when releasing the mutex object.";
1117+
1118+
case AGMDB_ERROR_SHM_BASE_NULL:
1119+
return"The shared memory base address is NULL. Please check the agmdb_handler object.";
1120+
case AGMDB_ERROR_SHM_SIZE_TOO_SMALL:
1121+
return"The size setting of shared memory is too small to save the DB control information.";
1122+
case AGMDB_ERROR_SHM_NAME_INVALID_STRING:
1123+
return"The name of database is not a valid string. Please check the data_dir setting in configuration file.";
1124+
case AGMDB_ERROR_SHM_ENTRY_NUM_NEGATIVE:
1125+
return"The setting of DB's entry number is negative!";
1126+
1127+
case AGMDB_ERROR_SHM_LINUX_CREATE_FAIL:
1128+
return"In Linux system, failed when creating the shared memory.";
1129+
case AGMDB_ERROR_SHM_LINUX_MAP_FAIL:
1130+
return"In Linux system, failed when mapping the shared memory into the process's address space.";
1131+
1132+
case AGMDB_ERROR_SHM_WIN_CREATE_FAIL:
1133+
return"In Windows system, failed when creating the shared memory.";
1134+
case AGMDB_ERROR_SHM_WIN_MAP_FAIL:
1135+
return"In Windows system, failed when mapping the shared memory into the process's address space.";
1136+
1137+
case AGMDB_ERROR_INSERT_INVALID_ENTRY_INTO_SPARELIST:
1138+
return"The AGMDB is inserting an invalid entry into the spare list.";
1139+
case AGMDB_ERROR_INSERT_BUSY_ENTRY_INTO_SPARELIST:
1140+
return"The AGMDB is inserting a busy entry into the spare list. Should remove the entry from hashlist first.";
1141+
1142+
case AGMDB_ERROR_INSERT_INVALID_ENTRY_INTO_HASHLIST:
1143+
return"The AGMDB is inserting an invalid entry into the hashlist.";
1144+
case AGMDB_ERROR_INSERT_BUSY_ENTRY_INTO_HASHLIST:
1145+
return"The AGMDB is inserting a busy entry into the hashlist.";
1146+
1147+
case AGMDB_ERROR_REMOVE_INVALID_ENTRY_FROM_HASHLIST:
1148+
return"The AGMDB is removing an invalid entry from hashlist";
1149+
case AGMDB_ERROR_NONHEAD_ENTRY_IN_HASHLIST_WITHOUT_PREV:
1150+
return"An entry in hashlist without previous entry is not the head of the hashlist.";
1151+
1152+
case AGMDB_ERROR_INSERT_INVALID_ENTRY_INTO_TIMELIST:
1153+
return"The AGMDB is inserting an invalid entry into the expire time list.";
1154+
case AGMDB_ERROR_REMOVE_INVALID_ENTRY_FROM_TIMELIST:
1155+
return"The AGMDB is removing an invalid entry into the expire time list.";
1156+
1157+
case AGMDB_ERROR_SET_KEYVAL_OF_INVALID_ENTRY:
1158+
return"The AGMDB is setting key-value to an invalid entry.";
1159+
1160+
case AGMDB_ERROR_KEY_INVALID_STRING:
1161+
return"The key is not a valid string.";
1162+
case AGMDB_ERROR_KEY_TOO_LONG:
1163+
return"The key string is too long.";
1164+
case AGMDB_ERROR_VALUE_INVALID_STRING:
1165+
return"The value is not a valid string.";
1166+
case AGMDB_ERROR_VALUE_TOO_LONG:
1167+
return"The value string is too long.";
1168+
1169+
case AGMDB_ERROR_HANDLE_NULL:
1170+
return"The agmdb_handler is NULL.";
1171+
case AGMDB_ERROR_DELETE_INVALID_ENTRY:
1172+
return"The AGMDB is deleting an invalid entry.";
1173+
case AGMDB_ERROR_NAME_NULL:
1174+
return"The name of AGMDB is NULL";
1175+
case AGMDB_ERROR_NAME_INVALID_STRING:
1176+
return"The name of AGMDB is not a valid string.";
1177+
1178+
case AGMDB_ERROR_SET_NEGATIVE_EXIPRE_TIME:
1179+
return"Set the expire time to a negative value.";
1180+
1181+
case AGMDB_ERROR_GET_BUFFER_NULL:
1182+
return"In get function, the buffer is NULL.";
1183+
case AGMDB_ERROR_GET_INVALID_BUFFER_LEN:
1184+
return"In get function, the length of buffer is an invalid number.";
1185+
case AGMDB_ERROR_GET_BUFFER_TOO_SMALL:
1186+
return"In get function, the buffer is too small to save the data.";
1187+
1188+
case AGMDB_ERROR_TIMELIST_LONG_NOTEQUEAL_SHM_CNT:
1189+
return"The size of expire time list does not equal to the entry counter in DB control block.";
1190+
case AGMDB_ERROR_GETALL_ARRAY_TOO_SMALL:
1191+
return"In getAll function, the array is too samll to save the data.";
1192+
}
1193+
}
1194+
10891195
/**
10901196
** Get the number of keys in a database.
10911197
** You have to get SHARED or EXCLUSIVE LOCK of the database before calling this function.

‎apache2/ag_mdb/ag_mdb_external.h‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ extern "C" {
1919
** AG Memory Database Status Definition
2020
**========================================================
2121
*/
22+
/**
23+
** First Digit: equals 1 if it is an error code.
24+
** Second Digit: the module where the error happens.
25+
** 0 means lock, 1 means shared momory, 2 means the database.
26+
** Third Digit: the platform where the error happens.
27+
** 0 means general, 1 means LINUX, 2 means WINDOWS.
28+
** 4th & 5th Digit: the detailed error number.
29+
*/
2230
#defineAGMDB_SUCCESS 0
2331
#defineAGMDB_ERROR 10000
2432

@@ -31,7 +39,7 @@ extern "C" {
3139

3240
#defineAGMDB_ERROR_LOCK_WIN_NAME_INVALID_STRING 10200
3341
#defineAGMDB_ERROR_LOCK_WIN_MUTEX_CREATE_FAIL 10201
34-
#defineAGMDB_ERROR_LOCK_WIN_ONLY_ONE_LCOK_EXISTS 10202
42+
#defineAGMDB_ERROR_LOCK_WIN_ONLY_ONE_LOCK_EXISTS 10202
3543
#defineAGMDB_ERROR_LOCK_WIN_GET_MUTEX_FAIL 10203
3644
#defineAGMDB_ERROR_LOCK_WIN_RELEASE_MUTEX_FAIL 10204
3745

@@ -70,7 +78,7 @@ extern "C" {
7078
#defineAGMDB_ERROR_NAME_NULL 12015
7179
#defineAGMDB_ERROR_NAME_INVALID_STRING 12016
7280

73-
#defineAGMDB_ERROR_SET_NAGATIVE_EXIPRE_TIME 12017
81+
#defineAGMDB_ERROR_SET_NEGATIVE_EXIPRE_TIME 12017
7482

7583
#defineAGMDB_ERROR_GET_BUFFER_NULL 12018
7684
#defineAGMDB_ERROR_GET_INVALID_BUFFER_LEN 12019
@@ -247,7 +255,12 @@ int AGMDB_removeStale(struct agmdb_handler *dbm);
247255
** AG Memory Database Debug API
248256
**========================================================
249257
*/
250-
258+
/**
259+
** Get the detail information of an error.
260+
** @param error_no: the error code returned by a function.
261+
** return: The error information.
262+
*/
263+
constchar*AGMDB_getErrorInfo(interror_no);
251264
/**
252265
** Get the number of keys in a database.
253266
** You have to get SHARED or EXCLUSIVE LOCK of the database before calling this function.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp