diff --git a/philo/philo_routine.c b/philo/philo_routine.c index ad413c1..d88ad04 100644 --- a/philo/philo_routine.c +++ b/philo/philo_routine.c @@ -6,7 +6,7 @@ /* By: cchauvet stop_mutex); - philo->stop = 1; - pthread_mutex_unlock(&philo->stop_mutex); -} - bool check(t_philo *philo, t_data *data) { bool stop; @@ -106,12 +99,14 @@ void *philo_routine(void *arg) while (true) { if (check(philo, data) - || philo_eat(philo, data) - || check(philo, data) - || philo_sleep(data, philo) - || check(philo, data)) + || philo_eat(philo, data) + || check(philo, data) + || philo_sleep(data, philo) + || check(philo, data)) { - philo_stop(philo); + pthread_mutex_lock(&philo->stop_mutex); + philo->stop = 1; + pthread_mutex_unlock(&philo->stop_mutex); return (NULL); } print_thinking(philo);