[MINOR] session: try to emit a 500 response on memory allocation errors
When we fail to create a session because of memory shortage, let's at
least try to send a 500 message directly on the socket. Even if we don't
have any buffers left, the kernel's orphans management will take care of
delivering the message as long as there are socket buffers left.
diff --git a/src/session.c b/src/session.c
index 6e3a525..e5ac4ee 100644
--- a/src/session.c
+++ b/src/session.c
@@ -310,6 +310,12 @@
out_free_session:
pool_free2(pool2_session, s);
out_close:
+ if (ret < 0 && s->fe->mode == PR_MODE_HTTP) {
+ /* critical error, no more memory, try to emit a 500 response */
+ struct chunk *err_msg = error_message(s, HTTP_ERR_500);
+ send(cfd, err_msg->str, err_msg->len, MSG_DONTWAIT|MSG_NOSIGNAL);
+ }
+
if (fdtab[cfd].state != FD_STCLOSE)
fd_delete(cfd);
else