Skip to content

making gracefulClose more graceful#580

Merged
kazu-yamamoto merged 2 commits into
haskell:masterfrom
kazu-yamamoto:gracefully-graceful-shutdown
Jun 12, 2024
Merged

making gracefulClose more graceful#580
kazu-yamamoto merged 2 commits into
haskell:masterfrom
kazu-yamamoto:gracefully-graceful-shutdown

Conversation

@kazu-yamamoto

Copy link
Copy Markdown
Collaborator

200ms is too long. So, wait for 1ms first, then 2ms, 4ms, 8ms, etc.

@kazu-yamamoto

kazu-yamamoto commented Jun 10, 2024

Copy link
Copy Markdown
Collaborator Author

@khibino This makes dug's time rag smaller. But we can still notice the time rag, I guess.

@edsko network-run uses gracefulClose in network. We feel a time rag when a client is finished because threadDelay with 200ms is used. This patch starts with 1ms and increments it exponentially.

Your opinions are highly welcome.

@edsko

edsko commented Jun 11, 2024

Copy link
Copy Markdown

Makes sense to me. I don't know how critical the maximum timeout out; as it stands, the patch might exceed it (by one round); could instead consider

let tmout' = tmout + delay
when (r == -1 && tmout' < tmout0) $ do
    threadDelay (delay * 1000)
    loop (delay * 2) tmout'

to check if the timeout that we are about to do would not exceed the max. But it probably doesn't really matter either way.

TL;DR: Fine with me :)

200ms is too long. So, wait for 1ms first, then 2ms, 4ms, 8ms, etc.
@kazu-yamamoto kazu-yamamoto force-pushed the gracefully-graceful-shutdown branch from b3c898e to 107486a Compare June 11, 2024 22:55
@kazu-yamamoto

Copy link
Copy Markdown
Collaborator Author

@edsko Thank you for your review.
I would like to merge this PR as is.

@kazu-yamamoto kazu-yamamoto merged commit a2e111e into haskell:master Jun 12, 2024
@kazu-yamamoto kazu-yamamoto deleted the gracefully-graceful-shutdown branch June 12, 2024 00:09
@kazu-yamamoto

Copy link
Copy Markdown
Collaborator Author

Rebased and merged.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jan 30, 2025
## Version 3.2.7.0

* Using nested `bracket` for `gracefulClose`.
  [#591](haskell/network#590)
* Fix memory leak in getaddrinfo and make it async exception safe.
  [#591](haskell/network#591)
* Make call to c_free async exception safe.
  [#592](haskell/network#592)

## Version 3.2.6.0

* fixing the Show instance of IPv4-mapped IPv6 address on little endian machines

## Version 3.2.5.0

* `gracefulClose` based on STM racing and `timeout`.
  [#587](haskell/network#587)

## Version 3.2.4.0

* New API: setSockOptValue.
  [#588](haskell/network#588)

## Version 3.2.3.0

* Making getAddrInfo polymorphic
  [#587](haskell/network#587)

## Version 3.2.2.0

* New API: waitReadSocketSTM, waitAndCancelReadSocketSTM,
  waitWriteSocketSTM, waitAndCancelWriteSocketSTM
  [#586](haskell/network#586)
* Checking the length of ASCII string allowing trailing 0.
  [#585](haskell/network#585)

## Version 3.2.1.0

* Trying to release with the latest autoreconf.
  Packing "network" in the local directory instead of CI.
* Remove includes from .cabal-file
  [#583](haskell/network#583)
* making gracefulClose more graceful
  [#580](haskell/network#580)
* Update config.guess, config.sub to their latest versions
  [#579](haskell/network#579)
msk pushed a commit to msk/pkgsrc that referenced this pull request May 11, 2026
## Version 3.2.7.0

* Using nested `bracket` for `gracefulClose`.
  [#591](haskell/network#590)
* Fix memory leak in getaddrinfo and make it async exception safe.
  [#591](haskell/network#591)
* Make call to c_free async exception safe.
  [#592](haskell/network#592)

## Version 3.2.6.0

* fixing the Show instance of IPv4-mapped IPv6 address on little endian machines

## Version 3.2.5.0

* `gracefulClose` based on STM racing and `timeout`.
  [#587](haskell/network#587)

## Version 3.2.4.0

* New API: setSockOptValue.
  [#588](haskell/network#588)

## Version 3.2.3.0

* Making getAddrInfo polymorphic
  [#587](haskell/network#587)

## Version 3.2.2.0

* New API: waitReadSocketSTM, waitAndCancelReadSocketSTM,
  waitWriteSocketSTM, waitAndCancelWriteSocketSTM
  [#586](haskell/network#586)
* Checking the length of ASCII string allowing trailing 0.
  [#585](haskell/network#585)

## Version 3.2.1.0

* Trying to release with the latest autoreconf.
  Packing "network" in the local directory instead of CI.
* Remove includes from .cabal-file
  [#583](haskell/network#583)
* making gracefulClose more graceful
  [#580](haskell/network#580)
* Update config.guess, config.sub to their latest versions
  [#579](haskell/network#579)
jperkin pushed a commit to TritonDataCenter/pkgsrc that referenced this pull request May 14, 2026
## Version 3.2.7.0

* Using nested `bracket` for `gracefulClose`.
  [#591](haskell/network#590)
* Fix memory leak in getaddrinfo and make it async exception safe.
  [#591](haskell/network#591)
* Make call to c_free async exception safe.
  [#592](haskell/network#592)

## Version 3.2.6.0

* fixing the Show instance of IPv4-mapped IPv6 address on little endian machines

## Version 3.2.5.0

* `gracefulClose` based on STM racing and `timeout`.
  [#587](haskell/network#587)

## Version 3.2.4.0

* New API: setSockOptValue.
  [#588](haskell/network#588)

## Version 3.2.3.0

* Making getAddrInfo polymorphic
  [#587](haskell/network#587)

## Version 3.2.2.0

* New API: waitReadSocketSTM, waitAndCancelReadSocketSTM,
  waitWriteSocketSTM, waitAndCancelWriteSocketSTM
  [#586](haskell/network#586)
* Checking the length of ASCII string allowing trailing 0.
  [#585](haskell/network#585)

## Version 3.2.1.0

* Trying to release with the latest autoreconf.
  Packing "network" in the local directory instead of CI.
* Remove includes from .cabal-file
  [#583](haskell/network#583)
* making gracefulClose more graceful
  [#580](haskell/network#580)
* Update config.guess, config.sub to their latest versions
  [#579](haskell/network#579)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants