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

Commit0f41445

Browse files
committed
AGMDB_destroyDB(), SHM_destroy(), Lock_destroy() doesn't support on Windows. The shared memory and locks will be destroyed automatically after all related handles have been closed.
1 parent567894a commit0f41445

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

‎apache2/ag_mdb/ag_mdb.cpp‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,17 @@ int Lock_destroy(struct agmdb_lock *db_lock) {
126126
rc =Lock_close(db_lock);
127127
if (AGMDB_isError(rc))
128128
return rc;
129-
/* Windows doesn't do anything*/
130129
#ifndef _WIN32
131130
rc =semctl(db_lock->sem_id,0, IPC_RMID);
132131
if (rc == -1)
133132
return AGMDB_ERROR_LOCK_LINUX_SEM_DESTROY_FAIL;
134133
else
135134
db_lock->sem_id = -1;
136-
#endif
137135
return AGMDB_SUCCESS;
136+
#else
137+
/* Locks destroy doesn't support on Windows*/
138+
return AGMDB_ERROR_LOCK_WIN_DESTROY_NOT_SUPPORT;
139+
#endif
138140
}
139141

140142
/**
@@ -451,16 +453,19 @@ int SHM_destroy(struct agmdb_handler *dbm) {
451453
rc =SHM_close(dbm);
452454
if (AGMDB_isError(rc))
453455
return rc;
454-
/* Windows doesn't do anything*/
456+
455457
#ifndef _WIN32
456458
if (dbm->linux_shm_id != -1) {
457459
rc =shmctl(dbm->linux_shm_id, IPC_RMID,0);
458460
if (rc == -1)
459461
return AGMDB_ERROR_SHM_LINUX_DESTROY_FAIL;
460462
dbm->linux_shm_id = -1;
461463
}
462-
#endif
463464
return AGMDB_SUCCESS;
465+
#else
466+
/* Shared memory destroy doesn't support on Windows*/
467+
return AGMDB_ERROR_SHM_WIN_DESTROY_NOT_SUPPORT;
468+
#endif
464469
}
465470

466471
/**
@@ -1124,6 +1129,11 @@ int AGMDB_destroyDB(struct agmdb_handler *dbm) {
11241129

11251130
rc_shm =SHM_destroy(dbm);
11261131
rc_lock =Lock_destroy(&(dbm->db_lock));
1132+
1133+
/* Database destroy doesn't support on Windows*/
1134+
if(rc_shm == AGMDB_ERROR_SHM_WIN_DESTROY_NOT_SUPPORT && rc_lock == AGMDB_ERROR_LOCK_WIN_DESTROY_NOT_SUPPORT)
1135+
return AGMDB_ERROR_DB_WIN_DESTROY_NOT_SUPPORT;
1136+
11271137
if (AGMDB_isError(rc_shm))
11281138
return rc_shm;
11291139
elseif (AGMDB_isError(rc_lock))
@@ -1442,6 +1452,9 @@ const char* AGMDB_getErrorInfo(int error_no) {
14421452
case AGMDB_ERROR_GETALL_ARRAY_TOO_SMALL:
14431453
return"In getAll function, the array is too samll to save the data.";
14441454

1455+
case AGMDB_ERROR_DB_WIN_DESTROY_NOT_SUPPORT:
1456+
return"In Windows system, the destroy operation doesn't supported. Just close the database.";
1457+
14451458
case AGMDB_ERROR_UNEXPECTED:
14461459
return"Unexpected error happens.";
14471460

@@ -1477,6 +1490,8 @@ const char* AGMDB_getErrorInfo(int error_no) {
14771490
return"In Windows system, faild when close the shared memory handle. Call GetLastError() for more information.";
14781491
case AGMDB_ERROR_SHM_WIN_UNMAP_AND_CLOSE_HANDLE_FAIL:
14791492
return"In Windows system, faild when unmap the shared memory and close the shared memory handle. Call GetLastError() for more information.";
1493+
case AGMDB_ERROR_SHM_WIN_DESTROY_NOT_SUPPORT:
1494+
return"In Windows system, the shared memory destroy operation doesn't supported. Just close the shared memory.";
14801495

14811496
case AGMDB_ERROR_LOCK_OP_NEGATIVE_VAL:
14821497
return"When operating the lock, the operation value is negative!";
@@ -1504,6 +1519,8 @@ const char* AGMDB_getErrorInfo(int error_no) {
15041519
return"In Windows system, failed when releasing the mutex object.";
15051520
case AGMDB_ERROR_LOCK_WIN_CLOSE_MUTEX_FAIL:
15061521
return"In Windows system, failed when close the mutex object.";
1522+
case AGMDB_ERROR_LOCK_WIN_DESTROY_NOT_SUPPORT:
1523+
return"In Windows system, the lock destroy operation doesn't supported. Just close the locks.";
15071524

15081525
default:
15091526
return"Error code is not found.";

‎apache2/ag_mdb/ag_mdb_external.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ extern "C" {
8080

8181
#defineAGMDB_ERROR_GETALL_ARRAY_TOO_SMALL 10023
8282

83+
#defineAGMDB_ERROR_DB_WIN_DESTROY_NOT_SUPPORT 10024
84+
8385
#defineAGMDB_ERROR_UNEXPECTED 10099
8486

8587
#defineAGMDB_ERROR_SHM_BASE_NULL 11000
@@ -99,6 +101,7 @@ extern "C" {
99101
#defineAGMDB_ERROR_SHM_WIN_UNMAP_FAIL 11202
100102
#defineAGMDB_ERROR_SHM_WIN_CLOSE_HANDLE_FAIL 11203
101103
#defineAGMDB_ERROR_SHM_WIN_UNMAP_AND_CLOSE_HANDLE_FAIL 11204
104+
#defineAGMDB_ERROR_SHM_WIN_DESTROY_NOT_SUPPORT 11205
102105

103106
#defineAGMDB_ERROR_LOCK_OP_NEGATIVE_VAL 12000
104107

@@ -114,6 +117,7 @@ extern "C" {
114117
#defineAGMDB_ERROR_LOCK_WIN_GET_MUTEX_FAIL 12203
115118
#defineAGMDB_ERROR_LOCK_WIN_RELEASE_MUTEX_FAIL 12204
116119
#defineAGMDB_ERROR_LOCK_WIN_CLOSE_MUTEX_FAIL 12205
120+
#defineAGMDB_ERROR_LOCK_WIN_DESTROY_NOT_SUPPORT 12206
117121

118122
/**
119123
**========================================================

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp