         if dispatchSource != nil {
             throw punosError(0, "Already running")
         }
+        sourceGroup = dispatch_group_create()
         dispatchSource = createDispatchSource(try Socket.tcpSocketForListen(listenPort))
         guard let source = dispatchSource else {
             throw punosError(0, "Could not create dispatch source")

            } else {
                self.log("Closed listening socket \(listeningSocketFD)")
            }
            dispatch_group_leave(self.sourceGroup)
        }
        
        dispatch_source_set_event_handler(source) { _ in

        self.queue = queue
    }
    
    private var sourceGroup: dispatch_group_t?
    private var dispatchSource: dispatch_source_t?
    
    private func createDispatchSource(listeningSocket: Socket) -> dispatch_source_t? {
        guard let sourceGroup = sourceGroup else { return nil }
        
        let listeningSocketFD = listeningSocket.socketFileDescriptor
        dispatch_group_enter(sourceGroup)
        let source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, UInt(listeningSocketFD), 0, queue)
