Bug 237886

Summary: logging/handlers.py doesn't always set unixsocket
Product: [Fedora] Fedora Reporter: Steve Friedman <steve>
Component: pythonAssignee: Jeremy Katz <katzj>
Status: CLOSED RAWHIDE QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 6CC: katzj
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-04-30 20:51:45 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Steve Friedman 2007-04-25 20:59:18 UTC
Description of problem:

I am having a problem (for reasons that I don't understand) that line 630 of
handlers.py claims that unixsocket is undefined.  One way that this can happen
is if the socket creation (either _connect_unixsocket() or socket.socket())
throws an uncaught exception as unixsocket is defined after this point. 


Version-Release number of selected component (if applicable):
python-2.4.4-1.fc6

How reproducible:
Always (if you can get the socket creation to fail).

Steps to Reproduce:
1. Turn of syslog / syslog-ng.
2. Run any python command that uses logging (e.g., yum check-update).
3.
  
Actual results:
The code throws an exception in the close().

Expected results:


Additional info:
The simplest solution is to set unixsocket=0 prior to the if and only set it to
1 after the socket is properly created:

From:
       if type(address) == types.StringType:
            self._connect_unixsocket(address)
            self.unixsocket = 1
        else:
            self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
            self.unixsocket = 0

To:
       self.unixsocket = 0
       if type(address) == types.StringType:
            self._connect_unixsocket(address)
            self.unixsocket = 1
        else:
            self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

Comment 1 Jeremy Katz 2007-04-30 20:51:45 UTC
Already fixed in rawhide and I've committed the fix to the FC-6 branch of the
python package for the next time I do an update of it.