取context,下标,不得不休,是抵抗DDOS重要一环。
【 在 ylh1969 的大作中提到: 】
: int repeat=0;
: leng=sizeof(cin);
: while(1) {
: ...................
static int get_task_no()
{
int i,ret;
struct timespec abstime;
abstime.tv_sec=0;
pthread_mutex_lock(&client_q.mut);
while(0>(i=TCB_get(&client_q.free_q))) {
if(abstime.tv_sec==0) ShowLog(1,"%s:超过最大连接数!",__FUNCTION__);
clock_gettime(CLOCK_REALTIME, &abstime);
abstime.tv_sec+=5;
ret=pthread_cond_timedwait(&client_q.cond,&client_q.mut,&abstime);
if(ret==ETIMEDOUT) {
pthread_mutex_unlock(&client_q.mut);
check_TCB_timeout();
pthread_mutex_lock(&client_q.mut);
}
}
pthread_mutex_unlock(&client_q.mut);
return i;
}
--
FROM 221.218.60.*