Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle errors when sending HTTP error responses #699

Closed
keshonok opened this issue Mar 14, 2017 · 1 comment
Closed

Properly handle errors when sending HTTP error responses #699

keshonok opened this issue Mar 14, 2017 · 1 comment

Comments

@keshonok
Copy link
Contributor

keshonok commented Mar 14, 2017

There's a set of tfw_http_send_XXX() functions in http.c module which send an HTTP error response, such as tfw_http_send_500(), etc. These functions return an error code if there's an error while sending an HTTP error response. However, these errors are never handled and there's no attempt to recover from these errors.

After the merge of #660 error responses are sent in proper seq order to a client. If a request results in an error response, and that error response could not be created and linked with the request, that leaves a "hole" in the seq queue. The hole forces Tempesta to stop sending responses to the client as it doesn't know that the response will never come. The connection with the client will hang around for some time until it's closed by the client or by Tempesta due to inactivity.

This situation needs to be handled properly. When it's known that there will be no response for a particular request, all prior responses should be sent out to the client as they are now, and then the connection should be closed by Tempesta.

A possible solution looks like this:

  • tfw_http_send_XXX() functions handle all errors internally by calling tfw_http_resp_fwd() with a NULL response pointer. Therefore, these functions do not return an error code any more and are made void.
  • tfw_http_resp_fwd() handles a NULL pointer to the response appropriately as described above.

This issue is NOT critical as it doesn't break Tempesta in any way. Also, it would occur only under severe memory pressure. Still, it's in everyone's best interests to close such connections as soon as possible.

@krizhanovsky
Copy link
Contributor

Basically this is duplicate of #825 (Handling errors in constructing messages to clients) and was fixed in #839 . Sending unlucky responses before the error was considered as senseless, see discussion #839 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants