mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: xinglp <xinglp@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: splice lost data
Date: Wed, 8 Apr 2009 03:48:44 +0800	[thread overview]
Message-ID: <b7997bdf0904071248t48fed168r7fa21b421c74358a@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 86 bytes --]

2.6.29.1 in VM

When recv data more than 8K (1024*8) bytes at once, data lost happen.

[-- Attachment #2: splice_test.c --]
[-- Type: text/plain, Size: 1267 bytes --]

#define SPLICE_SIZE	(1024*8)//when define SPLICE_SIZE bigger than (1024*8) data lost happen.
//This function is called when EPOLLIN on Socket
void RecvBySplice(int hFile,int Socket)
{
	ssize_t	SizeToRead;
	ssize_t	SizeRead;
	ssize_t	SizeLeft;
	ssize_t	SizeWrite;

	while(ContentLength>0)//ContentLength is global
	{
		SizeToRead	=SPLICE_SIZE>ContentLength?ContentLength:SPLICE_SIZE;

		SizeRead	=splice(Socket,NULL,Pipes[1],NULL,SizeToRead,SPLICE_F_NONBLOCK);//Pipes[] is global

		if(SizeRead>0)
		{
			ContentLength-=SizeRead;

			SizeLeft=SizeRead;
			
			while(SizeLeft>0)
			{
				SizeWrite=splice(Pipes[0],NULL,hFile,NULL,SizeLeft,SPLICE_F_NONBLOCK);//Pipes[] is global

				if(SizeWrite>0)
				{
					SizeLeft-=SizeWrite;
				}
				else if(EINTR==errno)
				{
					continue;
				}
				else
				{
					perror("splice");
					return;
				}
			}

			if(SizeRead<SizeToRead)
			{
				return;//No more data in socket buf
			}
		}
		else
		{
			if(0==SizeRead)
			{
				perror("peer close");
				return;
			}
			else
			{
				if(EAGAIN==errno)
				{
					return;
				}
				else if(EINTR==errno)
				{
					continue;
				}
				else
				{
					perror("splice");
					return;
				}
			}
		}
	}
}


             reply	other threads:[~2009-04-07 19:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-07 19:48 xinglp [this message]
2009-04-08  7:20 ` Vegard Nossum
2009-04-08  7:54   ` xinglp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b7997bdf0904071248t48fed168r7fa21b421c74358a@mail.gmail.com \
    --to=xinglp@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®