Weird behavior in receive_data function

Daniel.Li daniel_li at usish.com
Wed Jun 10 23:23:34 GMT 2009


On Thu, 2009-06-11 at 07:11 +0800, Daniel.Li wrote:
> Dear List,
> 
> I'm trying to get diff/removed data and it's offset out. So I write a
> functions in receive_data. When I run backup, I found there is a weird
> behavior which I don't understand.
> 
> i = recv_token(f_in, &data) will receive (i = -1, offset2 = 0) some
> where in the middle of the transfer procedure. That's to say, it's going
> to transfer the first data block from sender, 

Sorry, It's to say copy the first block from receiver, NOT first data
block from sender. 

> but I have been
> transferring almost half of the file. I noticed it was 92nd block
> (sum.blength = 700) .
> 
> Hope I have a clear explanation. I'm really confused now. Any advice and
> suggestion is well appreciated.
> 
> 
> Below is my code segment to generate file for test.
> 
> My Procedure (file 1 and file 2 have the same name, just binary
> difference): 
> Step 1: backup File 1
> Step 2: backup Fil 2
> 
> 
> 
> -- 
> Daniel Li
> 
> 
> File 1: 
>  This is the first time backup file.
> > 		count = 1;
> > 		nSize = 1;
> > 		nBlock = 256;
> > 		nInterval = 4;
> > 		nAdjust = 256;
> > 
> > 		printf("\nstart to build origin files!\n");
> > 		ch = 0;
> > 		for(l = 0; l < count; l++)
> > 		{
> > 			memset(buffer,0, 256);
> > 			sprintf(buffer,"media-test-3MB-file/origin/test/test%02d.dat",l);
> > 			printf("writting %s \n",buffer);
> > 			fd = open(buffer, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR);
> > 			for(lll = 0; lll < nSize; lll++)
> > 			{
> > 				for(mmm = 0; mmm < nAdjust; mmm++)
> > 				{
> > 					for(nnn = 0; nnn < nBlock; nnn++)
> > 					{
> > 						write_fhead_char(fd, &ch, 1);
> > 					}
> > 					ch++;
> > 				}
> > 			}
> > 		}
> > 		printf("origin files done!\n");
> > 
> 
> 
> 
> File 2:
>  This is the second time backup. when transferring this file, I met the trouble. 
> > 		printf("\nstart to build added data files!\n");
> > 		ch = 0;
> > 		for(l = 0; l < count; l++)
> > 		{
> > 			memset(buffer,0, 256);
> > 			sprintf(buffer,"media-test-3MB-file/add/test/test%02d.dat",l);
> > 			printf("writting %s \n",buffer);
> > 			fd = open(buffer, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR);
> > 			for(lll = 0; lll < nSize + 1; lll++)
> > 			{
> > 				for(mmm = 0; mmm < nAdjust; mmm++)
> > 				{
> > 					if(mmm % nInterval == 0)
> > 					{
> > 						for(nnn = 0; nnn < nBlock; nnn++)
> > 						{
> > 							write_fhead_char(fd, &ch, 1);
> > 						}
> > 					}
> > 
> > 					for(nnn = 0; nnn < nBlock; nnn++)
> > 					{
> > 						write_fhead_char(fd, &ch, 1);
> > 					}
> > 					ch++;
> > 				}
> > 			}
> > 			close(fd);
> > 		}
> 
-- 
Daniel Li



More information about the rsync mailing list