void fpm_request_info() { TSRMLS_FETCH(); struct fpm_shm_slot_s *slot; char *request_method = fpm_php_request_method(TSRMLS_C); char *script_filename = fpm_php_script_filename(TSRMLS_C); slot = fpm_shm_slots_acquire(0, 0); slot->request_stage = FPM_REQUEST_INFO; fpm_clock_get(&slot->tv); if (request_method) { cpystrn(slot->request_method, request_method, sizeof(slot->request_method)); } slot->content_length = fpm_php_content_length(TSRMLS_C); /* if cgi.fix_pathinfo is set to "1" and script cannot be found (404) the sapi_globals.request_info.path_translated is set to NULL */ if (script_filename) { cpystrn(slot->script_filename, script_filename, sizeof(slot->script_filename)); } fpm_shm_slots_release(slot); }
void fpm_request_info() /* {{{ */ { struct fpm_scoreboard_proc_s *proc; char *request_uri = fpm_php_request_uri(); char *request_method = fpm_php_request_method(); char *script_filename = fpm_php_script_filename(); char *query_string = fpm_php_query_string(); char *auth_user = fpm_php_auth_user(); size_t content_length = fpm_php_content_length(); struct timeval now; fpm_clock_get(&now); proc = fpm_scoreboard_proc_acquire(NULL, -1, 0); if (proc == NULL) { zlog(ZLOG_WARNING, "failed to acquire proc scoreboard"); return; } proc->request_stage = FPM_REQUEST_INFO; proc->tv = now; if (request_uri) { strlcpy(proc->request_uri, request_uri, sizeof(proc->request_uri)); } if (request_method) { strlcpy(proc->request_method, request_method, sizeof(proc->request_method)); } if (query_string) { strlcpy(proc->query_string, query_string, sizeof(proc->query_string)); } if (auth_user) { strlcpy(proc->auth_user, auth_user, sizeof(proc->auth_user)); } proc->content_length = content_length; /* if cgi.fix_pathinfo is set to "1" and script cannot be found (404) the sapi_globals.request_info.path_translated is set to NULL */ if (script_filename) { strlcpy(proc->script_filename, script_filename, sizeof(proc->script_filename)); } fpm_scoreboard_proc_release(proc); }
// 初始化fpm_request_info void fpm_request_info() /* {{{ */ { TSRMLS_FETCH(); // 记分牌,记录请求的相关信息 struct fpm_scoreboard_proc_s *proc; //从SG全局变量中拿各种数据 /* * uri * method * filename * query_string * 等等 */ char *request_uri = fpm_php_request_uri(TSRMLS_C); char *request_method = fpm_php_request_method(TSRMLS_C); char *script_filename = fpm_php_script_filename(TSRMLS_C); char *query_string = fpm_php_query_string(TSRMLS_C); char *auth_user = fpm_php_auth_user(TSRMLS_C); size_t content_length = fpm_php_content_length(TSRMLS_C); struct timeval now; fpm_clock_get(&now); // 拿到进程,加锁 proc = fpm_scoreboard_proc_acquire(NULL, -1, 0); if (proc == NULL) { zlog(ZLOG_WARNING, "failed to acquire proc scoreboard"); return; } proc->request_stage = FPM_REQUEST_INFO; proc->tv = now; if (request_uri) { strlcpy(proc->request_uri, request_uri, sizeof(proc->request_uri)); } if (request_method) { // post, get, delete, or... strlcpy(proc->request_method, request_method, sizeof(proc->request_method)); } if (query_string) { strlcpy(proc->query_string, query_string, sizeof(proc->query_string)); } if (auth_user) { strlcpy(proc->auth_user, auth_user, sizeof(proc->auth_user)); } proc->content_length = content_length; /* if cgi.fix_pathinfo is set to "1" and script cannot be found (404) the sapi_globals.request_info.path_translated is set to NULL */ if (script_filename) { strlcpy(proc->script_filename, script_filename, sizeof(proc->script_filename)); } // 释放锁 fpm_scoreboard_proc_release(proc); }