亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? namecachemain.c

?? p2p類源代碼 kadc協議官方源代碼
?? C
?? 第 1 頁 / 共 4 頁
字號:
								pdnp = NULL;	/* so it won't be freed below (now the packet is referenced by the pending_q rbt...) */							} else {								/* do nothing, maybe it's an unnecessary retry for timeout that is already being taken care of */							}						} else {							replyERR(pptp->pdnsio, pdm, pdnp, RCODE_SERVER_FAILURE);						}						pthread_mutex_unlock(&pptp->mutex);	/* ///// UNLOCK ///// */					}				} else {					/* it's a response */					void *iter = NULL;					raw_qa *pending_qa = NULL;					rbt_StatusEnum rbt_status;					/* see if there is a pending query matching it */					pthread_mutex_lock(&pptp->mutex);	/* \\\\\\ LOCK \\\\\\ */#ifdef VERBOSE_DEBUG					KadC_log("pending_q_rbt contains %d entries\n", rbt_size(pptp->pending_q_rbt));#endif					rbt_status = rbt_find(pptp->pending_q_rbt, pdnp, &iter);					if(rbt_status != RBT_STATUS_OK) {						/* if not, discard the response (pdnp will be destroyed below) */					} else {						/* if yes retrieve the pending query... */						pending_qa = rbt_value(iter);						/* ...and remove it from the pending rbt */						rbt_status = rbt_erase(pptp->pending_q_rbt, iter);						assert(rbt_status == RBT_STATUS_OK);						/* copy retrieved ID, IP, port and fd into pdnp */						pdnp->buf[0] = pending_qa->q->buf[0];						pdnp->buf[1] = pending_qa->q->buf[1];						pdnp->remoteip = pending_qa->q->remoteip;						pdnp->remoteport = pending_qa->q->remoteport;						pdnp->fd = pending_qa->q->fd;						/* forward pdnp as response to the original requestor */						if(pdnp->remoteip != 0)	/* if question DNSpacket was not a pseudo, used for predictive caching */							DNSreply(pptp->pdnsio, pdnp);						/* add the reply to the retrieved qa (whose a was NULL) */						pending_qa->a = pdnp;						pdnp = NULL;	/* prevent its deallocation, as it's referenced by pending_qa */						/* if positive result and there is at least one answer, try to place the result in the cache */						if(pdm->rcode == RCODE_NO_ERROR && pdm->answer_rr != NULL && pdm->answer_rr[0] != NULL) {							time_t now = time(NULL);							time_t answttl = pdm->answer_rr[0]->ttl;	/* use TTL of first answer (if present) */							time_t texp = now + answttl;#ifdef DEBUG							KadC_log("Caching answ for qt=%d on %s; TTL %d s, exp %s", pdm->questions[0]->type, pdm->questions[0]->name, answttl, ctime(&texp));#endif							/* see if we are replacing an existing entry */							rbt_status = rbt_find(pptp->cache_q_rbt, pending_qa->q, &iter);							pending_qa->expiry = texp;							pending_qa->last_accessed = now;							if(rbt_status == RBT_STATUS_OK) {								raw_qa *pqa = rbt_value(iter);								rbt_status = rbt_erase(pptp->cache_q_rbt, iter);								assert(rbt_status == RBT_STATUS_OK);								raw_qa_destroy(pqa);#ifdef DEBUG								KadC_log("...after replacing existing record for predictive caching refresh\n");#endif								/* the replacement will appear as NOT recently accessed. This								   prevents replacement loops */								pending_qa->last_accessed = 0;							}							rbt_status = rbt_insert(pptp->cache_q_rbt, pending_qa->q, pending_qa, 0);							if(rbt_status == RBT_STATUS_OK) {								pending_qa = NULL;	/* preventing its deallocation */								/* keep size below limit by expunging oldest entries */								trim_qa_rbt(pptp->cache_q_rbt, pptp->cache_maxentries);							} else if(rbt_status != RBT_STATUS_DUPLICATE_KEY) {								assert(0);	/* trouble if it's something else... */							}						}						/* if not placed in cache, destroy the retrieved qa */						raw_qa_destroy(pending_qa);					}					pthread_mutex_unlock(&pptp->mutex);	/* ///// UNLOCK ///// */				}				dns_msg_destroy(pdm);			}			DNSpacket_destroy(pdnp);		} /* end processing of DNS packet retrieved from FIFO */		/* scan pending_q_rbt and cache_q_rbt to expire old records */		pthread_mutex_lock(&pptp->mutex);	/* \\\\\\ LOCK \\\\\\ */		purge_expired(pptp->cache_q_rbt);		pthread_mutex_unlock(&pptp->mutex);	/* ///// UNLOCK ///// */		pthread_mutex_lock(&pptp->mutex);	/* \\\\\\ LOCK \\\\\\ */		purge_expired(pptp->pending_q_rbt);		pthread_mutex_unlock(&pptp->mutex);	/* ///// UNLOCK ///// */		/* KadC_log("."); */	}	return NULL;}int millisleep_exit(DNSIO *pdnsio, int millis) {	int sf;	pthread_mutex_lock(&pdnsio->mutex);		/* \\\\\\ LOCK \\\\\\ */	sf = pdnsio->shutdown_flag;	pthread_mutex_unlock(&pdnsio->mutex);	/* ///// UNLOCK ///// */	if(sf)		return 1;	millisleep(500);	return 0;}static void *publishing_thread(void *p){	processing_thread_params *pptp = p;	int i;	for(;;) {		unsigned long int extip;		extip = KadC_getextIP(pptp->pkcc);		if(extip == 0 || pptp->nmy_pseudo <= 0) {#ifdef VERBOSE_DEBUG			KadC_log("Waiting... our external IP address is %s, nmy_pseudo = %d.\n",  htoa(extip), pptp->nmy_pseudo);#endif			if(millisleep_exit(pptp->pdnsio, 500))				goto exit;		} else {		/* only if we are connected */#ifdef DEBUG			KadC_log("Connected! Our external IP address is %s .\n", htoa(extip));			KadC_log("Going to publish records for the %d \"-d\" params\n", pptp->nmy_pseudo);#endif			/* and even then, wait for 1 min to ensure the kbuckets are reasonably full * /			for(i=0; i < 60*2; i++) {				if(millisleep_exit(pptp->pdnsio, 500))					goto exit;			} */			for(i=0; i < pptp->nmy_pseudo; i++) {				char index[1024];				char value[64];				char metalist[1024];				char *mpd = strdup(pptp->my_pseudo[i]);				char *arg;				int i, n_published;				assert(mpd != NULL);				if((arg=strchr(mpd, '=')) != NULL) {					*arg++ = 0;					sprintf(metalist,"KadCapp=namecache;rrtype=A;ip=%s", arg);				} else {					sprintf(metalist,"KadCapp=namecache;rrtype=A;ip=%s", htoa(extip));				}				sprintf(index, "KadC::namecache::%s", mpd);				free(mpd);				sprintf(value, "#1234");	/* any idea for a meaningful use? */				/* p KadC::namecache::www.xxx.yyy #12 KadCapp=namecache;rrtype=A;ip=1.2.3.4 */				for(i=0, n_published=0; i<5 && n_published < 15; i++) {					int n;					/* repeat up to 5 times, or until a total of at least 15 nodes have					   received the publishing. (Yes, the same nodes could receive					   it multiple times: nothing's perfect...) Usually one round suffices. */					n = KadC_republish(pptp->pkcc, index, value, metalist, 20, 30); /* 20 threads, max 30 s */#ifdef DEBUG					KadC_log("Record published to %d peernodes\n", n);#endif					n_published += n;				}#ifdef DEBUG				KadC_log("Totally, record published to %d peernodes\n", n_published );#endif			}			{				int sleeptime = 2*3600-60;	/* times 2 because each step of slep is 500 ms */				time_t wakeuptime = time(NULL)+sleeptime;#ifdef DEBUG			KadC_log("Done. Going to sleep for %d seconds, till %s", sleeptime, ctime(&wakeuptime));#endif				/* sleep for 2 hours before republishing */				for(i=0; i < sleeptime * 2; i++) {					if(millisleep_exit(pptp->pdnsio, 500))						goto exit;				}			}		}	}exit:#ifdef DEBUG	KadC_log("Thread publishing_thread() terminated.\n");#endif	return NULL;}/* opens socket setting pdnsio->fd; returns pdnsio->fd or error status */static int udp_dns_init(DNSIO *pdnsio) {	int fd, on = 1;	struct sockaddr_in local;	int status;	memset(&(local), 0, sizeof(struct sockaddr_in));	local.sin_family = AF_INET;	local.sin_addr.s_addr = htonl(pdnsio->ip);	local.sin_port = htons(pdnsio->port);	status = socket(AF_INET, SOCK_DGRAM, 0);	if(status < 0)		goto err;	fd = status;	status = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on));	if(status < 0)		goto err;	status = bind(fd, (struct sockaddr *)&local, (socklen_t)sizeof(struct sockaddr_in));	if(status < 0)		goto err;	pdnsio->err = 0;	pdnsio->fd = fd;	return fd;err:#ifdef __WIN32__	pdnsio->err = WSAGetLastError();#else	pdnsio->err = errno;#endif	return status;}void *dns_udp_recv_thread(void *p) {	DNSIO *pdnsio = p;	unsigned char buf[1024];	int bufsize = sizeof(buf);	for(;;) {		DNSpacket *dp;		int nrecv;		struct sockaddr_in remote;		socklen_t sa_len = sizeof(struct sockaddr_in);		/* NOTE: if a datagram longer than t->size arrives,		   the buffer is only filled in with the first t->size		   characters; however:		   - With Cygwin, the whole datagram size is returned		     in nrecv, WITHOUT TRUNCATION		   - With -mno-cygwin, nrecv returns -1		 */		/* the following select() works around a problem with OpenBSD		   and possibly other BSD systems as well: close(fd) in one		   thread hangs if another thread is waiting for input. So,		   we make this thread wait in select(), BEFORE the recvfrom(). */		int status;		fd_set rset;		struct timeval timeout;		int sf;		pthread_mutex_lock(&pdnsio->mutex);	/* \\\\\\ LOCK \\\\\\ */		sf = pdnsio->shutdown_flag;		pthread_mutex_unlock(&pdnsio->mutex);	/* ///// UNLOCK ///// */		if(sf)			break;		for(;;) {			pthread_mutex_lock(&pdnsio->mutex);	/* \\\\\\ LOCK \\\\\\ */			sf = pdnsio->shutdown_flag;			pthread_mutex_unlock(&pdnsio->mutex);	/* ///// UNLOCK ///// */			if(sf)				goto exit;			FD_ZERO(&rset);			FD_SET(pdnsio->fd, &rset);			timeout.tv_sec = 0;			timeout.tv_usec = 500000;	/* 500 ms timeout */			status = select(pdnsio->fd+1, &rset, NULL, NULL, &timeout);			if(status > 0){				break;	/* data available, go read it */			}		};	/* wait outside recvfrom */		pthread_mutex_lock(&pdnsio->mutex);	/* \\\\\\ LOCK UDPIO \\\\\\ */		nrecv = recvfrom(						pdnsio->fd,						(char *)buf,						bufsize,						0,						(struct sockaddr *)&remote,						&sa_len);		pthread_mutex_unlock(&pdnsio->mutex);	/* ///// UNLOCK UDPIO ///// */		if(nrecv > bufsize)			nrecv = -1;	/* in UNIX as in WIN32 ignore oversize datagrams */		if(nrecv <= 0) {/* ...catch oversize datagrams */			continue; /* in case of other errors, just skip this datagram */		}		/* allocate a DNSpacket */		dp = malloc(sizeof(DNSpacket));		assert(dp != NULL);		dp->remoteip = ntohl(remote.sin_addr.s_addr);		dp->remoteport = ntohs(remote.sin_port);		dp->fd = -1;	/* means "packet arrived over UDP" */		/* allocate a copy of buffer referenced by DNSpacket */		dp->buf = malloc(nrecv);		assert(dp->buf != NULL);		memcpy(dp->buf, buf, nrecv);		dp->bufsize = nrecv;#ifdef VERBOSE_DEBUG /* DEBUG ONLY */		{			int i;			KadC_log("dns_udp_recv_thread - received from %s:%d %d bytes:",					htoa(dp->remoteip), dp->remoteport, dp->bufsize);			for(i=0; i < dp->bufsize /* && i < 48 */; i++) {				if((i % 16) == 0)					KadC_log("\n");				KadC_log("%02x ", dp->buf[i]);			}		}		KadC_log("\n================================\n");#endif		/* enqueue the DNSpacket */		if(pdnsio->fifo->enq(pdnsio->fifo, dp) != 0) {			/* if FIFO full, drop the packet? */			free(dp->buf);			free(dp);		}	}exit:#ifdef __WIN32__	pdnsio->err = closesocket(pdnsio->fd);#else	pdnsio->err = close(pdnsio->fd);#endif	return NULL;}/* blocking UDP send() */int udp_send(DNSIO *pd, unsigned char *buf, int buflen, unsigned long int destip, int destport) {	int status;	struct sockaddr_in destsockaddr;	int fd = pd->fd;	memset(&destsockaddr, 0, sizeof(struct sockaddr_in));	destsockaddr.sin_family = AF_INET;	destsockaddr.sin_port   = htons((unsigned short int)destport);	destsockaddr.sin_addr.s_addr = htonl(destip);	/* this lock protects the fd from concurrent access	   by separate threads either via sendto() recvfrom() */	pthread_mutex_lock(&pd->mutex);	/* \\\\\\ LOCK UDPIO \\\\\\ */	status = sendto(fd, (char *)buf, buflen,		0, (struct sockaddr *)&destsockaddr,		(socklen_t)sizeof(destsockaddr));	pthread_mutex_unlock(&pd->mutex);	/* ///// UNLOCK UDPIO ///// */	return status;}/* end blocking send() *//* blocking TCP send() FIXME: not used at the moment, need to write listener */int tcp_send(DNSIO *pd, unsigned char *buf, int buflen, int fd) {	int status;#ifdef MSG_NOSIGNAL	status = send(fd, (char *)buf, buflen, MSG_NOSIGNAL);#else	status = send(fd, (char *)buf, buflen, 0);#endif#ifdef __WIN32__	closesocket(fd);#else	close(fd);#endif	return status;}/* forward the packed DNS query in pdnp to the upstream server at the address ip */static int DNSquery(DNSIO *pd, DNSpacket *pdnp, unsigned long int ip) {	int status;	/* for the time being, only UDP */	status = udp_send(pd, pdnp->buf, pdnp->bufsize, ip, DNS_PORT);	return status;}/* send back the reply packed in the DNSpacket pointed by pdnpreply */static int DNSreply(DNSIO *pd, DNSpacket *pdnpreply) {	int status;	if(pdnpreply->fd < 0) {		/* use UDP */		if(pdnpreply->bufsize > 512) {			pdnpreply->bufsize = 512;	/* truncate to 512 */			pdnpreply->buf[2] |= 0x02;	/* set the TC (truncation) flag */		}		status = udp_send(pd, pdnpreply->buf, pdnpreply->bufsize, pdnpreply->remoteip, pdnpreply->remoteport);	} else {		/* use TCP on the same fd (FIXME: TBI) */		status = tcp_send(pd, pdnpreply->buf, pdnpreply->bufsize, pdnpreply->fd);	}	return status;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲免费视频成人| 色综合天天综合色综合av | 亚洲高清久久久| 美女视频网站久久| 在线影院国内精品| 欧美激情一区二区三区四区| 日韩激情在线观看| 色综合天天狠狠| 中文字幕亚洲不卡| 国产美女av一区二区三区| 欧美精选在线播放| 亚洲午夜久久久久久久久久久| 国产成人av一区二区三区在线| 欧美videossexotv100| 香蕉久久一区二区不卡无毒影院| 99久久免费精品高清特色大片| 久久久九九九九| 久久99精品久久久久久久久久久久 | 色999日韩国产欧美一区二区| 国产午夜精品美女毛片视频| 美腿丝袜亚洲一区| 欧美疯狂做受xxxx富婆| 亚洲成人激情社区| 欧美性生活久久| 亚洲成av人片| 欧美肥妇毛茸茸| 美女免费视频一区| 日韩欧美国产综合| 久久99久久99| 久久男人中文字幕资源站| 韩国女主播一区| 国产午夜亚洲精品羞羞网站| 国产99一区视频免费| 国产性做久久久久久| 粉嫩绯色av一区二区在线观看 | 在线播放日韩导航| 热久久免费视频| 欧美变态凌虐bdsm| 国产一区91精品张津瑜| 欧美高清一级片在线观看| 福利视频网站一区二区三区| 国产精品人妖ts系列视频| 波多野结衣在线一区| 亚洲三级久久久| 欧美在线视频不卡| 蜜臀久久久久久久| 国产欧美一区二区精品仙草咪| 成人夜色视频网站在线观看| 国产精品久久久久久久久免费相片| www.亚洲在线| 亚洲国产精品久久久久婷婷884| 777午夜精品视频在线播放| 久久99久久99| 亚洲欧美福利一区二区| 欧美日韩一区二区在线观看视频| 日本vs亚洲vs韩国一区三区 | 91美女在线看| 日本特黄久久久高潮| 久久色视频免费观看| 91丨porny丨户外露出| 婷婷六月综合网| 国产亚洲欧美激情| 91老师国产黑色丝袜在线| 日韩中文字幕不卡| 中文幕一区二区三区久久蜜桃| 色综合久久中文综合久久97| 麻豆国产精品官网| 国产精品无遮挡| 7777精品伊人久久久大香线蕉 | 亚洲成人免费影院| 久久久久久久久久久黄色| 色婷婷av一区二区三区软件 | 91蜜桃免费观看视频| 蜜臀av一级做a爰片久久| 国产精品久久夜| 欧美一区二区高清| 97久久人人超碰| 国产一区二区在线免费观看| 亚洲午夜在线电影| 国产欧美日韩在线看| 欧美一区日韩一区| 日本韩国一区二区三区视频| 国产一区二区视频在线| 天堂成人国产精品一区| 亚洲柠檬福利资源导航| 国产三级久久久| 欧美一区二区三区白人| 91在线视频播放地址| 国产成人精品网址| 久88久久88久久久| 日韩精品久久理论片| 亚洲免费观看高清完整版在线| 久久精品人人做| 日韩一区二区在线观看视频| 在线观看一区二区精品视频| 成人av网址在线| 国产伦精品一区二区三区免费迷 | 成人av在线资源网| 国产精品白丝av| 激情综合色丁香一区二区| 丝袜美腿亚洲综合| 亚洲一级电影视频| 一区二区在线观看不卡| 国产精品久久99| 久久久精品免费网站| 欧美mv日韩mv国产网站app| 欧美一区二区三区四区在线观看| 色成人在线视频| 在线观看中文字幕不卡| 91国产福利在线| 欧洲精品中文字幕| 欧美日韩亚洲综合在线| 欧美日韩久久久| 欧美日韩电影在线播放| 欧美日本韩国一区二区三区视频 | 婷婷开心激情综合| 日韩国产欧美在线播放| 日韩激情av在线| 日本v片在线高清不卡在线观看| 免费在线观看一区| 黄色资源网久久资源365| 国产福利不卡视频| 波多野结衣的一区二区三区| 国产suv一区二区三区88区| av亚洲精华国产精华精华| 一本一道波多野结衣一区二区| 色噜噜夜夜夜综合网| 在线91免费看| 337p粉嫩大胆噜噜噜噜噜91av| 久久天天做天天爱综合色| 国产肉丝袜一区二区| 专区另类欧美日韩| 亚洲丶国产丶欧美一区二区三区| 日日夜夜免费精品视频| 国产真实乱偷精品视频免| 成人短视频下载| 欧美性猛交xxxxxxxx| 精品成人私密视频| 亚洲人成小说网站色在线| 亚洲成人精品一区二区| 精品在线播放免费| 99免费精品在线观看| 欧美日韩一级大片网址| 亚洲精品一区二区三区在线观看| 亚洲国产成人午夜在线一区| 亚洲欧美偷拍卡通变态| 老司机一区二区| a级精品国产片在线观看| 欧美嫩在线观看| 国产欧美日韩在线观看| 午夜国产精品一区| 国产成人a级片| 欧美丰满少妇xxxbbb| 国产精品久久网站| 美女视频一区二区| 色素色在线综合| 久久久激情视频| 亚洲丶国产丶欧美一区二区三区| 国产精品香蕉一区二区三区| 欧美午夜片在线观看| 中文字幕的久久| 蜜桃视频在线观看一区| 色婷婷狠狠综合| 中文字幕免费一区| 美女视频网站黄色亚洲| 一本久久a久久精品亚洲| www国产精品av| 午夜精品久久久久久久久久久 | 精品美女一区二区三区| 精品成a人在线观看| 亚洲一区二三区| 不卡影院免费观看| 久久久精品一品道一区| 日韩精品91亚洲二区在线观看| 色综合天天做天天爱| 欧美国产精品v| 国产在线精品一区二区三区不卡| 欧美美女黄视频| 一区二区三区在线视频观看| 国产黑丝在线一区二区三区| 日韩欧美综合一区| 亚洲www啪成人一区二区麻豆| 色婷婷av一区二区| 亚洲视频在线观看三级| www..com久久爱| 国产精品网站在线播放| 韩国欧美国产1区| 欧美精品一区男女天堂| 日本sm残虐另类| 538prom精品视频线放| 亚洲成人在线网站| 欧美日本一区二区三区| 婷婷久久综合九色综合绿巨人| 在线视频国内一区二区| 亚洲精品视频免费观看| 91浏览器在线视频| 一区二区三区欧美| 欧美日韩一本到| 三级不卡在线观看| 日韩女优制服丝袜电影|