Bug#4053: too many of "error 1236: 'binlog truncated in the middle of \

	event' from master"

Since there is no repeatable test case, and this is obviously wrong, this is
the most conservative change that might possibly work.  

The syscall  read()  wasn't checked for a negative return value for an
interrupted read.  The kernel  sys_read()  returns -EINTR, and the "library" 
layer maps that to return value of -1 and sets  errno  to EINTR.  It's 
impossible (on Linux) for  read()  to set errno EINTR without the return 
value being -1 .

So, if we're checking for EINTR behavior, we should not require that the
return value be zero.
parent 46ee3ac1
...@@ -36,23 +36,26 @@ ...@@ -36,23 +36,26 @@
uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags) uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags)
{ {
uint readbytes,save_count; uint readbytes, save_count;
DBUG_ENTER("my_read"); DBUG_ENTER("my_read");
DBUG_PRINT("my",("Fd: %d Buffer: %lx Count: %u MyFlags: %d", DBUG_PRINT("my",("Fd: %d Buffer: %lx Count: %u MyFlags: %d",
Filedes, Buffer, Count, MyFlags)); Filedes, Buffer, Count, MyFlags));
save_count=Count; save_count= Count;
for (;;) for (;;)
{ {
errno=0; /* Linux doesn't reset this */ errno= 0; /* Linux doesn't reset this */
if ((readbytes = (uint) read(Filedes, Buffer, Count)) != Count) if ((readbytes= (uint) read(Filedes, Buffer, Count)) != Count)
{ {
my_errno=errno ? errno : -1; my_errno= errno ? errno : -1;
DBUG_PRINT("warning",("Read only %ld bytes off %ld from %d, errno: %d", DBUG_PRINT("warning",("Read only %ld bytes off %ld from %d, errno: %d",
readbytes,Count,Filedes,my_errno)); readbytes, Count, Filedes, my_errno));
#ifdef THREAD #ifdef THREAD
if (readbytes == 0 && errno == EINTR) if ((int) readbytes <= 0 && errno == EINTR)
{
DBUG_PRINT("debug", ("my_read() was interrupted and returned %d", (int) readbytes));
continue; /* Interrupted */ continue; /* Interrupted */
}
#endif #endif
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
{ {
...@@ -68,16 +71,16 @@ uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags) ...@@ -68,16 +71,16 @@ uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags)
DBUG_RETURN(MY_FILE_ERROR); /* Return with error */ DBUG_RETURN(MY_FILE_ERROR); /* Return with error */
if (readbytes > 0 && (MyFlags & MY_FULL_IO)) if (readbytes > 0 && (MyFlags & MY_FULL_IO))
{ {
Buffer+=readbytes; Buffer+= readbytes;
Count-=readbytes; Count-= readbytes;
continue; continue;
} }
} }
if (MyFlags & (MY_NABP | MY_FNABP)) if (MyFlags & (MY_NABP | MY_FNABP))
readbytes=0; /* Ok on read */ readbytes= 0; /* Ok on read */
else if (MyFlags & MY_FULL_IO) else if (MyFlags & MY_FULL_IO)
readbytes=save_count; readbytes= save_count;
break; break;
} }
DBUG_RETURN(readbytes); DBUG_RETURN(readbytes);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment