Anytime i use any of these tools to launch my MMO’s server they always crash on
.INVALD => unreachable,. Otherwise, the server runs normally.
In my server I initialize a player list in main
players: std.MultiArrayList(struct {
player: Player,
socket: std.posix.pollfd,
aid: common.AvatarId,
}),
pub fn init(io: std.Io, alloc: Alloc) Alloc.Error!PlayerList {
var list: PlayerList = .{ .players = .empty };
try list.players.setCapacity(alloc, PlayerCap);
list.players.len = list.players.capacity;
...
@memset(slice.items(.socket), .{ .fd = -1, .events = 0, .revents = 0 });
...
return list;
}
Then i have a background thread constantly polling the fd’s
pub fn poll(self: *PlayerList, server: *common.Server) void {
...
while (!common.Server.DEAD) {
...
const sockets = self.players.items(.socket);
_ = std.posix.poll(sockets, 10) catch |err| {
logger.err("Failed to poll? |{t}", .{err});
// FIXME : Shutdown server
break;
};
According the linux manual fd = -1 and events = 0 is an expected use case
// https://www.man7.org/linux/man-pages/man2/poll.2.html
The field fd contains a file descriptor for an open file. If this
field is negative, then the corresponding events field is ignored
and the revents field returns zero. (This provides an easy way of
ignoring a file descriptor for a single poll() call: simply set
the fd field to its bitwise complement.)
When I inspect the array begin the poll I get the reasonable results
info: len: 1310 | ptr: os.linux.pollfd@7fc5372dc280
info: pollfd: .{ .fd = -1, .events = 0, .revents = 0 }
...line repeated many times
I’m surely doing something wrong, but i’m not sure how to diagnose further. I’ve tried both llvm and self-hosted backend; same result for both.
0 Comments
Log in to join the conversation.No comments yet. Be the first to share your thoughts.