Re: more thoughts on a new jail() system call

Thunder from the hill (thunder@ngforever.de)
Thu, 18 Jul 2002 22:55:58 -0600 (MDT)


This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.

---1463811839-1262670546-1027054558=:3378
Content-Type: TEXT/PLAIN; charset=US-ASCII

Hi,

On 19 Jul 2002, James Antill wrote:
> The more general spelling is FIONREAD, and I generally find that only
> crap network applications need to use it. Good ones just try and read
> a largish amount of data into a buffer.

That doesn't matter as long as you haven't got any idea on how much data
will be read. Especially relaying between two completely different hosts,
possibly unknown protocols, you don't have a chance to know who will send
next. Without TIOCINQ you'll almost be shot if you have received lots of
lots of stuff from the client and expect any response from the server. You
just won't get it.

Give me another version of the appended piece of code that won't use
ioctl, and I'll consider an acknowledgement.

Regards,
Thunder

-- 
(Use http://www.ebb.org/ungeek if you can't decode)
------BEGIN GEEK CODE BLOCK------
Version: 3.12
GCS/E/G/S/AT d- s++:-- a? C++$ ULAVHI++++$ P++$ L++++(+++++)$ E W-$
N--- o?  K? w-- O- M V$ PS+ PE- Y- PGP+ t+ 5+ X+ R- !tv b++ DI? !D G
e++++ h* r--- y- 
------END GEEK CODE BLOCK------

---1463811839-1262670546-1027054558=:3378 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="portforwarder.c" Content-Transfer-Encoding: BASE64 Content-ID: <Pine.LNX.4.44.0207182255580.3378@hawkeye.luckynet.adm> Content-Description: Content-Disposition: attachment; filename="portforwarder.c"

I2luY2x1ZGUgPGVycm5vLmg+DQojaW5jbHVkZSA8c3RkaW8uaD4NCiNpbmNs dWRlIDxzdGRsaWIuaD4NCiNpbmNsdWRlIDxzdHJpbmcuaD4NCiNpbmNsdWRl IDx1bmlzdGQuaD4NCiNpbmNsdWRlIDxhcnBhL2luZXQuaD4NCiNpbmNsdWRl IDxzeXMvaW9jdGwuaD4NCiNpbmNsdWRlIDxuZXRpbmV0L2luLmg+DQojaW5j bHVkZSA8c3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1iYXNp Yy1vZmZzZXQ6IDgNCiAqIEVuZDoNCiAqLw0K ---1463811839-1262670546-1027054558=:3378-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/