mirror of
https://git.openafs.org/openafs.git
synced 2025-01-21 00:10:15 +00:00
Windows: cleanup redirector pipes
If pipe creation fails, cleanup the mess. At shutdown, if there are pipes that have not been closed by Windows, clean them up. This is just to ensure that at shutdown the reference counts of cm_scache_t objects in the cache are reset to zero. Change-Id: I1d738c31faafce445f05adc4884c7711123589e2 Reviewed-on: http://gerrit.openafs.org/7366 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com> Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
This commit is contained in:
parent
542dad7573
commit
e9e14b5519
@ -168,6 +168,7 @@ RDR_Initialize(void)
|
||||
if (dwRet == ERROR_SUCCESS) {
|
||||
|
||||
RDR_InitIoctl();
|
||||
RDR_InitPipe();
|
||||
}
|
||||
|
||||
return dwRet;
|
||||
@ -279,6 +280,10 @@ RDR_ShutdownNotify(void)
|
||||
// log the error, nothing to do
|
||||
}
|
||||
|
||||
|
||||
RDR_ShutdownIoctl();
|
||||
RDR_ShutdownPipe();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -143,6 +143,12 @@ RDR_InitIoctl(void)
|
||||
RDR_ioctlProcsp[VIOC_SETVERIFYDATA] = RDR_IoctlSetVerifyData;
|
||||
}
|
||||
|
||||
void
|
||||
RDR_ShutdownIoctl(void)
|
||||
{
|
||||
lock_FinalizeRWLock(&RDR_globalIoctlLock);
|
||||
}
|
||||
|
||||
/* called to make a fid structure into an IOCTL fid structure */
|
||||
void
|
||||
RDR_SetupIoctl(ULONG index, cm_fid_t *parentFid, cm_fid_t *rootFid, cm_user_t *userp)
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
extern void RDR_InitIoctl(void);
|
||||
|
||||
extern void RDR_ShutdownIoctl(void);
|
||||
|
||||
extern void RDR_SetupIoctl(ULONG index, cm_fid_t *parentFid, cm_fid_t *rootFid, cm_user_t *userp);
|
||||
|
||||
extern void RDR_CleanupIoctl(ULONG index);
|
||||
|
@ -69,6 +69,15 @@ RDR_InitPipe(void)
|
||||
lock_InitializeRWLock(&RDR_globalPipeLock, "RDR global pipe lock", LOCK_HIERARCHY_RDR_GLOBAL);
|
||||
}
|
||||
|
||||
void
|
||||
RDR_ShutdownPipe(void)
|
||||
{
|
||||
while (RDR_allPipes) {
|
||||
RDR_CleanupPipe(RDR_allPipes->index);
|
||||
}
|
||||
lock_FinalizeRWLock(&RDR_globalPipeLock);
|
||||
}
|
||||
|
||||
RDR_pipe_t *
|
||||
RDR_FindPipe(ULONG index, int locked)
|
||||
{
|
||||
@ -95,6 +104,7 @@ RDR_SetupPipe( ULONG index, cm_fid_t *parentFid, cm_fid_t *rootFid,
|
||||
cm_req_t req;
|
||||
DWORD status;
|
||||
char name[MAX_PATH];
|
||||
int newpipe = 0;
|
||||
|
||||
cm_InitReq(&req);
|
||||
|
||||
@ -114,19 +124,13 @@ RDR_SetupPipe( ULONG index, cm_fid_t *parentFid, cm_fid_t *rootFid,
|
||||
}
|
||||
} else {
|
||||
/* need to allocate a new one */
|
||||
newpipe = 1;
|
||||
pipep = malloc(sizeof(*pipep));
|
||||
if (pipep == NULL) {
|
||||
status = STATUS_NO_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
memset(pipep, 0, sizeof(*pipep));
|
||||
if (RDR_allPipes == NULL)
|
||||
RDR_allPipes = RDR_allPipesLast = pipep;
|
||||
else {
|
||||
pipep->prev = RDR_allPipesLast;
|
||||
RDR_allPipesLast->next = pipep;
|
||||
RDR_allPipesLast = pipep;
|
||||
}
|
||||
pipep->index = index;
|
||||
if (parentFid->cell == 0) {
|
||||
pipep->parentFid = cm_data.rootFid;
|
||||
@ -152,6 +156,43 @@ RDR_SetupPipe( ULONG index, cm_fid_t *parentFid, cm_fid_t *rootFid,
|
||||
pipep->devstate = RDR_DEVICESTATE_READMSGFROMPIPE |
|
||||
RDR_DEVICESTATE_MESSAGEMODEPIPE |
|
||||
RDR_DEVICESTATE_PIPECLIENTEND;
|
||||
|
||||
if (newpipe) {
|
||||
if (RDR_allPipes == NULL)
|
||||
RDR_allPipes = RDR_allPipesLast = pipep;
|
||||
else {
|
||||
pipep->prev = RDR_allPipesLast;
|
||||
RDR_allPipesLast->next = pipep;
|
||||
RDR_allPipesLast = pipep;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pipep->parentScp)
|
||||
cm_ReleaseSCache(pipep->parentScp);
|
||||
|
||||
if (pipep->inAllocp)
|
||||
free(pipep->inAllocp);
|
||||
if (pipep->outAllocp)
|
||||
free(pipep->outAllocp);
|
||||
|
||||
if (!newpipe) {
|
||||
if (RDR_allPipes == RDR_allPipesLast)
|
||||
RDR_allPipes = RDR_allPipesLast = NULL;
|
||||
else {
|
||||
if (pipep->prev == NULL)
|
||||
RDR_allPipes = pipep->next;
|
||||
else
|
||||
pipep->prev->next = pipep->next;
|
||||
if (pipep->next == NULL) {
|
||||
RDR_allPipesLast = pipep->prev;
|
||||
pipep->prev->next = NULL;
|
||||
} else
|
||||
pipep->next->prev = pipep->prev;
|
||||
}
|
||||
}
|
||||
free(pipep);
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
extern void RDR_InitPipe(void);
|
||||
|
||||
extern void RDR_ShutdownPipe(void);
|
||||
|
||||
extern DWORD RDR_SetupPipe( ULONG index, cm_fid_t *parentFid, cm_fid_t *rootFid,
|
||||
WCHAR *Name, DWORD NameLength,
|
||||
cm_user_t *userp);
|
||||
|
@ -288,6 +288,12 @@ RDR_ReleaseFid( IN cm_user_t *userp,
|
||||
IN DWORD ResultBufferLength,
|
||||
IN OUT AFSCommResult **ResultCB);
|
||||
|
||||
void
|
||||
RDR_InitPipe(void);
|
||||
|
||||
void
|
||||
RDR_ShutdownPipe(void);
|
||||
|
||||
void
|
||||
RDR_PipeOpen( IN cm_user_t *userp,
|
||||
IN AFSFileID ParentId,
|
||||
@ -369,6 +375,9 @@ RDR_FID2fid( IN AFSFileID *FileId,
|
||||
void
|
||||
RDR_InitIoctl(void);
|
||||
|
||||
void
|
||||
RDR_ShutdownIoctl(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user