I have another NSXPC problem, and the problem goes like this
- NSXPC server implements an interface
-(void) callbackWithInfo:(NSDictionary*)log reply:(void (^)(bool))action;
- The NSXPC client implements a method that will call the interface in a loop and perform a timeout operation. If the server returns to the interface and does not call the action after 1s, the client will perform subsequent operations. The
callbackWithInfo
interface is then called again, and the cycle continues.
client code: The general structure is as follows
while(true){
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[serverProxy callbackWithInfo:InfoDic reply:^(bool action) {
if(flag != NO){
flag = action;
}
}];
dispatch_semaphore_signal(semaphore);
});
if(dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, self.waitTime *NSEC_PER_MSEC)) != 0){
NSLog(@"flag: %d", flag);
}
sleep(0.1);
}
If the action callback is not invoked on the server, the number of FDS on the client increases. As a result, the process cannot open the file, or too much program context information is generated. As a result, the NSXPC interface fails to be invoked. Now I can not operate on the server side, how can the client side implement the code to ensure that the action will not be punished, and the fd will not increase.