[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [win-pv-devel] [PATCH 1/4] Ensure handles are closed when pipe disconnects



> -----Original Message-----
> From: win-pv-devel [mailto:win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx] On
> Behalf Of owen.smith@xxxxxxxxxx
> Sent: 25 August 2017 11:51
> To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Owen Smith <owen.smith@xxxxxxxxxx>
> Subject: [win-pv-devel] [PATCH 1/4] Ensure handles are closed when pipe
> disconnects
> 
> From: Owen Smith <owen.smith@xxxxxxxxxx>
> 
> Fixes leaks where the pipe handles were not closed, preventing new
> connections. Fixes the MONITOR_PIPE context leaking when its thread
> is stopped.
> 
> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>

Acked-by: Paul Durrant <paul.durrant@xxxxxxxxxx>

> ---
>  src/monitor/monitor.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 3e535e4..112ce65 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -469,6 +469,10 @@ PipeThread(
> 
>      CloseHandle(Overlapped.hEvent);
> 
> +    CloseHandle(Pipe->Pipe);
> +    CloseHandle(Pipe->Thread);
> +    free(Pipe);
> +
>      Log("<====");
> 
>      return 0;
> @@ -525,7 +529,7 @@ ServerThread(
>                                 0,
>                                 NULL);
>          if (Pipe == INVALID_HANDLE_VALUE)
> -            break;
> +            goto fail2;
> 
>          (VOID) ConnectNamedPipe(Pipe,
>                                  &Overlapped);
> @@ -534,15 +538,17 @@ ServerThread(
>                                          Handle,
>                                          FALSE,
>                                          INFINITE);
> -        if (Object == WAIT_OBJECT_0)
> +        if (Object == WAIT_OBJECT_0) {
> +            CloseHandle(Pipe);
>              break;
> +        }
> 
>          ResetEvent(Overlapped.hEvent);
> 
>          Instance = (PMONITOR_PIPE)malloc(sizeof(MONITOR_PIPE));
>          if (Instance == NULL) {
>              CloseHandle(Pipe);
> -            break;
> +            goto fail3;
>          }
> 
>          __InitializeListHead(&Instance->ListEntry);
> @@ -557,7 +563,7 @@ ServerThread(
>          if (Instance->Thread == INVALID_HANDLE_VALUE) {
>              free(Instance);
>              CloseHandle(Pipe);
> -            break;
> +            goto fail4;
>          }
>      }
> 
> @@ -567,6 +573,12 @@ ServerThread(
> 
>      return 0;
> 
> +fail4:
> +    Log("fail4\n");
> +fail3:
> +    Log("fail3\n");
> +fail2:
> +    Log("fail2\n");
>  fail1:
>      Error = GetLastError();
> 
> --
> 2.8.3
> 
> 
> _______________________________________________
> win-pv-devel mailing list
> win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.