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

Commit3c29038

Browse files
authored
Merge pull requestmicrosoft#23 from Microsoft/inMemoryDB-MSRA
Fix some bugs on inMemoryDB
2 parentsf9ee219 +2c7e270 commit3c29038

File tree

6 files changed

+32
-19
lines changed

6 files changed

+32
-19
lines changed

‎apache2/Makefile.win‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ DEFS=$(DEFS) -DWITH_YAJL
5656
INCLUDES = $(INCLUDES) -I$(YAJL)\include -I$(YAJL) \
5757
!ENDIF
5858

59+
# Enable support for collection's memory database
60+
DEFS=$(DEFS) -DMEMORY_DATABASE_ENABLE
61+
5962
CFLAGS= -MD $(INCLUDES) $(DEFS)
6063

6164
LDFLAGS =

‎apache2/ag_mdb/ag_mdb.cpp‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ int Lock_create(struct agmdb_lock *new_lock, const char* lock_name, int lock_nam
5858
return AGMDB_SUCCESS_LOCK_OPEN;
5959
}
6060
#else
61-
read_lock_name_len = (strlen(READ_LOCK_PREFIX) +strlen(lock_name) +1) *sizeof(char);
62-
write_lock_name_len = (strlen(WRITE_LOCK_PREFIX) +strlen(lock_name) +1) *sizeof(char);
61+
read_lock_name_len = (strlen(READ_LOCK_SUFFIX) +strlen(lock_name) +1) *sizeof(char);
62+
write_lock_name_len = (strlen(WRITE_LOCK_SUFFIX) +strlen(lock_name) +1) *sizeof(char);
6363

6464
if (AGMDB_isstring(lock_name, lock_name_length) != AGMDB_SUCCESS)
6565
return AGMDB_ERROR_LOCK_WIN_NAME_INVALID_STRING;
6666

6767
read_lock_name = (char *)malloc(read_lock_name_len *sizeof(char));
68-
sprintf_s(read_lock_name, read_lock_name_len,"%s%s",READ_LOCK_PREFIX, lock_name);
68+
sprintf_s(read_lock_name, read_lock_name_len,"%s%s",lock_name, READ_LOCK_SUFFIX);
6969
new_lock->read_lock_handle =CreateMutex(
7070
NULL,// Default security settings.
7171
FALSE,// Do not take the lock after created.
@@ -81,7 +81,7 @@ int Lock_create(struct agmdb_lock *new_lock, const char* lock_name, int lock_nam
8181
lock_exists =true;
8282

8383
write_lock_name = (char *)malloc(write_lock_name_len *sizeof(char));
84-
sprintf_s(write_lock_name, write_lock_name_len,"%s%s",WRITE_LOCK_PREFIX, lock_name);
84+
sprintf_s(write_lock_name, write_lock_name_len,"%s%s",lock_name, WRITE_LOCK_SUFFIX);
8585
new_lock->write_lock_handle =CreateMutex(
8686
NULL,// Default security settings.
8787
FALSE,// Do not take the lock after created.
@@ -127,6 +127,8 @@ int Lock_destroy(struct agmdb_lock *db_lock) {
127127
if (AGMDB_isError(rc))
128128
return rc;
129129
#ifndef _WIN32
130+
if (db_lock->sem_id = -1)
131+
return AGMDB_SUCCESS;
130132
rc =semctl(db_lock->sem_id,0, IPC_RMID);
131133
if (rc == -1)
132134
return AGMDB_ERROR_LOCK_LINUX_SEM_DESTROY_FAIL;

‎apache2/ag_mdb/ag_mdb_external.h‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#ifndef_AG_MDB_EXTERNAL_HEADER
22
#define_AG_MDB_EXTERNAL_HEADER
33

4-
#ifdef__cplusplus
5-
extern"C" {
6-
#endif
7-
8-
#ifndef_WIN32
94
#include"stdbool.h"
10-
#else
5+
#ifdef_WIN32
6+
#ifdefinline
7+
#undef inline
8+
#endif
119
#include<windows.h>
1210
#endif
1311

12+
#ifdef__cplusplus
13+
extern"C" {
14+
#endif
15+
1416
/**
1517
**========================================================
1618
** AG Memory Database Limitation Definition
@@ -305,6 +307,7 @@ const char* AGMDB_getErrorInfo(int return_code);
305307
False if not.
306308
*/
307309
boolAGMDB_isError(intreturn_code);
310+
308311
/**
309312
** Get the number of keys in a database.
310313
** You have to get SHARED or EXCLUSIVE LOCK of the database before calling this function.

‎apache2/ag_mdb/ag_mdb_internal.h‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#ifndef_AG_MDB_INTERNAL_HEADER
22
#define_AG_MDB_INTERNAL_HEADER
3+
4+
#ifdef_WIN32
35
#ifdefinline
46
#undef inline
57
#endif
6-
#ifdef_WIN32
7-
#include<windows.h>
8+
#include<windows.h>
89
#include<Synchapi.h>
910
#else
1011
#include<sys/shm.h>
@@ -337,11 +338,11 @@ int Entry_setKeyValue(CPTR_VOID shm_base, PTR_OFFSET entry_id, const char* key,
337338
*/
338339

339340
/**
340-
** Define the nameprefix of Read/Write lock on Windows
341+
** Define the namesuffix of Read/Write lock on Windows
341342
*/
342343
#ifdef_WIN32
343-
#defineREAD_LOCK_PREFIX "DB_LOCK_READ_"
344-
#defineWRITE_LOCK_PREFIX "DB_LOCK_WRITE_"
344+
#defineREAD_LOCK_SUFFIX "_DB_LOCK_READ"
345+
#defineWRITE_LOCK_SUFFIX "_DB_LOCK_WRITE"
345346
#endif
346347

347348
/**

‎apache2/persist_dbm.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,11 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
609609
if(ag_dbm==NULL) {
610610
//Create the DB
611611
root_dcfg=msr->dcfg1->root_config;
612+
#ifdef_WIN32
613+
dbm_filename=apr_pstrcat(root_dcfg->mp,"Global\\",root_dcfg->data_dir,"/",var_name->value,NULL);
614+
#else
612615
dbm_filename=apr_pstrcat(root_dcfg->mp,root_dcfg->data_dir,"/",var_name->value,NULL);
616+
#endif
613617
if(root_dcfg==NULL){
614618
msr_log(msr,1,"collection_retrieve_ex_agmdb: Cannot find root_config in msr->dcfg1.");
615619
gotoerror;
@@ -621,7 +625,7 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
621625

622626
rc=AGMDB_openDB(new_handle->handle,dbm_filename,strlen(dbm_filename),MAXIMUM_AGMDB_ENTRY_NUM);
623627
if(AGMDB_isError(rc)){
624-
msr_log(msr,1,"collection_retrieve_ex_agmdb: Failed to create DBM name: %s. Error info: %s",apr_psprintf(msr->mp,"%.*s",var_name->value_len,var_name->value),AGMDB_getErrorInfo(rc));
628+
msr_log(msr,1,"collection_retrieve_ex_agmdb: Failed to create DBM name: %s. Error info: %s",dbm_filename,AGMDB_getErrorInfo(rc));
625629
gotoerror;
626630
}
627631
ag_dbm=new_handle->handle;

‎iis/Makefile.win‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ INCLUDES = $(INCLUDES) -I$(YAJL)\include -I$(YAJL) \
6262
# DEFS=$(DEFS) -DWITH_SSDEEP
6363
# INCLUDES = $(INCLUDES) -I$(SSDEEP)\include -I$(SSDEEP) \
6464
# !ENDIF
65-
66-
67-
65+
66+
# Enable support for collection's memory database
67+
DEFS=$(DEFS) -DMEMORY_DATABASE_ENABLE
6868

6969
CFLAGS= -MD /Zi $(INCLUDES) $(DEFS)
7070

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp