Fix PHP communication with socket

This commit is contained in:
nemunaire 2014-12-28 11:13:50 +01:00
parent e8e0b4478b
commit 7865fbdf1f
2 changed files with 10 additions and 2 deletions

View File

@ -15,6 +15,7 @@ if (count($p) > 2)
case "init": case "init":
unlink($VAR["misc_dir"]."/challenge_started"); unlink($VAR["misc_dir"]."/challenge_started");
pipe_backend_scheduler("resetreset:HOME:all:SY");
break; break;
} }
} }

View File

@ -24,12 +24,19 @@ if (is_file($VAR["misc_dir"]."/challenge_started"))
function pipe_backend_scheduler($instruct) function pipe_backend_scheduler($instruct)
{ {
global $VAR;
$socket = socket_create(AF_UNIX, SOCK_STREAM, 0); $socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
if (is_writable($VAR["scheduler_socket"]) && socket_connect($socket, $VAR["scheduler_socket"])) if (is_writable($VAR["scheduler_socket"]) && socket_connect($socket, $VAR["scheduler_socket"]))
{ {
socket_write($socket, $instruct); socket_write($socket, $instruct);
socket_close($socket); socket_close($socket);
} }
else if(defined("DEBUG") && DEBUG)
{
print("Socket '".$VAR["scheduler_socket"]."' is not writable by ".$_SERVER["USER"]." user!");
exit(1);
}
} }
if (!empty($VAR['misc_dir'])) if (!empty($VAR['misc_dir']))