Request processing in two major processes of the PHP kernel. Two major processes of PHP kernel: request processing staticintphp_handler (request_rec * r) {* Initiliazethecontext * php_struct * volatilectx; void * conf; apr_bucket_brigade * volatilebrigad PHP kernel request processing
Static int php_handler (request_rec * r) {/* Initiliaze the context */php_struct * volatile ctx; void * conf; *** volatile brigade; apr_bucket * bucket; apr_status_t rv; request_rec * volatile parent_req = NULL; TSRMLS_FETCH ();...... zend_file_handle zfd; zfd. type = ZEND_HANDLE_FILENAME; zfd. filename = (char *) r-> filename; zfd. free_filename = 0; zfd. opened_path = NULL; zend_execute_scripts (ZEND_INCLUDE TSRMLS_CC, NULL, 1, & zfd );......} ZEND_API int zend_execute_scripts (int type TSRMLS_DC, zval ** retval, int file_count ,...) /*{{{*/{...... EG (active_op_array) = \ zend_compile_file (file_handle, type TSRMLS_CC );...... zend_execute (EG (active_op_array) TSRMLS_CC );......} ZEND_API void execute (zend_op_array * op_array TSRMLS_DC) {// Initialization execution context zend_execute_data execute_data; // exit execution if (EG (exception) {return ;} /* Initialize execute_data */EX (fbc) = NULL; // Initialize the calling function EX (object) = NULL; // Initialize the calling object EX (old_error_reporting) = NULL; // Initialization error report variable // allocate space for the execution stack if (op_array-> T <TEMP_VAR_STACK_LIMIT) {EX (Ts) = (temp_variable *) do_alloca (sizeof (temp_variable) * op_array-> T);} else {EX (Ts) = (temp_variable *) safe_emalloc (sizeof (temp_variable), op_array-> T, 0);} // allocate space for temporary variables and initialize these spaces EX (CVs) = (zval ***) do_alloca (sizeof (zval **) * op_array-> last_var); memset (EX (CVs), 0, sizeof (zval **) * op_array-> last_var); EX (op_array) = op_array; // switch the execution context EX (original_in_execution) = EG (in_execution); EX (symbol_table) = EG (active_symbol_table); EX (prev_execute_data) = EG (current_execute_data ); // Press the execution data in the current global variable to stack EG (current_execute_data) = & execute_data; // Press the current execution context to stack EG (in_execution) = 1; // initialize the First Command (opcode)/* # define ZEND_VM_SET_OPCODE (new_op) \ CHECK_SYMBOL_TABLES () \ EX (opline) = new_op execute_data.opline is the currently executed opcode */if (op_array-> start_op) {runtime (op_array-> start_op);} else {ZEND_VM_SET_OPCODE (op_array-> opcodes );} if (op_array-> uses_this & EG (This) {EG (This)-> refcount ++; /* For $ this pointer */if (zend_hash_add (EG (active_symbol_table), "this", sizeof ("this"), & EG (This), sizeof (zval *), NULL) = FAILURE) {EG (This)-> refcount --;} // assigns the memory address of the opline to executor_globals.online_ptr, which can track the opcode execution in real time (opline_ptr) = & EX (opline); EX (function_state ). function = (zend_function *) op_array; EG (function_state_ptr) = & EX (function_state); # if ZEND_DEBUG/* function_state.function_symbol_table is saved as-is to a stack, * which is an intentional UMR. shut it up if we're re in DEBUG. */EX (function_state ). function_symbol_table = NULL; # endif while (1) {# ifdef ZEND_WIN32 if (EG (timed_out) {zend_timeout (0) ;}# endif // calls the handler function of each opline cyclically, if the return value is greater than 0, exit if (EX (opline)-> handler (& execute_data TSRMLS_CC)> 0) {return ;}} zend_error_noreturn (E_ERROR, "Arrived at end of main loop which shouldn't happen ");}
Using static int php_handler (request_rec * r) {/* Initiliaze the context */php_struct * volatile ctx; void * conf; apr_bucket_brigade * volatile brigad...