[Date Prev] [Date Index] [Date Next] [Thread Prev] [Thread Index] [Thread Next]

uds console FD leak

Michael Heironimus michael_heironimus@archwayconcepts.com
Sun, 8 Apr 2007 12:53:21 -0700 (PDT)


I've been setting up conserver to provide console access and logging for
VMware machines running Linux, using the uds console type and a virtual
serial port. When the VM isn't running conserver uses another file
descriptor every time it tries to open the socket. If it's configured to
automatically reopen consoles that go down it eventually runs out of
file descriptors.

I added a few lines to consent.c to close the socket on failure and it
seems to work (patch against 8.1.15 attached). I'm not sure that this is
really the right way to handle it, but I haven't seen any problems in my
testing and the number of open file descriptors holds steady.

-- 
Michael Heironimus
*** conserver-8.1.15.orig/conserver/consent.c	Fri Jun 16 21:03:15 2006
--- conserver-8.1.15/conserver/consent.c	Sat Mar 17 12:15:25 2007
***************
*** 972,975 ****
--- 972,978 ----
  		if (!SetFlags(cofile, O_NONBLOCK, 0)) {
  		    ConsDown(pCE, FLAGTRUE, FLAGTRUE);
+ 		    if (cofile) {
+ 			close(cofile);
+ 		    }
  		    return;
  		}
***************
*** 982,985 ****
--- 985,991 ----
  			      pCE->server, cofile, strerror(errno));
  			ConsDown(pCE, FLAGTRUE, FLAGTRUE);
+ 			if (cofile) {
+ 			    close(cofile);
+ 			}
  			return;
  		    }
***************
*** 992,995 ****
--- 998,1004 ----
  		     pCE->server, cofile);
  		ConsDown(pCE, FLAGTRUE, FLAGTRUE);
+ 		if (cofile) {
+ 		    close(cofile);
+ 		}
  		return;
  	    }