Skip to content

Crash problem #521

@lexiaoyao20

Description

@lexiaoyao20

SocketIOClient.swift

public func engineDidClose(reason: String) {
        waitingPackets.removeAll()

        if status != .disconnected {
            status = .notConnected
        }

        if status == .disconnected || !reconnects {
            didDisconnect(reason: reason)
        } else if !reconnecting {
            reconnecting = true
            tryReconnect(reason: reason)
        }
    }

SocketParsable.swift

func parseBinaryData(_ data: Data) {
        guard !waitingPackets.isEmpty else {
            DefaultSocketLogger.Logger.error("Got data when not remaking packet", type: "SocketParser")
            return
        }

        // Should execute event?
        guard waitingPackets[waitingPackets.count - 1].addData(data) else { return }

        let packet = waitingPackets.removeLast()

        if packet.type != .binaryAck {
            handleEvent(packet.event, data: packet.args, isInternalMessage: false, withAck: packet.id)
        } else {
            handleAck(packet.id, data: packet.args)
        }
    }

crash at this method let packet = waitingPackets.removeLast(), perhaps caused by multi-threaded,waitingPackets.removeAll() this method need to run in parseQueue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions