| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 raise | 254 raise |
| 255 _log.debug("Server NOT running on %d: %s" % (port, e)) | 255 _log.debug("Server NOT running on %d: %s" % (port, e)) |
| 256 return False | 256 return False |
| 257 finally: | 257 finally: |
| 258 s.close() | 258 s.close() |
| 259 return True | 259 return True |
| 260 | 260 |
| 261 def _check_that_all_ports_are_available(self): | 261 def _check_that_all_ports_are_available(self): |
| 262 for mapping in self._mappings: | 262 for mapping in self._mappings: |
| 263 s = socket.socket() | 263 s = socket.socket() |
| 264 # s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | 264 if not self._platform.is_win(): |
| 265 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
| 265 port = mapping['port'] | 266 port = mapping['port'] |
| 266 try: | 267 try: |
| 267 s.bind(('localhost', port)) | 268 s.bind(('localhost', port)) |
| 268 except IOError, e: | 269 except IOError, e: |
| 269 if e.errno in (errno.EALREADY, errno.EADDRINUSE): | 270 if e.errno in (errno.EALREADY, errno.EADDRINUSE): |
| 270 raise ServerError('Port %d is already in use.' % port) | 271 raise ServerError('Port %d is already in use.' % port) |
| 271 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,):
# pylint: disable=E1101 | 272 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,):
# pylint: disable=E1101 |
| 272 raise ServerError('Port %d is already in use.' % port) | 273 raise ServerError('Port %d is already in use.' % port) |
| 273 else: | 274 else: |
| 274 raise | 275 raise |
| 275 finally: | 276 finally: |
| 276 s.close() | 277 s.close() |
| 277 _log.debug('all ports are available') | 278 _log.debug('all ports are available') |
| OLD | NEW |