| OLD | NEW |
| 1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 for mapping in self._mappings: | 268 for mapping in self._mappings: |
| 269 s = socket.socket() | 269 s = socket.socket() |
| 270 if not self._platform.is_win(): | 270 if not self._platform.is_win(): |
| 271 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | 271 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
| 272 port = mapping['port'] | 272 port = mapping['port'] |
| 273 try: | 273 try: |
| 274 s.bind(('localhost', port)) | 274 s.bind(('localhost', port)) |
| 275 except IOError as e: | 275 except IOError as e: |
| 276 if e.errno in (errno.EALREADY, errno.EADDRINUSE): | 276 if e.errno in (errno.EALREADY, errno.EADDRINUSE): |
| 277 raise ServerError('Port %d is already in use.' % port) | 277 raise ServerError('Port %d is already in use.' % port) |
| 278 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,):
# pylint: disable=E1101 | 278 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,):
# pylint: disable=no-member |
| 279 raise ServerError('Port %d is already in use.' % port) | 279 raise ServerError('Port %d is already in use.' % port) |
| 280 else: | 280 else: |
| 281 raise | 281 raise |
| 282 finally: | 282 finally: |
| 283 s.close() | 283 s.close() |
| 284 _log.debug('all ports are available') | 284 _log.debug('all ports are available') |
| OLD | NEW |