fix: philo alone died now

This commit is contained in:
Camille Chauvet 2023-04-25 14:56:57 +00:00
parent 02a80af93b
commit 69e34424c1

View File

@ -42,6 +42,12 @@ bool philo_eat(t_philo *philo, t_data *data)
pthread_mutex_unlock(&data->forks[philo->id]);
return (1);
}
while ((philo->id + 1) % data->nb_philos == philo->id)
if (check(philo, data))
{
pthread_mutex_unlock(&data->forks[philo->id]);
return (1);
}
pthread_mutex_lock(&data->forks[(philo->id + 1) % data->nb_philos]);
print_take_a_fork(philo);
if (check(philo, data))