mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
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
1 changed files with 5 additions and 5 deletions
|
@ -91,14 +91,14 @@ namespace Sortix
|
|||
{
|
||||
if ( bufferused < count ) { count = bufferused; }
|
||||
size_t amount = count;
|
||||
size_t linear = buffersize - bufferused;
|
||||
size_t linear = buffersize - bufferoffset;
|
||||
if ( linear < amount ) { amount = linear; }
|
||||
ASSERT(amount);
|
||||
Memory::Copy(dest, buffer + bufferoffset, amount);
|
||||
bufferoffset = (bufferoffset + amount) % buffersize;
|
||||
bufferused -= amount;
|
||||
writeevent.Signal();
|
||||
if ( bufferused == 0 || amount == count ) { return amount; }
|
||||
return amount + Read(dest + amount, count - amount);
|
||||
return amount;
|
||||
}
|
||||
|
||||
if ( !anywriting ) { return 0; }
|
||||
|
@ -119,11 +119,11 @@ namespace Sortix
|
|||
size_t amount = count;
|
||||
size_t linear = buffersize - writeoffset;
|
||||
if ( linear < amount ) { amount = linear; }
|
||||
ASSERT(amount);
|
||||
Memory::Copy(buffer + writeoffset, src, amount);
|
||||
bufferused += amount;
|
||||
readevent.Signal();
|
||||
if ( buffersize == bufferused || amount == count ) { return amount; }
|
||||
return amount + Write(src + amount, count - amount);
|
||||
return amount;
|
||||
}
|
||||
|
||||
Error::Set(EBLOCKING);
|
||||
|
|
Loading…
Add table
Reference in a new issue