comparison mercurial/chgserver.py @ 49240:201222849987 stable

chg: ignore already closed fds when cleaning up This should fix this error we see in the CI from time to time: ``` --- /tmp/mercurial-ci/tests/test-chg.t +++ /tmp/mercurial-ci/tests/test-chg.t.err @@ -187,6 +187,26 @@ $ chg bulkwrite --pager=on --color no --config ui.formatted=True paged! 'going to write massive data\n' killed! (?) + Traceback (most recent call last): + File "/tmp/hgtests._uvojvqb/install/lib/python/mercurial/commandserver.py", line 509, in _serverequest + sv.cleanup() + File "/tmp/hgtests._uvojvqb/install/lib/python/mercurial/chgserver.py", line 382, in cleanup + self._restoreio() + File "/tmp/hgtests._uvojvqb/install/lib/python/mercurial/chgserver.py", line 461, in _restoreio + os.close(fd) + OSError: [Errno 9] Bad file descriptor + Traceback (most recent call last): + File "/tmp/hgtests._uvojvqb/install/lib/python/mercurial/commandserver.py", line 693, in _acceptnewconnection + self._runworker(conn) + File "/tmp/hgtests._uvojvqb/install/lib/python/mercurial/commandserver.py", line 744, in _runworker + prereposetups=[self._reposetup], + File "/tmp/hgtests._uvojvqb/install/lib/python/mercurial/commandserver.py", line 509, in _serverequest + sv.cleanup() + File "/tmp/hgtests._uvojvqb/install/lib/python/mercurial/chgserver.py", line 382, in cleanup + self._restoreio() + File "/tmp/hgtests._uvojvqb/install/lib/python/mercurial/chgserver.py", line 461, in _restoreio + os.close(fd) + OSError: [Errno 9] Bad file descriptor [255] ```
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 30 May 2022 11:52:31 +0200
parents 7caaefa48794
children cd51d4957b28
comparison
equal deleted inserted replaced
49234:9dad328434c7 49240:201222849987
463 # of EPIPE. The data should belong to the current session 463 # of EPIPE. The data should belong to the current session
464 # and should never persist. 464 # and should never persist.
465 os.dup2(nullfd, fp.fileno()) 465 os.dup2(nullfd, fp.fileno())
466 fp.flush() 466 fp.flush()
467 os.dup2(fd, fp.fileno()) 467 os.dup2(fd, fp.fileno())
468 os.close(fd)
468 except OSError as err: 469 except OSError as err:
469 # According to issue6330, running chg on heavy loaded systems 470 # According to issue6330, running chg on heavy loaded systems
470 # can lead to EBUSY. [man dup2] indicates that, on Linux, 471 # can lead to EBUSY. [man dup2] indicates that, on Linux,
471 # EBUSY comes from a race condition between open() and dup2(). 472 # EBUSY comes from a race condition between open() and dup2().
472 # However it's not clear why open() race occurred for 473 # However it's not clear why open() race occurred for
475 b'chgserver', 476 b'chgserver',
476 b'got %s while duplicating %s\n', 477 b'got %s while duplicating %s\n',
477 stringutil.forcebytestr(err), 478 stringutil.forcebytestr(err),
478 fn, 479 fn,
479 ) 480 )
480 os.close(fd)
481 setattr(self, cn, ch) 481 setattr(self, cn, ch)
482 setattr(ui, fn, fp) 482 setattr(ui, fn, fp)
483 os.close(nullfd) 483 os.close(nullfd)
484 del self._oldios[:] 484 del self._oldios[:]
485 485