prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Failing `socket_info.getpeername()` with uvloop against a UDS.
  When running against a unix domain socket, we seem to occassionaly get an OSError when looking up the remote address. This appears to only occur with `uvloop`.
  
  ```
  ERROR:    Exception in callback HttpToolsProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)
  handle: <Handle HttpToolsProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)>
  Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/events.py", line 127, in _run
      self._callback(*self._args)
    File "/Users/tomchristie/GitHub/encode/uvicorn/uvicorn/protocols/http/httptools_impl.py", line 129, in connection_made
      self.client = get_remote_addr(transport)
    File "/Users/tomchristie/GitHub/encode/uvicorn/uvicorn/protocols/utils.py", line 8, in get_remote_addr
      info = socket_info.getpeername()
  OSError: [Errno 22] Invalid argument
  ```
  
  </issue>
  <code>
  [start of uvicorn/protocols/utils.py]
  1 import socket
  2 
  3 
  4 def get_remote_addr(transport):
  5     socket_info = transport.get_extra_info("socket")
  6     if socket_info is not None:
  7         info = socket_info.getpeername()
  8         family = socket_info.family
  9         if family in (socket.AF_INET, socket.AF_INET6):
  10             return (str(info[0]), int(info[1]))
  11         return None
  12     info = transport.get_extra_info("peername")
  13     if info is not None and isinstance(info, (list, tuple)) and len(info) == 2:
  14         return (str(info[0]), int(info[1]))
  15     return None
  16 
  17 
  18 def get_local_addr(transport):
  19     socket_info = transport.get_extra_info("socket")
  20     if socket_info is not None:
  21         info = socket_info.getsockname()
  22         family = socket_info.family
  23         if family in (socket.AF_INET, socket.AF_INET6):
  24             return (str(info[0]), int(info[1]))
  25         return None
  26     info = transport.get_extra_info("sockname")
  27     if info is not None and isinstance(info, (list, tuple)) and len(info) == 2:
  28         return (str(info[0]), int(info[1]))
  29     return None
  30 
  31 
  32 def is_ssl(transport):
  33     return bool(transport.get_extra_info("sslcontext"))
  34 
  35 
  36 def get_client_addr(scope):
  37     client = scope.get("client")
  38     if not client:
  39         return ""
  40     return "%s:%d" % client
  41 
  42 
  43 def get_path_with_query_string(scope):
  44     path_with_query_string = scope.get("root_path", "") + scope["path"]
  45     if scope["query_string"]:
  46         path_with_query_string = "{}?{}".format(
  47             path_with_query_string, scope["query_string"].decode("ascii")
  48         )
  49     return path_with_query_string
  50
  [end of uvicorn/protocols/utils.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/uvicorn/protocols/utils.py b/uvicorn/protocols/utils.py
  --- a/uvicorn/protocols/utils.py
  +++ b/uvicorn/protocols/utils.py
  @@ -4,8 +4,16 @@
   def get_remote_addr(transport):
       socket_info = transport.get_extra_info("socket")
       if socket_info is not None:
  -        info = socket_info.getpeername()
  -        family = socket_info.family
  +        try:
  +            info = socket_info.getpeername()
  +        except OSError:
  +            # This case appears to inconsistently occur with uvloop
  +            # bound to a unix domain socket.
  +            family = None
  +            info = None
  +        else:
  +            family = socket_info.family
  +
           if family in (socket.AF_INET, socket.AF_INET6):
               return (str(info[0]), int(info[1]))
           return None
  
verification_info: {"golden_diff": "diff --git a/uvicorn/protocols/utils.py b/uvicorn/protocols/utils.py\n--- a/uvicorn/protocols/utils.py\n+++ b/uvicorn/protocols/utils.py\n@@ -4,8 +4,16 @@\n def get_remote_addr(transport):\n     socket_info = transport.get_extra_info(\"socket\")\n     if socket_info is not None:\n-        info = socket_info.getpeername()\n-        family = socket_info.family\n+        try:\n+            info = socket_info.getpeername()\n+        except OSError:\n+            # This case appears to inconsistently occur with uvloop\n+            # bound to a unix domain socket.\n+            family = None\n+            info = None\n+        else:\n+            family = socket_info.family\n+\n         if family in (socket.AF_INET, socket.AF_INET6):\n             return (str(info[0]), int(info[1]))\n         return None\n", "issue": "Failing `socket_info.getpeername()` with uvloop against a UDS.\nWhen running against a unix domain socket, we seem to occassionaly get an OSError when looking up the remote address. This appears to only occur with `uvloop`.\r\n\r\n```\r\nERROR:    Exception in callback HttpToolsProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)\r\nhandle: <Handle HttpToolsProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)>\r\nTraceback (most recent call last):\r\n  File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/events.py\", line 127, in _run\r\n    self._callback(*self._args)\r\n  File \"/Users/tomchristie/GitHub/encode/uvicorn/uvicorn/protocols/http/httptools_impl.py\", line 129, in connection_made\r\n    self.client = get_remote_addr(transport)\r\n  File \"/Users/tomchristie/GitHub/encode/uvicorn/uvicorn/protocols/utils.py\", line 8, in get_remote_addr\r\n    info = socket_info.getpeername()\r\nOSError: [Errno 22] Invalid argument\r\n```\n", "before_files": [{"content": "import socket\n\n\ndef get_remote_addr(transport):\n    socket_info = transport.get_extra_info(\"socket\")\n    if socket_info is not None:\n        info = socket_info.getpeername()\n        family = socket_info.family\n        if family in (socket.AF_INET, socket.AF_INET6):\n            return (str(info[0]), int(info[1]))\n        return None\n    info = transport.get_extra_info(\"peername\")\n    if info is not None and isinstance(info, (list, tuple)) and len(info) == 2:\n        return (str(info[0]), int(info[1]))\n    return None\n\n\ndef get_local_addr(transport):\n    socket_info = transport.get_extra_info(\"socket\")\n    if socket_info is not None:\n        info = socket_info.getsockname()\n        family = socket_info.family\n        if family in (socket.AF_INET, socket.AF_INET6):\n            return (str(info[0]), int(info[1]))\n        return None\n    info = transport.get_extra_info(\"sockname\")\n    if info is not None and isinstance(info, (list, tuple)) and len(info) == 2:\n        return (str(info[0]), int(info[1]))\n    return None\n\n\ndef is_ssl(transport):\n    return bool(transport.get_extra_info(\"sslcontext\"))\n\n\ndef get_client_addr(scope):\n    client = scope.get(\"client\")\n    if not client:\n        return \"\"\n    return \"%s:%d\" % client\n\n\ndef get_path_with_query_string(scope):\n    path_with_query_string = scope.get(\"root_path\", \"\") + scope[\"path\"]\n    if scope[\"query_string\"]:\n        path_with_query_string = \"{}?{}\".format(\n            path_with_query_string, scope[\"query_string\"].decode(\"ascii\")\n        )\n    return path_with_query_string\n", "path": "uvicorn/protocols/utils.py"}]}