dumpcap: Fix pipe read deadlock on Windows

The deadlock would occur if pipe was closed before the requested number
of bytes was read.

Bug: 15695
Change-Id: I1236dd397d3c268dd52233ea78fb58165d0c9398
Reviewed-on: https://code.wireshark.org/review/32907
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Tomasz Moń 2019-04-20 09:42:51 +02:00 committed by Anders Broman
parent a051d5d869
commit 93b9388676

View File

@ -1348,6 +1348,12 @@ static void *cap_thread_read(void *arg)
}
g_mutex_unlock(pcap_src->cap_pipe_read_mtx);
}
/* Post to queue if we didn't read enough data as the main thread waits for the message */
g_mutex_lock(pcap_src->cap_pipe_read_mtx);
if (pcap_src->cap_pipe_bytes_read < pcap_src->cap_pipe_bytes_to_read) {
g_async_queue_push(pcap_src->cap_pipe_done_q, pcap_src->cap_pipe_buf); /* Any non-NULL value will do */
}
g_mutex_unlock(pcap_src->cap_pipe_read_mtx);
return NULL;
}
#endif