Re: Correct way to cancel a server-side request?



On 04/04/2012 03:44 AM, Mark Delany wrote:
> What I do is to call ClientContent->get_socket->disconnect() which
> ultimately causes Soup.Server to raise a request-aborted signal which
> is fine.
> 
> What I want is a guaranteed way of canceling the connection so
> calling unpause_message() is inappropriate as it relies on the client
> consuming the response which is outside of my control.
> 
> Question: Is .disconnect() the best/only way to do this?

There's a test in tests/connection-test.c (or tests/misc-test.c in
libsoup < 2.38) that does this (to test how the client side reacts in a
particular situation), and I found that calling soup_socket_disconnect()
causes SoupServer to end up leaking some data (at least in that
particular test; maybe not in all cases). However, shutting down the
socket file descriptor has more or less the same effect, without the leak:

	sockfd = soup_socket_get_fd (sock);
    #ifdef G_OS_WIN32
	shutdown (sockfd, SD_BOTH);
    #else
	shutdown (sockfd, SHUT_RDWR);
    #endif

(The SoupServer will then get an error trying to read from or write to
the socket, and then it will clean everything up properly from there.)

Maybe there ought to be API for doing this less kludgily...

-- Dan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]