Commit 3dac803c4158c56bde557910ae93abbd7097a1fa
1 parent
459ecc5d
fix memory leak created while changing things
Showing
3 changed files
with
10 additions
and
3 deletions
... | ... | @@ -31,11 +31,11 @@ char * |
31 | 31 | httpHeaderGet(const HttpHeader header[], int nheader, const char * name) |
32 | 32 | { |
33 | 33 | unsigned long hash = sdbm((unsigned char *)name); |
34 | - HttpHeader found; | |
34 | + HttpHeader * found; | |
35 | 35 | |
36 | 36 | found = bsearch(&hash, header, nheader, sizeof(HttpHeader), comp); |
37 | 37 | |
38 | - return (NULL != found)? found->value : NULL; | |
38 | + return (NULL != *found)? (*found)->value : NULL; | |
39 | 39 | } |
40 | 40 | |
41 | 41 | // vim: set ts=4 sw=4: | ... | ... |
... | ... | @@ -9,7 +9,7 @@ httpRequestParserGetHeader(HttpRequest request, char * line) |
9 | 9 | char * name = line; |
10 | 10 | char * value = strchr(line, ':'); |
11 | 11 | |
12 | - *value = 0; | |
12 | + *(value++) = 0; | |
13 | 13 | for (; *value == ' ' && *value != 0; value++); |
14 | 14 | |
15 | 15 | (request->header)[request->nheader++] = new(HttpHeader, name, value); | ... | ... |
... | ... | @@ -2,6 +2,9 @@ |
2 | 2 | #include <socket.h> |
3 | 3 | #include <string.h> |
4 | 4 | |
5 | +#include <sys/time.h> | |
6 | +#include <sys/resource.h> | |
7 | + | |
5 | 8 | #include "server.h" |
6 | 9 | #include "logger.h" |
7 | 10 | #include "http/request_parser.h" |
... | ... | @@ -13,11 +16,15 @@ |
13 | 16 | int |
14 | 17 | main() |
15 | 18 | { |
19 | + struct rlimit limit = {RLIM_INFINITY, RLIM_INFINITY}; | |
20 | + | |
16 | 21 | Logger logger = new(LoggerStderr, LOGGER_ERR); |
17 | 22 | HttpRequestParser parser = new(HttpRequestParser); |
18 | 23 | Server server = new(Server, logger, parser, 11212, SOMAXCONN); |
19 | 24 | //Server server = new(Server, logger, parser, 11212, 20); |
20 | 25 | |
26 | + setrlimit(RLIMIT_CPU, &limit); | |
27 | + | |
21 | 28 | init_signals(); |
22 | 29 | serverRun(server); |
23 | 30 | ... | ... |
Please
register
or
login
to post a comment