[Haskell-cafe] ANN: network 3.0.0.0

Kazu Yamamoto (=?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?=) kazu at iij.ad.jp
Mon Jan 21 08:23:57 UTC 2019


Hello,

> * Never change the type of an existing function unless absolutely necessary.

The change of mkSocket and fdSocket is inevitable because the old
definition of Socket is:
data Socket = MkSocket CInt Family SocketType ProtocolNumber (MVar SocketStatus)
while new one is:
data Socket = Socket !(IORef CInt) CInt {- for Show -}

Why this drastic change? Well, believing or not, old Socket cannot be
GCed because of MVar! mkWeakMVar does not solve this issue.

So, we decided to get rid of MVar. But without SocketStatus (ie Socket
CInt), "close" becomes unsafe if "close" is called multiple time.  To
fix this, IORef was introduced. Now a closed Socket contains (-1).

If you type "fdScoket" or "GC" to the github repo search, you can find
a lot of discussions about this.

--Kazu


More information about the Haskell-Cafe mailing list