Skip to content

Commit

Permalink
*update Dockerfile *add more read timeout set point
Browse files Browse the repository at this point in the history
  • Loading branch information
vyloy committed Dec 15, 2023
1 parent 77e0f36 commit 7bd656c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
23 changes: 5 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.20-bullseye
FROM golang:1.20-bookworm

# apt 切换国内源,安装 google webrtc 依赖安装脚本的依赖
# mirrors.163.com
# repo.huaweicloud.com
RUN sed -i 's|deb.debian.org|mirrors.163.com|g' /etc/apt/sources.list && \
apt update && \
RUN apt update && \
apt install xz-utils bzip2 sudo lsb-release ninja-build generate-ninja file patch -y

# 安装nodejs 20
Expand All @@ -31,12 +27,7 @@ RUN apt-get install -y ca-certificates curl gnupg && \
apt-get install nodejs -y

# 安装msquic依赖
RUN apt-get update && \
apt-get install -y cmake build-essential liblttng-ust-dev lttng-tools libssl-dev && \
wget https://cmake.org/files/v3.23/cmake-3.23.0.tar.gz && \
tar -zxvf cmake-3.23.0.tar.gz && cd cmake-3.23.0 && ./configure && make -j8 && make install && \
cmake --version
# RUN apt-get install -y cmake build-essential liblttng-ust-dev lttng-tools
RUN apt-get install -y cmake build-essential liblttng-ust-dev lttng-tools libssl-dev

# golang 切换国内源并且提前安装好依赖
ENV GO111MODULE=on
Expand All @@ -47,16 +38,12 @@ RUN cd /go/src/github.com/isrc-cas/gt && \
rm -rf /go/src/github.com/isrc-cas/gt

# 安装 gnu 编译链
RUN apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-x86-64-linux-gnu g++-x86-64-linux-gnu -y
RUN apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-x86-64-linux-gnu g++-x86-64-linux-gnu

# 安装 google webrtc 依赖
ADD ./dep/_google-webrtc/src/build /root/build
RUN sed -i 's/egrep -q "i686|x86_64"/true/g' /root/build/install-build-deps.sh && \
DEBIAN_FRONTEND=noninteractive TZ=Asia/Shanghai bash /root/build/install-build-deps.sh --no-chromeos-fonts && \
rm -rf /root/build

RUN if uname -m | grep aarch64; then \
file /usr/x86_64-linux-gnu/lib/libm.a | grep "ASCII text" && \
rm -f /usr/x86_64-linux-gnu/lib/libm.a && \
ln -s /usr/x86_64-linux-gnu/lib/libm-2.31.a /usr/x86_64-linux-gnu/lib/libm.a && echo "success"; \
fi
RUN cp -r /usr/x86_64-linux-gnu/lib/* /usr/lib/x86_64-linux-gnu/
13 changes: 13 additions & 0 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,12 @@ func (c *conn) process(taskID uint32, task *conn, cli *client) {
buf[4] = byte(predef.Close >> 8)
buf[5] = byte(predef.Close)
_, wErr = c.Write(buf[:6])
if wErr == nil &&
c.server.config.Timeout.Duration > 0 &&
!c.server.config.TimeoutOnUnidirectionalTraffic {
dl := time.Now().Add(c.server.config.Timeout.Duration)
wErr = c.SetReadDeadline(dl)
}
}
pool.BytesPool.Put(buf)
if rErr != nil || wErr != nil {
Expand Down Expand Up @@ -1011,6 +1017,13 @@ func (c *conn) process(taskID uint32, task *conn, cli *client) {
if wErr != nil {
return
}
if c.server.config.Timeout.Duration > 0 && !c.server.config.TimeoutOnUnidirectionalTraffic {
dl := time.Now().Add(c.server.config.Timeout.Duration)
wErr = c.SetReadDeadline(dl)
if wErr != nil {
return
}
}

bufIndex -= 4
buf[bufIndex] = byte(predef.Data >> 8)
Expand Down

0 comments on commit 7bd656c

Please sign in to comment.