一个quick-cocos2dx 2.2.6里遇到的一个线程信号锁的问题
quick的网络调用是通过在文件HttpClient.cpp里实现的
CCHttpClient类里的send方法可以将请求发送出去。
void CCHttpClient::send(CCHttpRequest* request)
{
if (false == lazyInitThreadSemphore())
{
return;
}
if (!request)
{
return;
}
++s_asyncRequestCount;
request->retain();
pthread_mutex_lock(&s_requestQueueMutex);
s_requestQueue->addObject(request);
pthread_mutex_unlock(&s_requestQueueMutex);
// Notify thread start to work
sem_post(s_pSem);
}
但是,在发送之前会有一个切线程的准备工作,lazyInitThreadSemphore()
在这里面会有一个新建?信号灯的步骤
s_pSem = sem_open(CC_ASYNC_HTTPREQUEST_SEMAPHORE, O_CREAT, 0644, 0);
但是在某些时候,这个结果会是SEM_FAILED,然后查看errno,结果是EPERM
#define EPERM 1 /* Operation not permitted */
因为这个问题并非必现,所以想问一下,什么情况会导致"Operation not permitted"