Perfect icon indicating copy to clipboard operation
Perfect copied to clipboard

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

Open cxr0715 opened this issue 7 years ago • 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

cxr0715 avatar Apr 26 '18 17:04 cxr0715

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

kjessup avatar Apr 26 '18 18:04 kjessup

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(){}

}

cxr0715 avatar Apr 27 '18 18:04 cxr0715

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.

kuhl avatar Nov 16 '18 16:11 kuhl