> +-- | Allocate a port.
> +-- The port will be taken from the available port pool or from the
> +-- default port range (and in this case we increase
> +-- highest_used_port).
> +allocatePort :: WConfdMonad Int
> +allocatePort = do
> +  maybePort <- modifyConfigAndReturnWithLock (\_ cs ->
> [...]
> +  case maybePort of
> +    Nothing -> toError . Bad . ConfigurationError $
> +      "Failed to modify configuration"
> +    Just port -> return port

NACK.

modifyConfingAndReturnWithLock returns nothing if the
configuration lock is held by some other process. This
is NOT a configuration error but simply indicates that
the configuration is temporarily not available. As we
have no guarantee to obtain a lock withing the time
frame of an RPC, we have to delegate out the retry to
the caller by returning Maybe Int, or maybe MaybeForJSON Int.

-- 
Klaus Aehlig
Google Germany GmbH, Dienerstr. 12, 80331 Muenchen
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschaeftsfuehrer: Graham Law, Christine Elizabeth Flores

Reply via email to