diff --git a/ixwebsocket/IXWebSocketTransport.cpp b/ixwebsocket/IXWebSocketTransport.cpp index e798c24b..df56a939 100644 --- a/ixwebsocket/IXWebSocketTransport.cpp +++ b/ixwebsocket/IXWebSocketTransport.cpp @@ -211,7 +211,8 @@ namespace ix setReadyState(CLOSED); break; } - else if (result == PollResultType_ReadyForWrite) + // FIXME: why are we not getting PollResultType_ReadyForWrite ?? + else // if (result == PollResultType_ReadyForWrite) { sendOnSocket(); } diff --git a/ws/test_ws.sh b/ws/test_ws.sh index 75305520..765b7061 100644 --- a/ws/test_ws.sh +++ b/ws/test_ws.sh @@ -5,7 +5,7 @@ mkdir -p /tmp/ws_test # Start a transport server cd /tmp/ws_test -ws transfer --port 8090 --pidfile /tmp/ws_test/pidfile & +ws transfer --port 8090 --pidfile /tmp/ws_test/pidfile.transfer & # Wait until the transfer server is up while true @@ -14,21 +14,21 @@ do echo "Transfer server up and running" break } - echo "sleep ..." + echo "sleep ... wait for transfer server" sleep 0.1 done # Start a receiver mkdir -p /tmp/ws_test/receive cd /tmp/ws_test/receive -ws receive --delay 5 ws://127.0.0.1:8090 & +ws receive --delay 5 ws://127.0.0.1:8090 --pidfile /tmp/ws_test/pidfile.receive & mkdir /tmp/ws_test/send cd /tmp/ws_test/send -dd if=/dev/urandom of=20M_file count=20000 bs=1024 +dd if=/dev/urandom of=20M_file count=10000 bs=1024 # Start the sender job -ws send ws://127.0.0.1:8090 20M_file +ws send --pidfile /tmp/ws_test/pidfile.send ws://127.0.0.1:8090 20M_file # Wait until the file has been written to disk while true @@ -37,7 +37,7 @@ do echo "Received file does exists, exiting loop" break fi - echo "sleep ..." + echo "sleep ... wait for output file" sleep 0.1 done @@ -48,4 +48,7 @@ cksum /tmp/ws_test/receive/20M_file sleep 2 # Cleanup -kill `cat /tmp/ws_test/pidfile` +kill `cat /tmp/ws_test/pidfile.transfer` +kill `cat /tmp/ws_test/pidfile.receive` +kill `cat /tmp/ws_test/pidfile.send` + diff --git a/ws/ws.cpp b/ws/ws.cpp index c6b929bc..9aea1a6d 100644 --- a/ws/ws.cpp +++ b/ws/ws.cpp @@ -50,11 +50,13 @@ int main(int argc, char** argv) sendApp->add_option("url", url, "Connection url")->required(); sendApp->add_option("path", path, "Path to the file to send") ->required()->check(CLI::ExistingPath); + sendApp->add_option("--pidfile", pidfile, "Pid file"); CLI::App* receiveApp = app.add_subcommand("receive", "Receive a file"); receiveApp->add_option("url", url, "Connection url")->required(); receiveApp->add_option("--delay", delayMs, "Delay (ms) to wait after receiving a fragment" " to artificially slow down the receiver"); + receiveApp->add_option("--pidfile", pidfile, "Pid file"); CLI::App* transferApp = app.add_subcommand("transfer", "Broadcasting server"); transferApp->add_option("--port", port, "Connection url"); @@ -96,19 +98,19 @@ int main(int argc, char** argv) CLI11_PARSE(app, argc, argv); + // pid file handling + if (!pidfile.empty()) + { + unlink(pidfile.c_str()); + + std::ofstream f; + f.open(pidfile); + f << getpid(); + f.close(); + } + if (app.got_subcommand("transfer")) { - // pid file handling - if (!pidfile.empty()) - { - unlink(pidfile.c_str()); - - std::ofstream f; - f.open(pidfile); - f << getpid(); - f.close(); - } - return ix::ws_transfer_main(port, hostname); } else if (app.got_subcommand("send"))