send_http_message() doesn't create a memory block and store it in the
connection's output_message variable. Instead the error is sent to the client right away. Once we finish processing the client's headers it will automatically accept the error message. So we get the same result, but less memory is used.
This commit is contained in:
parent
606c8196a0
commit
6ab7ebcb31
16
src/utils.c
16
src/utils.c
@ -1,4 +1,4 @@
|
||||
/* $Id: utils.c,v 1.12 2001-09-15 21:29:59 rjkaes Exp $
|
||||
/* $Id: utils.c,v 1.13 2001-09-16 20:13:52 rjkaes Exp $
|
||||
*
|
||||
* Misc. routines which are used by the various functions to handle strings
|
||||
* and memory allocation and pretty much anything else we can think of. Also,
|
||||
@ -84,7 +84,6 @@ int send_http_message(struct conn_s* connptr, int http_code,
|
||||
char *header_buffer;
|
||||
char timebuf[30];
|
||||
time_t global_time;
|
||||
int output_size;
|
||||
|
||||
header_buffer = safemalloc(HEADER_SIZE);
|
||||
if (!header_buffer)
|
||||
@ -95,18 +94,13 @@ int send_http_message(struct conn_s* connptr, int http_code,
|
||||
|
||||
snprintf(header_buffer, HEADER_SIZE - 1, headers, http_code, error_title, PACKAGE, VERSION, timebuf, strlen(message));
|
||||
|
||||
output_size = strlen(message) + strlen(header_buffer);
|
||||
connptr->output_message = safemalloc(output_size + 1);
|
||||
if (!connptr->output_message) {
|
||||
safefree(header_buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
strlcpy(connptr->output_message, header_buffer, output_size);
|
||||
strlcat(connptr->output_message, message, output_size);
|
||||
safe_write(connptr->client_fd, header_buffer, strlen(header_buffer));
|
||||
safe_write(connptr->client_fd, message, strlen(message));
|
||||
|
||||
safefree(header_buffer);
|
||||
|
||||
connptr->send_message = TRUE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user