send optimization + ws file transfer test
This commit is contained in:
parent
34de36fe01
commit
5b4354a6f3
@ -1 +0,0 @@
|
||||
docker/Dockerfile.debian
|
31
Dockerfile
Normal file
31
Dockerfile
Normal file
@ -0,0 +1,31 @@
|
||||
FROM debian:stretch
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install g++
|
||||
RUN apt-get -y install libssl-dev
|
||||
RUN apt-get -y install gdb
|
||||
RUN apt-get -y install screen
|
||||
RUN apt-get -y install procps
|
||||
RUN apt-get -y install lsof
|
||||
RUN apt-get -y install libz-dev
|
||||
RUN apt-get -y install vim
|
||||
RUN apt-get -y install make
|
||||
RUN apt-get -y install cmake
|
||||
RUN apt-get -y install curl
|
||||
RUN apt-get -y install python
|
||||
RUN apt-get -y install netcat
|
||||
|
||||
# debian strech cmake is too old for building with Docker
|
||||
COPY makefile .
|
||||
RUN ["make", "install_cmake_for_linux"]
|
||||
|
||||
COPY . .
|
||||
|
||||
ARG CMAKE_BIN_PATH=/tmp/cmake/cmake-3.14.0-rc4-Linux-x86_64/bin
|
||||
ENV PATH="${CMAKE_BIN_PATH}:${PATH}"
|
||||
|
||||
# RUN ["make"]
|
||||
|
||||
EXPOSE 8765
|
||||
CMD ["/ws/ws", "transfer", "--port", "8765", "--host", "0.0.0.0"]
|
@ -1,30 +0,0 @@
|
||||
FROM debian:stretch
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install g++
|
||||
RUN apt-get -y install libssl-dev
|
||||
RUN apt-get -y install gdb
|
||||
RUN apt-get -y install screen
|
||||
RUN apt-get -y install procps
|
||||
RUN apt-get -y install lsof
|
||||
RUN apt-get -y install libz-dev
|
||||
RUN apt-get -y install vim
|
||||
RUN apt-get -y install make
|
||||
RUN apt-get -y install cmake
|
||||
RUN apt-get -y install curl
|
||||
RUN apt-get -y install python
|
||||
|
||||
# debian strech cmake is too old for building with Docker
|
||||
COPY makefile .
|
||||
RUN ["make", "install_cmake_for_linux"]
|
||||
|
||||
COPY . .
|
||||
|
||||
ARG CMAKE_BIN_PATH=/tmp/cmake/cmake-3.14.0-rc4-Linux-x86_64/bin
|
||||
ENV PATH="${CMAKE_BIN_PATH}:${PATH}"
|
||||
|
||||
# RUN ["make"]
|
||||
|
||||
EXPOSE 8765
|
||||
CMD ["/ws/ws", "transfer", "--port", "8765", "--host", "0.0.0.0"]
|
@ -605,7 +605,11 @@ namespace ix
|
||||
}
|
||||
}
|
||||
|
||||
_socket->wakeUpFromPoll(Socket::kSendRequest);
|
||||
// Request to flush the send buffer on the background thread if it isn't empty
|
||||
if (!isSendBufferEmpty())
|
||||
{
|
||||
_socket->wakeUpFromPoll(Socket::kSendRequest);
|
||||
}
|
||||
|
||||
return WebSocketSendInfo(true, compressionError, payloadSize, wireSize);
|
||||
}
|
||||
|
3
makefile
3
makefile
@ -36,6 +36,9 @@ test_server:
|
||||
test:
|
||||
python test/run.py
|
||||
|
||||
ws_test:
|
||||
(cd ws ; sh test_ws.sh)
|
||||
|
||||
# For the fork that is configured with appveyor
|
||||
rebase_upstream:
|
||||
git fetch upstream
|
||||
|
16
ws/ws.cpp
16
ws/ws.cpp
@ -16,6 +16,8 @@
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cli11/CLI11.hpp>
|
||||
#include <ixwebsocket/IXSocket.h>
|
||||
@ -32,6 +34,7 @@ int main(int argc, char** argv)
|
||||
std::string headers;
|
||||
std::string output;
|
||||
std::string hostname("127.0.0.1");
|
||||
std::string pidfile;
|
||||
bool headersOnly = false;
|
||||
bool followRedirects = false;
|
||||
bool verbose = false;
|
||||
@ -52,6 +55,7 @@ int main(int argc, char** argv)
|
||||
CLI::App* transferApp = app.add_subcommand("transfer", "Broadcasting server");
|
||||
transferApp->add_option("--port", port, "Connection url");
|
||||
transferApp->add_option("--host", hostname, "Hostname");
|
||||
transferApp->add_option("--pidfile", pidfile, "Pid file");
|
||||
|
||||
CLI::App* connectApp = app.add_subcommand("connect", "Connect to a remote server");
|
||||
connectApp->add_option("url", url, "Connection url")->required();
|
||||
@ -90,8 +94,20 @@ int main(int argc, char** argv)
|
||||
|
||||
ix::Socket::init();
|
||||
|
||||
// pid file handling
|
||||
|
||||
if (app.got_subcommand("transfer"))
|
||||
{
|
||||
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"))
|
||||
|
@ -146,11 +146,16 @@ namespace ix
|
||||
std::string filename = data["filename"].string_value();
|
||||
filename = extractFilename(filename);
|
||||
|
||||
std::cout << "Writing to disk: " << filename << std::endl;
|
||||
std::ofstream out(filename);
|
||||
std::string filenameTmp = filename + ".tmp";
|
||||
|
||||
std::cout << "Writing to disk: " << filenameTmp << std::endl;
|
||||
std::ofstream out(filenameTmp);
|
||||
out.write((char*)&content.front(), content.size());
|
||||
out.close();
|
||||
|
||||
std::cout << "Renaming " << filenameTmp << " to " << filename << std::endl;
|
||||
rename(filenameTmp.c_str(), filename.c_str());
|
||||
|
||||
std::map<MsgPack, MsgPack> pdu;
|
||||
pdu["ack"] = true;
|
||||
pdu["id"] = data["id"];
|
||||
|
Loading…
Reference in New Issue
Block a user