Permalink
Browse files

ZMQSocket: -close: Fix crash when called twice. (NOT THREADSAFE)

  • Loading branch information...
1 parent 0e01e0b commit db51b6bd5e154d11a0788f2ea1c24a3f9d5795ea @jeremy-w committed Jan 9, 2011
Showing with 8 additions and 5 deletions.
  1. +8 −5 src/ZMQSocket.m
View
13 src/ZMQSocket.m
@@ -48,12 +48,15 @@ - (id)initWithContext:(ZMQContext *)context_ type:(ZMQSocketType)type_ {
@synthesize socket;
@synthesize closed;
- (void)close {
- int err = zmq_close(self.socket);
- if (err) {
- ZMQLogError(self, @"zmq_close");
- return;
+ // FIXME: This is not thread-safe.
+ if (!self.closed) {
+ int err = zmq_close(self.socket);
+ if (err) {
+ ZMQLogError(self, @"zmq_close");
+ return;
+ }
+ self.closed = YES;
}
- self.closed = YES;
}
- (void)dealloc {

0 comments on commit db51b6b

Please sign in to comment.