Firewall Wizards mailing list archives

Re: Code reviews [Was: FWTK and smap/smapd]


From: ark () eltex ru
Date: Tue, 23 Jul 2002 20:31:03 +0400

-----BEGIN PGP SIGNED MESSAGE-----

Carson Gaspar <carson () taltos org> said :

It depends on what the maximum buflen is, isn't it?

If we have a small buffer that we know does fit send queue we may
assume that if write count is not equal to expected size something
wrong happens with the socket and we may shut the connection down
diagnosing network error, am i wrong?

If the buffer size can really grow that much we need something like
net_write, sure.

Ah, but I cleverly failed to tell you:

- How much data you were dealing with
- Whether the fd was blocking or non-blocking

Then i should implement the most reliable algorithm.
 
In my opinion, anyone who _ever_ assumes write(fd, buf, n) will only ever 
return n or -1 is writing bogus code. Always program defensively - you may 
be a genius, but the person who mangles your code later won't be.

Hmm actually i still think that handling partial write of, say, 1024 byte buffer
as socket error does not break things. It is bad style, though, and should be
avoided.

                                     _     _  _  _  _      _  _
 {::} {::} {::}  CU in Hell          _| o |_ | | _|| |   / _||_|   |_ |_ |_
 (##) (##) (##)        /Arkan#iD    |_  o  _||_| _||_| /   _|  | o |_||_||_|
 [||] [||] [||]            Do i believe in Bible? Hell,man,i've seen one!

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.1i

iQCVAwUBPT2Ex6H/mIJW9LeBAQH0JgP9ED2QwJbrC4aY6wnCM71dJ6SB+gICRBhS
u4u8e6BeiOOdOY10IHtaPLRPNdR5ZWSGvz3/F3XoZggWBNn3wGDfAsIZiodfz32t
HqUeVHMD1WUJrUJHxQd7PZrqslsghVwsu8IPBbDQEDH2zutXitF+y02fOU4dHENR
cnXk0UW2WiI=
=SJdp
-----END PGP SIGNATURE-----
_______________________________________________
firewall-wizards mailing list
firewall-wizards () honor icsalabs com
http://honor.icsalabs.com/mailman/listinfo/firewall-wizards


Current thread: