aboutsummaryrefslogtreecommitdiffstats
path: root/dumpcap.c
diff options
context:
space:
mode:
authorTomasz Moń <desowin@gmail.com>2019-04-20 09:42:51 +0200
committerAnders Broman <a.broman58@gmail.com>2019-04-21 07:31:57 +0000
commit93b9388676a3dbfb3d079a9f4335c090b7b45b98 (patch)
treed24d1dfe736925c85de4921c686054f54fcf34d5 /dumpcap.c
parenta051d5d869e1932a718eb43bc2089e88cadd30e3 (diff)
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>
Diffstat (limited to 'dumpcap.c')
-rw-r--r--dumpcap.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/dumpcap.c b/dumpcap.c
index a706132f93..9ea7076c35 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -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