
mark at mark
Aug 26, 2003, 6:53 PM
Post #1 of 2
(720 views)
Permalink
|
|
Fwd: Clamd Socket Already Exist Error (patch attached)
|
|
On Tue, Aug 26, 2003 at 05:53:57PM +0200, Tomasz Kojm wrote: > > As I don't usually do networking in C, and there were one/some style > > complaints: Tomasz, are you accepting the patch as-is? > Of course, I do. However I'd like to see Mark's version and after that > we can update the CVS with the better one ;) So... I rolled up my sleaves and got dirty. There was a misunderstanding on my part in this discussion: I was under the impression that bind() for a UNIX socket either worked by default, or could be configured, similar to how bind() for an IP socket works with SO_REUSEADDR configured. I was startled to find that it does not. I even scanned through net/unix/af_unix.c in the Linux kernel, and sure enough, bind() is not implemented the way I expected. On an indirectly related topic, I believe this to be a bug in the UNIX specification, but one that isn't likely to be fixed. :-( The other issue that I claimed, that of a race condition in the already proposed patch, does exist as far as I can tell. The patch appeared to invert the bind()->stat() to be stat()->bind, which is awkward, in that however infeasible, the stat() could show that the file does not exist, the file could be created, and the bind() would then fail. The patch that I enclose prefers the bind()->unlink()->bind() approach. It does further error handling, and touches up the logged error messages to be consistent and according to form. I don't mean to take too much from the already proposed patch. After realizing my first error, I used the first patch as a template to create this one. Thanks to Thomas Lamy for getting the work-around down on paper, and saving me from having to figure out how to add a configuration option. I only adjusted the resulting lines to be more technically perfect. Cheers, mark -- mark [at] mielke/markm [at] ncf/markm [at] nortelnetworks __________________________ . . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder |\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | | | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada One ring to rule them all, one ring to find them, one ring to bring them all and in the darkness bind them... http://mark.mielke.cc/
|