diff options
| -rw-r--r-- | src/w32-io.c | 10 | 
1 files changed, 8 insertions, 2 deletions
diff --git a/src/w32-io.c b/src/w32-io.c index 0d1c810e..6302ad97 100644 --- a/src/w32-io.c +++ b/src/w32-io.c @@ -700,7 +700,7 @@ writer (void *arg)    for (;;)      {        LOCK (ctx->mutex); -      if (ctx->stop_me) +      if (ctx->stop_me && !ctx->nbytes)  	{  	  UNLOCK (ctx->mutex);  	  break; @@ -717,7 +717,7 @@ writer (void *arg)  	  TRACE_LOG ("got data to send");  	  LOCK (ctx->mutex);         	} -      if (ctx->stop_me) +      if (ctx->stop_me && !ctx->nbytes)  	{  	  UNLOCK (ctx->mutex);  	  break; @@ -776,6 +776,9 @@ writer (void *arg)    TRACE_LOG ("waiting for close");    WaitForSingleObject (ctx->close_ev, INFINITE); +  if (ctx->nbytes) +    TRACE_LOG1 ("still %d bytes in buffer at close time", ctx->nbytes); +    CloseHandle (ctx->close_ev);    CloseHandle (ctx->have_data);    CloseHandle (ctx->is_empty); @@ -892,6 +895,9 @@ destroy_writer (struct writer_context_s *ctx)      SetEvent (ctx->have_data);    UNLOCK (ctx->mutex); +  /* Give the writer a chance to flush the buffer.  */ +  WaitForSingleObject (ctx->is_empty, INFINITE); +  #ifdef HAVE_W32CE_SYSTEM    /* Scenario: We never create a full pipe, but already started       writing more than the pipe buffer.  Then we need to unblock the  | 
