基于EPOLL写的HTTP服务器(加入了线程池)(五)

2012-08-26 14:11:58 · 作者: · 浏览: 7473
nbsp;   evs[i].data.fd=-1;

                                               }
               else if(len==EAGAIN)
                                            {
                 printf("socket huan cun man le!\n");

                                            }
               else
                                            {
                  //client读取出错
                  printf("Client read failed!\n");
                                            }
       thread_para[0] = 0;//设置线程占用标志为"空闲"
       goto wait_unlock;

       printf("pthread exit!\n");
       pthread_exit(NULL);

}

static int init_thread_pool(void)
{
    int i,rc;
    for(i=0;i<THREAD_MAX;i++)
    {
     s_thread_para[i][0]=0;  //idle
     s_thread_para[i][7]=i;   //thread pool ID
     pthread_mutex_lock(s_mutex+i);   //thread lock
    }
    // create thread pool
    for(i=0;i<THREAD_MAX;i++)
    {  rc=pthread_create(s_tid+i,0,(void *(*)(void*))&http_server,(void *)(s_thread_para[i]));
       if(0!=rc)
        { fprintf(stderr,"Create thread failed!\n");
  &n