Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socketMap is not cleaned on unregister #29

Open
agising opened this issue Jun 7, 2021 · 0 comments
Open

socketMap is not cleaned on unregister #29

agising opened this issue Jun 7, 2021 · 0 comments

Comments

@agising
Copy link

agising commented Jun 7, 2021

When unregistering from poller the socketMap dict is not updated. When registering again the poller somtimes get out of index.
Suggested solution, clear dict entry in poller:

        public func unregister(socket: Socket) throws {
            let socketIndex = socketMap[socket]!
            sockets.remove(at: socketIndex)
            socketMap[socket] = nil

            // Update indices of all other sockets in the socket map
            for (socket, _) in sockets.suffix(from: socketIndex) {
                let socketIndex = socketMap[socket]!
                socketMap[socket] = socketIndex - 1
            }
        }

Edit: formatting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant