fix: random crashes when reloading (#394)

This commit is contained in:
Kévin Dunglas 2023-12-18 09:05:49 +01:00 committed by GitHub
parent ebd5b45dda
commit 517e086786
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 0 deletions

View File

@ -53,6 +53,17 @@ jobs:
name: Run Caddy module tests
working-directory: caddy/
run: go test -race -v ./...
-
name: Build the server
working-directory: caddy/frankenphp/
run: go build
-
name: Start the server
working-directory: testdata/
run: sudo ../caddy/frankenphp/frankenphp start
-
name: Run integrations tests
run: ./reload_test.sh
-
name: Lint Go code
uses: golangci/golangci-lint-action@v3

View File

@ -528,6 +528,8 @@ static void bsem_init(bsem *bsem_p, int value) {
/* Reset semaphore to 0 */
static void bsem_reset(bsem *bsem_p) {
pthread_mutex_destroy(&(bsem_p->mutex));
pthread_cond_destroy(&(bsem_p->cond));
bsem_init(bsem_p, 0);
}

View File

@ -15,6 +15,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "C-Thread-Pool/thpool.c"
#include "C-Thread-Pool/thpool.h"

4
reload_test.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
for ((i = 0 ; i < 100 ; i++)); do
curl --no-progress-meter -o /dev/null http://localhost:2019/config/apps/frankenphp -: --no-progress-meter -o /dev/null -H 'Cache-Control: must-revalidate' -H 'Content-Type: application/json' --data-binary '{"workers":[{"file_name":"./index.php"}]}' -X PATCH http://localhost:2019/config/apps/frankenphp
done