PerfectlySoft/Perfect

when i was send request with for i in 0..<2 {Alamofire.request(.....)}

cxr0715 opened this issue · 3 comments

when i was send request with

for i in 0..<2 {
       //client send
       //and server will run: self.mysql.query(statement: "select * from home")
       Alamofire.request(.....)
}

have a crash happened

and send only one request Alamofire.request(.....),server is done
qq20180427-014657 2x

Are you using a global MySQL connection or sharing them amongst threads in any way? Sharing one connection is definitely not thread-safe.

but I use MySQLManager connected is Singleton whit thread-safe

class MySQLManager {
    var mysql : MySQL!
    static let shareInstance : MySQLManager = {
        let instance = MySQLManager()
        let testHost = "127.0.0.1"
        let testUser = "root"
        let testPassword = "********"
        let testDB = "********"
        instance.mysql = MySQL()
        let connected = instance.mysql.connect(host: testHost, user: testUser, password: testPassword, db: testDB)
        
        if connected {
            print("connectedSuccess")
        } else {
            print("connectedError")
        }
        
        guard connected else {
            print(instance.mysql.errorMessage())
            return instance
        }
        return instance
    }()
    private init(){}

}
kuhl commented

A "use of undeclared type" usually means you have a linker error. Check your target. I don't think this is an issue in Perfect. Please close.