Permalink
Browse files

free arena at the end of the request

  • Loading branch information...
1 parent 9e6853f commit 954b6f36e5c766933ba34f6c803399ddb8c640b9 @charliesome committed Aug 4, 2012
Showing with 11 additions and 6 deletions.
  1. +5 −4 sapi/apache2/mod_slash.c
  2. +6 −2 sapi/cli/cli.c
View
@@ -126,7 +126,7 @@ setup_response_object(sl_vm_t* vm)
}
static int
-run_slash_script(request_rec* r)
+run_slash_script(request_rec* r, void* stack_top)
{
sl_vm_t* vm;
slash_context_t ctx;
@@ -135,7 +135,8 @@ run_slash_script(request_rec* r)
SLVAL error;
sl_static_init();
vm = sl_init();
- vm->cwd = sl_alloc(vm->arena, strlen(r->canonical_filename) + 10);
+ sl_gc_set_stack_top(vm->arena, stack_top);
+ vm->cwd = sl_alloc_buffer(vm->arena, strlen(r->canonical_filename) + 10);
strcpy(vm->cwd, r->canonical_filename);
last_slash = strrchr(vm->cwd, '/');
if(last_slash) {
@@ -158,6 +159,7 @@ run_slash_script(request_rec* r)
}, error, {});
flush_headers(&ctx);
sl_response_flush(vm);
+ sl_free_gc_arena(vm->arena);
return OK;
}
@@ -171,8 +173,7 @@ slash_handler(request_rec* r)
if(!sl_abs_file_exists(r->canonical_filename)) {
return DECLINED;
}
- ret = run_slash_script(r);
- GC_gcollect();
+ ret = run_slash_script(r, &ret);
return ret;
}
View
@@ -92,6 +92,7 @@ main(int argc, char** argv)
sl_vm_t* vm;
sl_catch_frame_t exit_frame;
SLVAL err;
+ int exit_code;
sl_static_init();
vm = sl_init();
sl_gc_set_stack_top(vm->arena, &argc);
@@ -115,8 +116,11 @@ main(int argc, char** argv)
on_error(vm, &state, err);
}
if(exit_frame.type == SL_UNWIND_EXIT) {
- exit(sl_get_int(err));
+ exit_code = sl_get_int(err);
+ sl_free_gc_arena(vm->arena);
+ exit(exit_code);
}
- });
+ });
+ sl_free_gc_arena(vm->arena);
return 0;
}

0 comments on commit 954b6f3

Please sign in to comment.