Просмотр исходного кода

Applies suggestions by @dunglas

Alliballibaba 3 месяцев назад
Родитель
Сommit
c080608661
5 измененных файлов с 9 добавлено и 5 удалено
  1. 2 0
      frankenphp.c
  2. 1 0
      frankenphp.h
  3. 1 1
      frankenphp_arginfo.h
  4. 4 3
      phpmainthread.go
  5. 1 1
      testdata/transition-regular.php

+ 2 - 0
frankenphp.c

@@ -823,6 +823,7 @@ static void *php_thread(void *arg) {
   ZEND_TSRMLS_CACHE_UPDATE();
 #endif
 #endif
+
   local_ctx = malloc(sizeof(frankenphp_server_context));
 
   /* check if a default filter is set in php.ini and only filter if
@@ -928,6 +929,7 @@ int frankenphp_new_main_thread(int num_threads) {
       0) {
     return -1;
   }
+
   return pthread_detach(thread);
 }
 

+ 1 - 0
frankenphp.h

@@ -53,6 +53,7 @@ int frankenphp_request_startup();
 int frankenphp_execute_script(char *file_name);
 
 int frankenphp_execute_script_cli(char *script, int argc, char **argv);
+
 int frankenphp_execute_php_function(const char *php_function);
 
 void frankenphp_register_variables_from_request_info(

+ 1 - 1
frankenphp_arginfo.h

@@ -49,4 +49,4 @@ static const zend_function_entry ext_functions[] = {
   ZEND_FALIAS(apache_response_headers, frankenphp_response_headers, arginfo_apache_response_headers)
   ZEND_FE_END
 };
-// clang-format on
+// clang-format on

+ 4 - 3
phpmainthread.go

@@ -3,8 +3,9 @@ package frankenphp
 // #include "frankenphp.h"
 import "C"
 import (
-	"fmt"
 	"sync"
+
+	"go.uber.org/zap"
 )
 
 // represents the main PHP thread
@@ -20,7 +21,7 @@ var (
 	mainThread *phpMainThread
 )
 
-// reserve a fixed number of PHP threads on the go side
+// reserve a fixed number of PHP threads on the Go side
 func initPHPThreads(numThreads int) error {
 	mainThread = &phpMainThread{
 		state:      newThreadState(),
@@ -45,7 +46,7 @@ func initPHPThreads(numThreads int) error {
 	for _, thread := range phpThreads {
 		go func() {
 			if !C.frankenphp_new_php_thread(C.uintptr_t(thread.threadIndex)) {
-				panic(fmt.Sprintf("unable to create thread %d", thread.threadIndex))
+				logger.Panic("unable to create thread", zap.Int("threadIndex", thread.threadIndex))
 			}
 			thread.state.waitFor(stateInactive)
 			ready.Done()

+ 1 - 1
testdata/transition-regular.php

@@ -1,3 +1,3 @@
 <?php
 
-echo "Hello from regular thread";
+echo "Hello from regular thread";