[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to balance WebServer's retain/release cycles?
From: |
Richard Frith-Macdonald |
Subject: |
Re: How to balance WebServer's retain/release cycles? |
Date: |
Tue, 5 Aug 2014 07:51:11 +0100 |
On 4 Aug 2014, at 10:59, Sergei Golovin <address@hidden> wrote:
>
> Hi!
>
> I'm trying to develop more thourough NSURLConnection's tests using a
> WebServer instance.
> And I have the problem with retain/release cycles on the WebServer.
> The simple code which gives me the exception
>
> "Uncaught exception NSFileHandleOperationException, reason: attempt to close
> closed file"
>
> is attached. If i comment out the line
>
> DESTROY(server);
>
> at the end it begins to work. But it seems counterintuitive for me.
> What do i do wrong?
You are doing nothing wrong.
I think that's a bug in shutting down the web server ... the connections the
server has open are told to shut down, but if they are operating in the same
thread that's shutting down the server, the runloop wasn't being run to allow
the I/O to complete.
I have added some code to run the runloop for up to 30 seconds to allow
incoming connections to be cleanly shut down.