1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-01 20:38:14 +00:00

Check permission to set fan speed before actually doing it, otherwise X11 becomes mad and drops the connection

This commit is contained in:
jsteube 2016-06-18 14:42:57 +02:00
parent e43be7aba3
commit 6a2ec331ef

View File

@ -114,14 +114,18 @@ int set_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int val)
{ {
if (xnvctrl->dpy == NULL) return -1; if (xnvctrl->dpy == NULL) return -1;
xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val);
int cur; int cur;
int rc = get_fan_control (xnvctrl, gpu, &cur); int rc = get_fan_control (xnvctrl, gpu, &cur);
if (rc == -1) return -1; if (rc == -1) return -1;
xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val);
rc = get_fan_control (xnvctrl, gpu, &cur);
if (rc == -1) return -1;
if (cur != val) return -1; if (cur != val) return -1;
return 0; return 0;
@ -140,6 +144,8 @@ int get_core_threshold (XNVCTRL_PTR *xnvctrl, int gpu, int *val)
int get_fan_speed_current (XNVCTRL_PTR *xnvctrl, int gpu, int *val) int get_fan_speed_current (XNVCTRL_PTR *xnvctrl, int gpu, int *val)
{ {
if (xnvctrl->dpy == NULL) return -1;
int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL, val); int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL, val);
if (!rc) return -1; if (!rc) return -1;
@ -162,14 +168,18 @@ int set_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int val)
{ {
if (xnvctrl->dpy == NULL) return -1; if (xnvctrl->dpy == NULL) return -1;
xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val);
int cur; int cur;
int rc = get_fan_speed_target (xnvctrl, gpu, &cur); int rc = get_fan_speed_target (xnvctrl, gpu, &cur);
if (rc == -1) return -1; if (rc == -1) return -1;
xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val);
rc = get_fan_speed_target (xnvctrl, gpu, &cur);
if (rc == -1) return -1;
if (cur != val) return -1; if (cur != val) return -1;
return 0; return 0;