cond_resched(); 
svc_recv(struct svc_serv *serv, struct svc_rqst *rqstp, long timeout){	struct svc_sock		*svsk =NULL;	int			len;	int 			pages;	struct xdr_buf		*arg;	DECLARE_WAITQUEUE(wait, current);	dprintk("svc: server %p waiting for data (to = %ld)\n",		rqstp, timeout);	if (rqstp->rq_sock)		printk(KERN_ERR 			"svc_recv: service %p, socket not NULL!\n",			 rqstp);	if (waitqueue_active(&rqstp->rq_wait))		printk(KERN_ERR 			"svc_recv: service %p, wait queue active!\n",			 rqstp);	/* Initialize the buffers */	/* first reclaim pages that were moved to response list */	svc_pushback_allpages(rqstp);	/* now allocate needed pages.  If we get a failure, sleep briefly */	pages = 2 + (serv->sv_bufsz + PAGE_SIZE -1) / PAGE_SIZE;	while (rqstp->rq_arghi < pages) {		struct page *p = alloc_page(GFP_KERNEL);		if (!p) {			schedule_timeout_uninterruptible(msecs_to_jiffies(500));			continue;		}		rqstp->rq_argpages[rqstp->rq_arghi++] = p;	}	/* Make arg->head point to first page and arg->pages point to rest */	arg = &rqstp->rq_arg;	arg->head[0].iov_base = page_address(rqstp->rq_argpages[0]);	arg->head[0].iov_len = PAGE_SIZE;	rqstp->rq_argused = 1;	arg->pages = rqstp->rq_argpages + 1;	arg->page_base = 0;	/* save at least one page for response */	arg->page_len = (pages-2)*PAGE_SIZE;	arg->len = (pages-1)*PAGE_SIZE;	arg->tail[0].iov_len = 0;	try_to_freeze();	if (signalled())		return -EINTR;	spin_lock_bh(&serv->sv_lock);	if (!list_empty(&serv->sv_tempsocks)) {		svsk = list_entry(serv->sv_tempsocks.next,				  struct svc_sock, sk_list);		/* apparently the "standard" is that clients close		 * idle connections after 5 minutes, servers after		 * 6 minutes		 *   http://www.connectathon.org/talks96/nfstcp.pdf 		 */		if (get_seconds() - svsk->sk_lastrecv < 6*60		    || test_bit(SK_BUSY, &svsk->sk_flags))			svsk = NULL;	}	if (svsk) {		set_bit(SK_BUSY, &svsk->sk_flags);		set_bit(SK_CLOSE, &svsk->sk_flags);		rqstp->rq_sock = svsk;		svsk->sk_inuse++;	} else if ((svsk = svc_sock_dequeue(serv)) != NULL) {		rqstp->rq_sock = svsk;		svsk->sk_inuse++;		rqstp->rq_reserved = serv->sv_bufsz;			svsk->sk_reserved += rqstp->rq_reserved;	} else {		/* No data pending. Go to sleep */		svc_serv_enqueue(serv, rqstp);		/*		 * We have to be able to interrupt this wait		 * to bring down the daemons ...		 */		set_current_state(TASK_INTERRUPTIBLE);		add_wait_queue(&rqstp->rq_wait, &wait);		spin_unlock_bh(&serv->sv_lock);		schedule_timeout(timeout);		try_to_freeze();		spin_lock_bh(&serv->sv_lock);		remove_wait_queue(&rqstp->rq_wait, &wait);		if (!(svsk = rqstp->rq_sock)) {			svc_serv_dequeue(serv, rqstp);			spin_unlock_bh(&serv->sv_lock);			dprintk("svc: server %p, no data yet\n", rqstp);			return signalled()? -EINTR : -EAGAIN;		}	}	spin_unlock_bh(&serv->sv_lock);	dprintk("svc: server %p, socket %p, inuse=%d\n",		 rqstp, svsk, svsk->sk_inuse);	len = svsk->sk_recvfrom(rqstp);	dprintk("svc: got len=%d\n", len);	/* No data, incomplete (TCP) read, or accept() */	if (len == 0 || len == -EAGAIN) {		rqstp->rq_res.len = 0;		svc_sock_release(rqstp);		return -EAGAIN;	}	svsk->sk_lastrecv = get_seconds();	if (test_bit(SK_TEMP, &svsk->sk_flags)) {		/* push active sockets to end of list */		spin_lock_bh(&serv->sv_lock);		if (!list_empty(&svsk->sk_list))			list_move_tail(&svsk->sk_list, &serv->sv_tempsocks);		spin_unlock_bh(&serv->sv_lock);	}	rqstp->rq_secure  = ntohs(rqstp->rq_addr.sin_port) < 1024;	rqstp->rq_chandle.defer = svc_defer;	if (serv->sv_stats)		serv->sv_stats->netcnt++;	return len;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/1887b93529410633b5529a7c2d304897dbed5b3e/svcsock.c/buggy/net/sunrpc/svcsock.c