libwinpr-pipe: fix circular dependency

This commit is contained in:
Marc-André Moreau 2014-05-08 17:17:39 -04:00
parent 4dc6ffdaaa
commit 06d36c7084
3 changed files with 15 additions and 16 deletions

View File

@ -169,7 +169,7 @@ BOOL CloseHandle(HANDLE hObject)
if (--pipe->dwRefCount == 0)
{
ArrayList_Remove(WinPR_GetBaseNamedPipeList(), pipe);
pipe->pfnRemoveBaseNamedPipeFromList(pipe);
if (pipe->pBaseNamedPipe)
{

View File

@ -45,7 +45,7 @@
#include "pipe.h"
/*
* Since the WINPR implementation of named pipes makes use of UNIX domain
* Since the WinPR implementation of named pipes makes use of UNIX domain
* sockets, it is not possible to bind the same name more than once (i.e.,
* SO_REUSEADDR does not work with UNIX domain sockets). As a result, the
* first call to CreateNamedPipe must create the UNIX domain socket and
@ -64,19 +64,19 @@ static BOOL g_Initialized = FALSE;
static void InitWinPRPipeModule()
{
if (g_Initialized) return;
if (g_Initialized)
return;
g_BaseNamedPipeList = ArrayList_New(TRUE);
g_Initialized = TRUE;
}
wArrayList* WinPR_GetBaseNamedPipeList()
void WinPR_RemoveBaseNamedPipeFromList(WINPR_NAMED_PIPE* pNamedPipe)
{
return g_BaseNamedPipeList;
ArrayList_Remove(g_BaseNamedPipeList, pNamedPipe);
}
/*
* Unnamed pipe
*/
@ -146,15 +146,18 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD
pBaseNamedPipe = NULL;
ArrayList_Lock(g_BaseNamedPipeList);
for (index = 0; index < ArrayList_Count(g_BaseNamedPipeList); index++)
{
WINPR_NAMED_PIPE* p = (WINPR_NAMED_PIPE*) ArrayList_GetItem(g_BaseNamedPipeList, index);
if (strcmp(p->name, lpName) == 0)
{
pBaseNamedPipe = p;
break;
}
}
ArrayList_Unlock(g_BaseNamedPipeList);
pNamedPipe = (WINPR_NAMED_PIPE*) malloc(sizeof(WINPR_NAMED_PIPE));
@ -162,6 +165,8 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD
WINPR_HANDLE_SET_TYPE(pNamedPipe, HANDLE_TYPE_NAMED_PIPE);
pNamedPipe->pfnRemoveBaseNamedPipeFromList = WinPR_RemoveBaseNamedPipeFromList;
pNamedPipe->name = _strdup(lpName);
pNamedPipe->dwOpenMode = dwOpenMode;
pNamedPipe->dwPipeMode = dwPipeMode;

View File

@ -37,6 +37,8 @@ typedef struct winpr_pipe WINPR_PIPE;
typedef struct winpr_named_pipe WINPR_NAMED_PIPE;
typedef void ( * fnRemoveBaseNamedPipeFromList)(WINPR_NAMED_PIPE* pNamedPipe);
struct winpr_named_pipe
{
WINPR_HANDLE_DEF();
@ -61,18 +63,10 @@ struct winpr_named_pipe
DWORD nDefaultTimeOut;
DWORD dwFlagsAndAttributes;
LPOVERLAPPED lpOverlapped;
fnRemoveBaseNamedPipeFromList pfnRemoveBaseNamedPipeFromList;
};
#ifdef __cplusplus
extern "C" {
#endif
wArrayList* WinPR_GetBaseNamedPipeList();
#ifdef __cplusplus
}
#endif
#endif
#endif /* WINPR_PIPE_PRIVATE_H */