mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-15 07:43:50 +00:00
1. Added CancelEx
2. Updated, so if ReadEx is used, buffer is not freed directly
This commit is contained in:
@@ -79,6 +79,7 @@ typedef struct ILibProcessPipe_PipeObject
|
||||
ILibProcessPipe_GenericBrokenPipeHandler brokenPipeHandler;
|
||||
void *user1, *user2;
|
||||
#ifdef WIN32
|
||||
int usingCompletionRoutine;
|
||||
HANDLE mPipe_Reader_ResumeEvent;
|
||||
HANDLE mPipe_ReadEnd;
|
||||
HANDLE mPipe_WriteEnd;
|
||||
@@ -554,10 +555,13 @@ void ILibProcessPipe_FreePipe(ILibProcessPipe_PipeObject *pipeObject)
|
||||
if (pipeObject->mPipe_ReadEnd != NULL) { CloseHandle(pipeObject->mPipe_ReadEnd); }
|
||||
if (pipeObject->mPipe_WriteEnd != NULL && pipeObject->mPipe_WriteEnd != pipeObject->mPipe_ReadEnd) { CloseHandle(pipeObject->mPipe_WriteEnd); }
|
||||
if (pipeObject->mOverlapped != NULL) { CloseHandle(pipeObject->mOverlapped->hEvent); free(pipeObject->mOverlapped); }
|
||||
if (pipeObject->mwOverlapped != NULL) { free(pipeObject->mwOverlapped); }
|
||||
if (pipeObject->mPipe_Reader_ResumeEvent != NULL) { CloseHandle(pipeObject->mPipe_Reader_ResumeEvent); }
|
||||
if (pipeObject->buffer != NULL && pipeObject->usingCompletionRoutine == 0) { free(pipeObject->buffer); }
|
||||
#else
|
||||
if (pipeObject->buffer != NULL) { free(pipeObject->buffer); }
|
||||
#endif
|
||||
|
||||
if (pipeObject->buffer != NULL) { free(pipeObject->buffer); }
|
||||
if (pipeObject->WriteBuffer != NULL)
|
||||
{
|
||||
ILibProcessPipe_WriteData* data;
|
||||
@@ -1661,9 +1665,16 @@ void __stdcall ILibProcessPipe_Pipe_Write_CompletionRoutine(DWORD dwErrorCode, D
|
||||
((ILibProcessPipe_Pipe_WriteExHandler)j->user4)(j, j->user3, dwErrorCode, dwNumberOfBytesTransfered);
|
||||
}
|
||||
}
|
||||
int ILibProcessPipe_Pipe_CancelEx(ILibProcessPipe_Pipe targetPipe)
|
||||
{
|
||||
ILibProcessPipe_PipeObject *j = (ILibProcessPipe_PipeObject*)targetPipe;
|
||||
if (!ILibMemory_CanaryOK(j) || j->mPipe_ReadEnd == NULL) { return(2); }
|
||||
return(CancelIoEx(j->mPipe_ReadEnd, NULL));
|
||||
}
|
||||
void ILibProcessPipe_Pipe_ReadEx(ILibProcessPipe_Pipe targetPipe, char *buffer, int bufferLength, void *user, ILibProcessPipe_Pipe_ReadExHandler OnReadHandler)
|
||||
{
|
||||
ILibProcessPipe_PipeObject *j = (ILibProcessPipe_PipeObject*)targetPipe;
|
||||
j->usingCompletionRoutine = 1;
|
||||
j->buffer = buffer;
|
||||
j->bufferSize = bufferLength;
|
||||
j->user1 = user;
|
||||
|
||||
@@ -57,6 +57,7 @@ HANDLE ILibProcessPipe_Manager_GetWorkerThread(ILibProcessPipe_Manager mgr);
|
||||
ILibTransport_DoneState ILibProcessPipe_Pipe_Write(ILibProcessPipe_Pipe writePipe, char* buffer, int bufferLen, ILibTransport_MemoryOwnership ownership);
|
||||
void ILibProcessPipe_Pipe_AddPipeReadHandler(ILibProcessPipe_Pipe targetPipe, int bufferSize, ILibProcessPipe_Pipe_ReadHandler OnReadHandler);
|
||||
#ifdef WIN32
|
||||
int ILibProcessPipe_Pipe_CancelEx(ILibProcessPipe_Pipe targetPipe);
|
||||
void ILibProcessPipe_Pipe_ReadEx(ILibProcessPipe_Pipe targetPipe, char *buffer, int bufferLength, void *user, ILibProcessPipe_Pipe_ReadExHandler OnReadHandler);
|
||||
void ILibProcessPipe_Pipe_WriteEx(ILibProcessPipe_Pipe targetPipe, char *buffer, int bufferLength, void *user, ILibProcessPipe_Pipe_WriteExHandler OnWriteHandler);
|
||||
ILibProcessPipe_Pipe ILibProcessPipe_Pipe_CreateFromExistingWithExtraMemory(ILibProcessPipe_Manager manager, HANDLE existingPipe, ILibProcessPipe_Pipe_ReaderHandleType handleType, int extraMemorySize);
|
||||
|
||||
Reference in New Issue
Block a user