Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zfl9 committed Jul 16, 2024
1 parent d023832 commit 27fdeb6
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -826,10 +826,25 @@ fn send_reply_xxx(msg: []u8, fdobj: *EvLoop.Fd, src_addr: *const cc.SockAddr, qf
if (msg.len >= dns.header_len())
_ = dns.empty_reply(msg, 0);

if (qflags.has(.from_tcp))
_ = g.evloop.send(fdobj, msg, 0)
else
if (qflags.has(.from_tcp)) {
var iov = [_]cc.iovec_t{
.{
.iov_base = std.mem.asBytes(&cc.htons(cc.to_u16(msg.len))),
.iov_len = 2,
},
.{
.iov_base = msg.ptr,
.iov_len = msg.len,
},
};
const msghdr: cc.msghdr_t = .{
.msg_iov = &iov,
.msg_iovlen = iov.len,
};
_ = g.evloop.sendmsg(fdobj, &msghdr, 0);
} else {
_ = cc.sendto(fdobj.fd, msg, 0, src_addr);
}
}

// =========================================================================
Expand Down

0 comments on commit 27fdeb6

Please sign in to comment.