Fixed kernel stack overflow and premature EOF in the unix pipe code.
This usually caused the system to lock up when much data was transferred over pipes, for instance: $ cd /bin ; cat cat | cat
This commit is contained in:
parent
c7c0fc603a
commit
d564603460
|
@ -91,14 +91,14 @@ namespace Sortix
|
||||||
{
|
{
|
||||||
if ( bufferused < count ) { count = bufferused; }
|
if ( bufferused < count ) { count = bufferused; }
|
||||||
size_t amount = count;
|
size_t amount = count;
|
||||||
size_t linear = buffersize - bufferused;
|
size_t linear = buffersize - bufferoffset;
|
||||||
if ( linear < amount ) { amount = linear; }
|
if ( linear < amount ) { amount = linear; }
|
||||||
|
ASSERT(amount);
|
||||||
Memory::Copy(dest, buffer + bufferoffset, amount);
|
Memory::Copy(dest, buffer + bufferoffset, amount);
|
||||||
bufferoffset = (bufferoffset + amount) % buffersize;
|
bufferoffset = (bufferoffset + amount) % buffersize;
|
||||||
bufferused -= amount;
|
bufferused -= amount;
|
||||||
writeevent.Signal();
|
writeevent.Signal();
|
||||||
if ( bufferused == 0 || amount == count ) { return amount; }
|
return amount;
|
||||||
return amount + Read(dest + amount, count - amount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !anywriting ) { return 0; }
|
if ( !anywriting ) { return 0; }
|
||||||
|
@ -119,11 +119,11 @@ namespace Sortix
|
||||||
size_t amount = count;
|
size_t amount = count;
|
||||||
size_t linear = buffersize - writeoffset;
|
size_t linear = buffersize - writeoffset;
|
||||||
if ( linear < amount ) { amount = linear; }
|
if ( linear < amount ) { amount = linear; }
|
||||||
|
ASSERT(amount);
|
||||||
Memory::Copy(buffer + writeoffset, src, amount);
|
Memory::Copy(buffer + writeoffset, src, amount);
|
||||||
bufferused += amount;
|
bufferused += amount;
|
||||||
readevent.Signal();
|
readevent.Signal();
|
||||||
if ( buffersize == bufferused || amount == count ) { return amount; }
|
return amount;
|
||||||
return amount + Write(src + amount, count - amount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Error::Set(EBLOCKING);
|
Error::Set(EBLOCKING);
|
||||||
|
|
Loading…
Reference in New Issue