Commit 3abd8e28 authored by MARCHE Claude's avatar MARCHE Claude

Fix memory leaks in server code.

parent fedd395d
......@@ -74,12 +74,14 @@ prequest parse_request(char* str_req, int len, int key) {
if (semic == 1) {
pos = copy_up_to_semicolon (str_req, pos, len, &tmp);
if (strncmp(tmp, "parallel", pos) == 0) {
pos = copy_up_to_semicolon (str_req, pos, len, &tmp);
parallel_arg = atoi(tmp);
if (parallel_arg >= 1) {
parallel = parallel_arg;
}
free(tmp);
pos = copy_up_to_semicolon (str_req, pos, len, &tmp);
parallel_arg = atoi(tmp);
if (parallel_arg >= 1) {
parallel = parallel_arg;
}
}
free(tmp);
return NULL;
}
......@@ -92,9 +94,11 @@ prequest parse_request(char* str_req, int len, int key) {
if (strncmp(tmp, "runstdin", pos) == 0) {
runstdin = true;
} else {
free(tmp);
return NULL;
}
}
free(tmp);
req = (prequest) malloc(sizeof(request));
req->key = key;
req->numargs = numargs;
......
......@@ -537,7 +537,9 @@ void read_on_client(pclient client) {
void schedule_new_jobs() {
while (list_length(processes) < parallel && !(queue_is_empty (queue))) {
run_request((prequest) queue_pop (queue));
prequest r = (prequest) queue_pop (queue);
run_request(r);
free_request(r);
}
}
......
......@@ -556,9 +556,11 @@ void close_client(pclient client, int key) {
}
void schedule_new_jobs() {
while (list_length(processes) < parallel && !(queue_is_empty (queue))) {
run_request((prequest) queue_pop (queue));
}
while (list_length(processes) < parallel && !(queue_is_empty (queue))) {
prequest r = (prequest) queue_pop (queue);
run_request(r);
free_request(r);
}
}
void handle_child_event(pproc child, pclient client, int proc_key, DWORD event) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment