Skip to content

Commit

Permalink
fix deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
NaN-git committed Jan 26, 2017
1 parent 7cdea70 commit 4b3192d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sysfs-gpu-controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,8 @@ static int __set_fanspeed(gpu_sysfs_info *info, float fanpercent)
snprintf(speed_str, sizeof(speed_str), "%d", speed);
#ifdef __linux__
if (info->fd_fan != -1 && fanpercent >= 0.f) {
pthread_mutex_lock(&info->rw_lock);
lseek(info->fd_fan, 0, SEEK_SET);
ret = (write(info->fd_fan, speed_str, strlen(speed_str)) <= 0);
pthread_mutex_unlock(&info->rw_lock);
if (!ret)
info->target_fanpercent = fanpercent;
}
Expand All @@ -307,7 +305,9 @@ int sysfs_set_fanspeed(int gpu, float fanpercent)
if (has_sysfs_hwcontrols && gpus[gpu].has_sysfs_hwcontrols) {
gpu_sysfs_info *info = &gpus[gpu].sysfs_info;
applog(LOG_DEBUG, "GPU%d: set fanpercent to %.3g%%", gpu, fanpercent);
pthread_mutex_lock(&info->rw_lock);
ret = __set_fanspeed(info, fanpercent);
pthread_mutex_unlock(&info->rw_lock);
}
return ret;
}
Expand Down

0 comments on commit 4b3192d

Please sign in to comment.