Update RunLoop/AsyncUdpSocket.m #49

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
@gghose

gghose commented Apr 28, 2012

Found a pretty bad bug. The queues aren't safe because you can potentially remove objects at position 0 (dequeuing) at the same time you're adding objects. The solution is to put in a lock whenever you manipulate the queue. This got rid of consistent crashes for me.

So I've added NSLock objects theSendQueueLock and theReceiveQueueLock. (Note you'll need to declare them in the corresponding AsyncUdpSocket.h).

This is the only part of the library I'm actually using, so I don't know how pervasive this queuing problem is.

@evands

This comment has been minimized.

Show comment Hide comment
@evands

evands Jul 25, 2012

The RunLoop based Async socket classes are explicitly not threadsafe; you need to always access them on the same run loop to be safe.

evands commented Jul 25, 2012

The RunLoop based Async socket classes are explicitly not threadsafe; you need to always access them on the same run loop to be safe.

@dvor

This comment has been minimized.

Show comment Hide comment
@dvor

dvor Dec 19, 2013

Collaborator

@evands is right, RunLoop socket library isn't thread safe. Closing this issue.

Collaborator

dvor commented Dec 19, 2013

@evands is right, RunLoop socket library isn't thread safe. Closing this issue.

@dvor dvor closed this Dec 19, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment