seastar
seastar copied to clipboard
posix_datagram_channel::send() is not fiber-safe
future<> posix_datagram_channel::send(const socket_address& dst, packet p) {
auto len = p.len();
_send.prepare(dst, std::move(p));
auto sg_id = internal::scheduling_group_index(current_scheduling_group());
bytes_sent[sg_id] += len;
return _fd.sendmsg(&_send._hdr)
.then([len] (size_t size) { SEASTAR_ASSERT(size == len); });
}
First call to prepare() sets up posix_datagram_channel::_send, the next call to _fd.sendmsg() can yield waiting for the _fd to be writable. If at that point another fiber calls send() the _send thing gets overwritten and will spoil the former execution