Re: Correct way to cancel a server-side request?
- From: "Mark Delany" <k3x echo emu st>
- To: libsoup-list gnome org
- Subject: Re: Correct way to cancel a server-side request?
- Date: 4 Apr 2012 23:17:17 +0000
> > 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
> 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...
If you're suggesting something like Server.cancel_message() then that
has the merit of making the actions of the caller explicit. It also
gives Server the opportunity to do something more sensible than
express an unexpected I/O error.
As it stands, my stumbling across a mechanism that happens to work and
you using a different mechanism based on internal knowledge does
suggest that we are both relying on a side-effect to achieve the same
goal.
I do note that your method is safer than mine. By closing the fd I
have created the possibility that the fd may be re-used by another
open/accept and then two requests could operate on the same fd -
obviously not good. But do I get brownie points for at least using an
API call rather than an OS call :-)
Mark.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]