diff --git a/bin/uce_fastcgi.debug.linux.bin b/bin/uce_fastcgi.debug.linux.bin index 2872655..41a916e 100755 Binary files a/bin/uce_fastcgi.debug.linux.bin and b/bin/uce_fastcgi.debug.linux.bin differ diff --git a/src/fastcgi/src/fcgicc.cc b/src/fastcgi/src/fcgicc.cc index 4c90083..ed06247 100644 --- a/src/fastcgi/src/fcgicc.cc +++ b/src/fastcgi/src/fcgicc.cc @@ -81,6 +81,9 @@ FastCGIServer::FastCGIServer() : FastCGIServer::~FastCGIServer() { + if(my_pid != parent_pid) // if we're a child process, we must not close the handles + return; + for (std::vector::iterator it = listen_sockets.begin(); it != listen_sockets.end(); ++it) close(*it); diff --git a/src/lib/compiler.cpp b/src/lib/compiler.cpp index 29c83cd..217c241 100644 --- a/src/lib/compiler.cpp +++ b/src/lib/compiler.cpp @@ -250,6 +250,15 @@ SharedUnit* get_shared_unit(Request* context, String file_name) { su = new SharedUnit(); setup_unit_paths(context, su, file_name); + if(!do_recompile) + { + // if we didn't decide to force recompile yet, we need to check + // (this case should only happen if the SU cache for that entry is cold + // but the SO itself exists _AND_ is stale) + su->last_compiled = file_mtime(su->so_name); + if(su->last_compiled < mod_time || mod_time == 0) + do_recompile = true; + } int fdlock = open((su->so_name+".lock").c_str(), O_RDWR | O_CREAT, 0666 ); int fl_excl = flock(fdlock, LOCK_EX); diff --git a/src/lib/types.h b/src/lib/types.h index 57a32d5..93e7a05 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -18,7 +18,7 @@ typedef long long s64; typedef std::string String; #define DEBUG_MEMORY_OFF; -#define GLOBAL_ARENA_ALLOCATOR; +#define NO_GLOBAL_ARENA_ALLOCATOR; struct MemoryArena { @@ -31,7 +31,7 @@ struct MemoryArena { { name = _name; capacity = cap; - printf("(i) memory arena %s created with capacity of %llu bytes\n", name.c_str(), capacity); + printf("(i) memory arena '%s' created with capacity of %llu bytes\n", name.c_str(), capacity); data = (u8*)malloc(cap); } @@ -43,7 +43,7 @@ struct MemoryArena { void clear() { #ifdef DEBUG_MEMORY - printf("(i) memory arena %s cleared after high mark of %llu bytes\n", name.c_str(), size); + printf("(i) memory arena '%s' cleared after high mark of %llu bytes\n", name.c_str(), size); #endif size = 0; } @@ -60,7 +60,7 @@ struct MemoryArena { } size += size_aligned; #ifdef DEBUG_MEMORY - printf("(i) memory arena %s [+%llu]:%p alloc %llu/%llu bytes\n", name.c_str(), size, result, size_needed, size_aligned); + printf("(i) memory arena '%s' [+%llu]:%p alloc %llu/%llu bytes\n", name.c_str(), size, result, size_needed, size_aligned); #endif return(result); } diff --git a/src/linux_fastcgi.cpp b/src/linux_fastcgi.cpp index faa33b5..ad63de0 100644 --- a/src/linux_fastcgi.cpp +++ b/src/linux_fastcgi.cpp @@ -4,12 +4,13 @@ FastCGIServer server; ServerState server_state; -MemoryArena* request_arena; +MemoryArena* request_arena = 0; int handle_request(FastCGIRequest& request) { // This is always the first event to occur. It occurs when the // server receives all parameters. There may be more data coming on the // standard input stream. + request.request_arena = request_arena; request.time_init = microtime(); if (request.params.count("REQUEST_URI")) return 0; // OK, continue processing @@ -66,8 +67,6 @@ int handle_complete(FastCGIRequest& request) { } // printf("(i) request ready\n"); - //current_memory_arena = request_arena; - //request_arena->clear(); request.invoke(request.params["SCRIPT_FILENAME"]); switch_to_system_alloc(); @@ -100,12 +99,15 @@ int handle_complete(FastCGIRequest& request) { void listen_for_connections() { + //request_arena = new MemoryArena(server_state.config.MAX_MEMORY, "request"); + signal(SIGSEGV, on_segfault); server.request_handler(&handle_request); server.data_handler(&handle_data); server.complete_handler(&handle_complete); - request_arena = new MemoryArena(server_state.config.MAX_MEMORY, "request"); for(;;) { + //if(request_arena) request_arena->clear(); + //current_memory_arena = request_arena; server.process(); } } @@ -114,7 +116,6 @@ int main(int argc, char** argv) { printf("(P) Starting parent server PID:%i\n", getpid()); - signal(SIGSEGV, on_segfault); signal(SIGCHLD, on_child_exit); srand(time());