From cb22a25e9edc5d9de8726a8217ada51b1553e13f Mon Sep 17 00:00:00 2001
From: Sven-Hendrik Haase <svenstaro@gmail.com>
Date: Tue, 25 Feb 2025 16:42:28 +0100
Subject: [PATCH] Fix hanging socat

In socat 1.8.0.3, it appears a change was made to cause this command to hang indefinitely in case ignoreeof
is provided. As such, we're using a local timeout to kill the connection after some time has passed.

The upstream change in question is here: https://repo.or.cz/socat.git/commitdiff/fa67d7d380c2a9bbd348a86655974808ed510cfc
---
 .gitlab-ci.yml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fe8cc8c..925d682 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -98,7 +98,7 @@ test-basic-qemu-bios:
         -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0
         -nographic &
     - timeout 15m sh -c "while ! sshpass -e ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no arch@localhost -p 2222 sudo true; do sleep 1; done"
-    - 'echo "{\"execute\": \"guest-network-get-interfaces\"}" | socat -t0 -,ignoreeof unix-connect:/tmp/qga.sock | jq -e "any(.return.[]; .name == \"lo\")"'
+    - 'echo "{\"execute\": \"guest-network-get-interfaces\"}" | socat -T0 -,ignoreeof unix-connect:/tmp/qga.sock | jq -e "any(.return.[]; .name == \"lo\")"'
 
 test-cloudimg-qemu-bios:
   stage: test
@@ -141,7 +141,7 @@ test-cloudimg-qemu-bios:
     - timeout 15m sh -c "while ! sshpass -e ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no arch@localhost -p 2222 true; do sleep 1; done"
     - timeout 15m sh -c "while ! sshpass -e ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no arch@localhost -p 2222 pacman -Q bat tmux tree; do sleep 1; done"
     - timeout 15m sh -c "while ! sshpass -e ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no arch@localhost -p 2222 test -f /runcmd_successful ; do sleep 1; done"
-    - 'echo "{\"execute\": \"guest-network-get-interfaces\"}" | socat -t0 -,ignoreeof unix-connect:/tmp/qga.sock | jq -e "any(.return.[]; .name == \"lo\")"'
+    - 'echo "{\"execute\": \"guest-network-get-interfaces\"}" | socat -T0 -,ignoreeof unix-connect:/tmp/qga.sock | jq -e "any(.return.[]; .name == \"lo\")"'
 
 test-basic-qemu-uefi-x64:
   stage: test
@@ -163,7 +163,7 @@ test-basic-qemu-uefi-x64:
         -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0
         -nographic &
     - timeout 15m sh -c "while ! sshpass -e ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no arch@localhost -p 2222 sudo true; do sleep 1; done"
-    - 'echo "{\"execute\": \"guest-network-get-interfaces\"}" | socat -t0 -,ignoreeof unix-connect:/tmp/qga.sock | jq -e "any(.return.[]; .name == \"lo\")"'
+    - 'echo "{\"execute\": \"guest-network-get-interfaces\"}" | socat -T0 -,ignoreeof unix-connect:/tmp/qga.sock | jq -e "any(.return.[]; .name == \"lo\")"'
 
 test-cloudimg-qemu-uefi-x64:
   stage: test
@@ -209,7 +209,7 @@ test-cloudimg-qemu-uefi-x64:
     - timeout 15m sh -c "while ! sshpass -e ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no arch@localhost -p 2222 true; do sleep 1; done"
     - timeout 15m sh -c "while ! sshpass -e ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no arch@localhost -p 2222 pacman -Q bat tmux tree; do sleep 1; done"
     - timeout 15m sh -c "while ! sshpass -e ssh -o ConnectTimeout=2 -o StrictHostKeyChecking=no arch@localhost -p 2222 test -f /runcmd_successful ; do sleep 1; done"
-    - 'echo "{\"execute\": \"guest-network-get-interfaces\"}" | socat -t0 -,ignoreeof unix-connect:/tmp/qga.sock | jq -e "any(.return.[]; .name == \"lo\")"'
+    - 'echo "{\"execute\": \"guest-network-get-interfaces\"}" | socat -T0 -,ignoreeof unix-connect:/tmp/qga.sock | jq -e "any(.return.[]; .name == \"lo\")"'
 
 publish:
   stage: publish
-- 
GitLab