コード例 #1
0
ファイル: 10_副本serve.c プロジェクト: ouyangjiayou/qq
void parse(int cfd)
{
	char buf[1024];
	char buf1[64];
	int ret;
	int b;
	Node* t;
	Node* s;
	 struct package p;

	ret = read(cfd, &p.head, sizeof(p.head));
	if(ret <=0){
		printf("cfd=%d close!\n",cfd);
		removelist(cfd);
		close(cfd);
		ev.data.fd = cfd;
		epoll_ctl(eh,EPOLL_CTL_DEL,ev.data.fd,&ev);

	}
              strcpy(buf1,p.head.type);
            
              printf("buf1=%s\n",buf1);

              if(buf1[0] == 'g')
              {
              	pool_add_work(thread,(void*)cfd);
              }else if(buf1[0] == 'f'){
                            // printf("sddsddsd\n");
                          pool_add_work(regiser,(void*)cfd);   
              }else if(buf1[0] == 'h'){
              	printf("oooooooooooooook\n");
                            pool_add_work(show_list,(void*)cfd);
              }else{
              	
              	  t = search_b(buf1);
              
              	   if(t != NULL)
              	   {       
              	   	  ret = read(cfd,buf,sizeof(buf));
              	                
              	                 printf("buf=%s\n",buf);
			   if(ret <=0){
			   	close(cfd);
			   	printf("close cfd+%d\n",cfd);
			   	//return argv;
			   }
                                              s = search_cfd(cfd);
			  strcpy(p.head.type , s->name);
	                                   printf("p.head.type=%s\n",p.head.type);
			   p.head.version = 1;
			   p.head.length = strlen(buf);
                                            //cfd = t->fcd;
                                             printf("t->fcd=%d\n",t->fcd);
		                write(t->fcd,&p.head,sizeof(p.head));
		                write(t->fcd,buf,p.head.length);
		                memset(buf,0,1024);
              	   }
              }
	
}
コード例 #2
0
ファイル: main.c プロジェクト: yuyichao/explore
void
time_search_b(Item *items, size_t len, int key)
{
    struct timespec start, end;
    long long t;
    int i;
    clock_gettime(CLOCK_ID, &start);
    for (i = 0;i < N;i++) {
        search_b(items, len, key);
    }
    clock_gettime(CLOCK_ID, &end);
    t = ((end.tv_sec - start.tv_sec) * 1000000000)
        + end.tv_nsec - start.tv_nsec;
    printf("%s, search_b:\n\t %lld\n", __func__, t);
}