[ds6-devel] refactoring
Chris Leishman
chris at leishman.org
Mon Jan 13 23:40:52 CET 2003
On Monday, January 13, 2003, at 10:06 PM, Mauro Tortonesi wrote:
>
> i have just created a new branch for nc6: mauro_refactor_130103. i have
> made a major refactoring of network.c.
Had a look - it's fine, though I have a couple of things:
- skip_addrinfo isn't a great name for the function (although I'm stuck
thinking of another).
- ai_to_string also isn't a great name. Perhaps getnameinfo_string or
something (to reflect the fact that it's actually doing reverse lookups
via getnameinfo). ai_to_string sounds more like atoi or strerror,
where it's just a simple conversion. Also, there's no addrinfo in the
parameters, so ai isn't really appropriate.
- the connect_timeout function is slightly broken. The connect call
can return a success immediately - yet you still call
CONNECTION_ABORTED. Thats why in the previous version I fall out the
bottom of the EINPROGRESS block with err and errno reset appropriately.
This patch clears it up:
--- network.c 13 Jan 2003 20:30:51 -0000 1.32.2.1
+++ network.c 13 Jan 2003 21:36:20 -0000
@@ -170,15 +170,12 @@
/* setup errno according to the result returned by
* getsockopt */
- if (err != 0) {
+ if (err != 0)
errno = err;
- return CONNECTION_ABORTED;
- }
-
- return CONNECTION_VALID;
}
- return CONNECTION_ABORTED;
+ /* return aborted if an error occured, and valid otherwise */
+ return (err != 0) CONNECTION_ABORTED : CONNECTION_VALID;
}
Also, the connection wasn't necessarily aborted - it just failed (for
various reasons). So perhaps you should call it CONNECTION_FAILED.
And valid is more like _SUCCESS don't you think?
Regards,
Chris
More information about the ds6-devel
mailing list