mirror of https://gitee.com/bigwinds/arangodb
correct verion of plugin
This commit is contained in:
parent
ce54ce59f8
commit
ab4e60d861
|
@ -34,13 +34,13 @@ extra_parameters* g_extra = NULL;
|
|||
/// handle for the memory segment
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
HANDLE hMapFile = NULL;
|
||||
// HANDLE hMapFile = NULL;
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
/// content of the memory segment
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
LPCTSTR pBuf = NULL;
|
||||
// LPCTSTR pBuf = NULL;
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
/// content of the memory segment
|
||||
|
@ -88,7 +88,8 @@ void PushReturnValue(int value);
|
|||
|
||||
PUBLIC_FUNCTION(CreateSharedMemory)
|
||||
{
|
||||
|
||||
HANDLE hMapFile = NULL;
|
||||
LPCTSTR pBuf = NULL;
|
||||
TCHAR * szName = SHARED_MEM_SEGMENT;
|
||||
SECURITY_ATTRIBUTES attr;
|
||||
attr.bInheritHandle = 1;
|
||||
|
@ -139,16 +140,45 @@ PUBLIC_FUNCTION_END
|
|||
|
||||
PUBLIC_FUNCTION(WriteIntoSharedMem)
|
||||
{
|
||||
if(!pBuf) {
|
||||
PushReturnValue(-1);
|
||||
return;
|
||||
}
|
||||
HANDLE hMapFile = NULL;
|
||||
LPCTSTR pBuf = NULL;
|
||||
|
||||
TCHAR * szMsg = (TCHAR*)LocalAlloc(LPTR, g_string_size * sizeof(TCHAR));
|
||||
if (!szMsg) {
|
||||
PushReturnValue(-2); // memory could not be allocated
|
||||
return;
|
||||
}
|
||||
hMapFile = OpenFileMapping(
|
||||
FILE_MAP_WRITE, // read/write access
|
||||
FALSE, // do not inherit the name
|
||||
SHARED_MEM_SEGMENT); // name of mapping object
|
||||
|
||||
if (hMapFile == NULL)
|
||||
{
|
||||
PushReturnValue(GetLastError());
|
||||
// _tprintf(TEXT("Could not open file mapping object (%d).\n"),
|
||||
// GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
pBuf = (LPTSTR)MapViewOfFile(hMapFile, // handle to map object
|
||||
FILE_MAP_ALL_ACCESS, // read/write permission
|
||||
0,
|
||||
0,
|
||||
BUF_SIZE);
|
||||
|
||||
if (pBuf == NULL)
|
||||
{
|
||||
// _tprintf(TEXT("Could not map view of file (%d).\n"),
|
||||
// GetLastError());
|
||||
|
||||
PushReturnValue(GetLastError());
|
||||
|
||||
CloseHandle(hMapFile);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// read name for mem segment from stack
|
||||
popstring(szMsg);
|
||||
CopyMemory((PVOID)pBuf, szMsg, (_tcslen(szMsg) * sizeof(TCHAR)));
|
||||
|
@ -164,14 +194,13 @@ PUBLIC_FUNCTION_END
|
|||
|
||||
PUBLIC_FUNCTION(ReadIntoSharedMem)
|
||||
{
|
||||
HANDLE hMapFile;
|
||||
LPCTSTR pBuf;
|
||||
TCHAR * szName = SHARED_MEM_SEGMENT;
|
||||
HANDLE hMapFile = NULL;
|
||||
LPCTSTR pBuf = NULL;
|
||||
|
||||
hMapFile = OpenFileMapping(
|
||||
FILE_MAP_WRITE, // read/write access
|
||||
FALSE, // do not inherit the name
|
||||
szName); // name of mapping object
|
||||
SHARED_MEM_SEGMENT); // name of mapping object
|
||||
|
||||
if (hMapFile == NULL)
|
||||
{
|
||||
|
@ -210,17 +239,22 @@ PUBLIC_FUNCTION(ReadIntoSharedMem)
|
|||
}
|
||||
PUBLIC_FUNCTION_END
|
||||
|
||||
PUBLIC_FUNCTION(RemoveSharedMem)
|
||||
PUBLIC_FUNCTION(ExistsSharedMem)
|
||||
{
|
||||
if(pBuf) {
|
||||
UnmapViewOfFile(pBuf);
|
||||
CloseHandle(hMapFile);
|
||||
pBuf = NULL;
|
||||
hMapFile = NULL;
|
||||
PushReturnValue(0);
|
||||
HANDLE hMapFile = NULL;
|
||||
|
||||
hMapFile = OpenFileMapping(
|
||||
FILE_MAP_WRITE, // read/write access
|
||||
FALSE, // do not inherit the name
|
||||
SHARED_MEM_SEGMENT); // name of mapping object
|
||||
|
||||
if (hMapFile == NULL)
|
||||
{
|
||||
PushReturnValue(GetLastError());
|
||||
// _tprintf(TEXT("Could not open file mapping object (%d).\n"),
|
||||
// GetLastError());
|
||||
return;
|
||||
}
|
||||
PushReturnValue(GetLastError());
|
||||
}
|
||||
|
||||
PUBLIC_FUNCTION_END
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue