diff options
author | Xinchen Hui <laruence@gmail.com> | 2015-05-26 11:47:01 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2015-05-26 11:47:01 +0800 |
commit | 5f753f9e2e907187b6c8d5b0488c450713ee0871 (patch) | |
tree | 485d45e8781b88f89f69bdbb1a0e27d245ab463e /main | |
parent | 06483a98d6e1a6738c0b225741a400e088e4d6b0 (diff) | |
download | php-git-5f753f9e2e907187b6c8d5b0488c450713ee0871.tar.gz |
Micro optimizations
Diffstat (limited to 'main')
-rw-r--r-- | main/fastcgi.c | 28 | ||||
-rw-r--r-- | main/fastcgi.h | 6 |
2 files changed, 16 insertions, 18 deletions
diff --git a/main/fastcgi.c b/main/fastcgi.c index 675b9a88b0..e2e356faac 100644 --- a/main/fastcgi.c +++ b/main/fastcgi.c @@ -768,6 +768,10 @@ FCGI_API void fcgi_set_allowed_clients(char *ip) } } +static void fcgi_hook_dummy() { + return; +} + FCGI_API fcgi_request *fcgi_init_request(fcgi_request *req, int listen_socket) { memset(req, 0, sizeof(fcgi_request)); @@ -790,19 +794,21 @@ FCGI_API fcgi_request *fcgi_init_request(fcgi_request *req, int listen_socket) */ req->out_pos = req->out_buf; + req->hook.on_accept = fcgi_hook_dummy; + req->hook.on_read = fcgi_hook_dummy; + req->hook.on_close = fcgi_hook_dummy; #ifdef _WIN32 req->tcp = !GetNamedPipeInfo((HANDLE)_get_osfhandle(req->listen_socket), NULL, NULL, NULL, NULL); #endif + fcgi_hash_init(&req->env); return req; } FCGI_API void fcgi_destroy_request(fcgi_request *req) { - if (req->env.buckets) { - fcgi_hash_destroy(&req->env); - } + fcgi_hash_destroy(&req->env); } static inline ssize_t safe_write(fcgi_request *req, const void *buf, size_t count) @@ -1193,9 +1199,7 @@ FCGI_API void fcgi_close(fcgi_request *req, int force, int destroy) #endif req->fd = -1; - if (req->hook.on_close) { - req->hook.on_close(); - } + req->hook.on_close(); } } @@ -1285,9 +1289,7 @@ FCGI_API int fcgi_accept_request(fcgi_request *req) sa_t sa; socklen_t len = sizeof(sa); - if (req->hook.on_accept) { - req->hook.on_accept(); - } + req->hook.on_accept(); FCGI_LOCK(req->listen_socket); req->fd = accept(listen_socket, (struct sockaddr *)&sa, &len); @@ -1318,9 +1320,7 @@ FCGI_API int fcgi_accept_request(fcgi_request *req) struct pollfd fds; int ret; - if (req->hook.on_read) { - req->hook.on_read(); - } + req->hook.on_read(); fds.fd = req->fd; fds.events = POLLIN; @@ -1334,9 +1334,7 @@ FCGI_API int fcgi_accept_request(fcgi_request *req) } fcgi_close(req, 1, 0); #else - if (req->hook.on_read) { - req->hook.on_read(); - } + req->hook.on_read(); if (req->fd < FD_SETSIZE) { struct timeval tv = {5,0}; diff --git a/main/fastcgi.h b/main/fastcgi.h index e5888228fe..67203f1647 100644 --- a/main/fastcgi.h +++ b/main/fastcgi.h @@ -181,17 +181,17 @@ struct _fcgi_request { int nodelay; #endif int closed; - - fcgi_req_hook hook; - int in_len; int in_pad; fcgi_header *out_hdr; + unsigned char *out_pos; unsigned char out_buf[1024*8]; unsigned char reserved[sizeof(fcgi_end_request_rec)]; + fcgi_req_hook hook; + int has_env; fcgi_hash env; }; |