when trying to flush the send buffer, use select to wait until it is possible instead of using sleep to retry at a given frequency

This commit is contained in:
Benjamin Sergeant
2019-03-18 14:25:27 -07:00
parent 1d49ba41ea
commit 2a90e3f478
11 changed files with 126 additions and 53 deletions

View File

@ -21,20 +21,19 @@ done
# Start a receiver
mkdir -p /tmp/ws_test/receive
cd /tmp/ws_test/receive
ws receive ws://127.0.0.1:8090 &
ws receive --delay 5 ws://127.0.0.1:8090 &
mkdir /tmp/ws_test/send
cd /tmp/ws_test/send
# mkfile 10m 10M_file
dd if=/dev/urandom of=10M_file count=10000 bs=1024
dd if=/dev/urandom of=20M_file count=20000 bs=1024
# Start the sender job
ws send ws://127.0.0.1:8090 10M_file
ws send ws://127.0.0.1:8090 20M_file
# Wait until the file has been written to disk
while true
do
if test -f /tmp/ws_test/receive/10M_file ; then
if test -f /tmp/ws_test/receive/20M_file ; then
echo "Received file does exists, exiting loop"
break
fi
@ -42,8 +41,8 @@ do
sleep 0.1
done
cksum /tmp/ws_test/send/10M_file
cksum /tmp/ws_test/receive/10M_file
cksum /tmp/ws_test/send/20M_file
cksum /tmp/ws_test/receive/20M_file
# Give some time to ws receive to terminate
sleep 2