Skip to content

Commit

Permalink
Use vlang version 0.1.29 as this is the fastest version for ffead-cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
sumeetchhetri committed Apr 21, 2021
1 parent 75bba20 commit bb6abd8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
3 changes: 2 additions & 1 deletion docker/techempower-config/ffead-cpp-v-base.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ RUN rm -f /usr/local/lib/libffead-* /usr/local/lib/libte_benc* /usr/local/lib/li
ldconfig

RUN apt update -yqq && apt install -y git make && rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/vlang/v && cd v && make && ./v symlink
#RUN git clone https://github.com/vlang/v && cd v && make && ./v symlink
RUN wget -q https://github.com/vlang/v/releases/download/0.1.29/v_linux.zip && unzip -q v_linux.zip && cd v && chmod +x v && ./v symlink && cd .. && rm -f v_linux.zip

WORKDIR ${IROOT}/lang-server-backends/v/vweb
#COPY vweb.v ${IROOT}/lang-server-backends/v/vweb/
Expand Down
30 changes: 12 additions & 18 deletions lang-server-backends/v/pico.v/main.v
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,24 @@ fn cpy_str_1(dst byteptr, src string) int {
}

fn callback(req picohttpparser.Request, mut res picohttpparser.Response) {
mut j := 0
$if debug {
println('${req.method} ${req.path} ${req.num_headers}')
mut j := 0
for {
if j == req.num_headers {
break
}
unsafe {
k := tos(req.headers[j].name, req.headers[j].name_len)
v := tos(req.headers[j].value, req.headers[j].value_len)
k := tos(req.headers[j].name, req.headers[j].name_len)
v := tos(req.headers[j].value, req.headers[j].value_len)
$if debug {
println('${k} ${v}')
}
j = j+1
}
}

freq := C.ffead_request3{
server_str: 'picov'.str
server_str: 'picov'.str
server_str_len: u64(5)
method: req.method.str
method_len: u64(req.method.len)
Expand Down Expand Up @@ -113,8 +114,8 @@ fn callback(req picohttpparser.Request, mut res picohttpparser.Response) {
}

if scode > 0 {
smsg = tos(smsg.str, int(smsg_len))
unsafe {
smsg = tos(smsg.str, int(smsg_len))
res.buf += cpy_str_1(res.buf, "HTTP/1.1 ${scode} ${smsg}\r\n")
}
res.header_server()
Expand All @@ -124,29 +125,22 @@ fn callback(req picohttpparser.Request, mut res picohttpparser.Response) {
if j == int(headers_len) {
break
}
k := tos(req.headers[j].name, int(req.headers[j].name_len))
v := tos(req.headers[j].value, int(req.headers[j].value_len))
unsafe {
k := tos(req.headers[j].name, int(req.headers[j].name_len))
v := tos(req.headers[j].value, int(req.headers[j].value_len))
res.buf += cpy_str_1(res.buf, "${k}: ${v}\r\n")
}
j = j + 1
}
unsafe {
out_body = tos(out_body.str, int(out_body_len))
}
out_body = tos(out_body.str, int(out_body_len))
res.body(out_body)
C.ffead_cpp_resp_cleanup(resp)
} else {
unsafe {
out_mime = tos(out_mime.str, int(out_mime_len))
out_url = tos(out_url.str, int(out_url_len))
}
out_mime = tos(out_mime.str, int(out_mime_len))
out_url = tos(out_url.str, int(out_url_len))

$if debug {
println('res.url = $out_url')
}

$if debug {
println('res.mime_type = $out_mime')
}

Expand Down

0 comments on commit bb6abd8

Please sign in to comment.