Skip to content
This repository has been archived by the owner on Apr 5, 2019. It is now read-only.

Memory crash fix #4

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Memory crash fix #4

wants to merge 14 commits into from

Conversation

adamjernst
Copy link
Contributor

Fix a memory management problem that could cause a crash if the heartbeat timer was the last retaining reference to self.

…beat timer was the last retaining reference to self.
…o auto-reconnect after timeout, those messages would be dropped. Likewise, if the user manually tried reconnecting after a disconnection any queued messages would be dropped. Instead just let the queue be released in dealloc as it already is.
@adamjernst
Copy link
Contributor Author

Also, don't clear the queue on disconnection. See notes in commit message.

adamjernst and others added 12 commits October 26, 2011 11:41
All delegate methods are now optional. A new delegate method, -socketIoClient:didFailWithError:, is called when an underlying error occurs, or when the connection or heartbeat times out.

Removed tryAgainOnConnectTimeout as it is confusing and error-prone. Instead, delegates should check for SocketIoClientErrorConnectionTimeout and call -connect to try again if they desire. The queue of outgoing messages is preserved between attempts.

When heartbeat times out, explicitly disconnect the underlying socket immediately. Previously, the socket was left open so SocketIoClient could miraculously pop back open after a heartbeat timeout.
…-disconnect, so you don't subsequently get a timeout error anyway. Second, actually send the heartbeat timeout error.
First, use a state variable instead of potentially contradictory boolean flags.

Introduce a new delegate method socketIoClient:connectDidFailWithError: that is called when an attempt to connect fails. Document that EITHER socketIoClient:connectDidFailWithError: is called, OR socketIoClient:didDisconnectWithError: is called, but not both. (The latter is called only if a connection is established, signaled by socketIoClientDidConnect:).

Make it safe to immediately retry the connection in the delegate error handling functions by deferring their execution until the next run loop.
…o that it isn't called more than once if connect is called repeatedly. Also add two new logging statements, improve the logging output to show the socket doing the logging, and respect a SOCKETIO_DEBUG flag instead of just commenting out the NSLog.
…so, onConnectError should cancel the connect timeout.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant