Commit cfe49b99 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

queue requests

parent 454f21c1
<html>
<head>
<script src="js/jquery-2.2.3.min.js"></script>
<script src="jquery.ajax.queue.js"></script>
<script src="debugfs.js"></script>
<script src="js/bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="js/bootstrap/css/bootstrap.min.css"/>
......
......@@ -160,7 +160,7 @@ function fill_content(record,index,target){
l = "<tr class='"+oddeven+"'>";
l += " <td style='text-align:center' title='"+ttl+"'>"+record[j].lineno+"</td>";
l += " <td style='text-align:center'><input title='p-flag' type='checkbox' class='tp debug' "+checked+" file='"+record[j].file+"' line='"+record[j].lineno+"' index='"+index+"' subindex='"+j+"' /></td>";
l += " <td style='text-align:center'><input title='pflag' type='checkbox' class='tp debug' "+checked+" file='"+record[j].file+"' line='"+record[j].lineno+"' index='"+index+"' subindex='"+j+"' /></td>";
l += " <td title=\"function: "+record[j].function+"\">"+record[j].function.substr(0,20)+cut_function+"</td>";
l += " <td title=\"format: "+record[j].format+"\">"+record[j].format.substr(0,20)+cut_format+"</td>";
l += "</tr>";
......@@ -180,7 +180,8 @@ function fill_content_rebind_events(){
debugfs_data[index].configs[0].lines[subindex].flags = flags;
//console.log($(this).attr("file")+", "+$(this).attr("line")+", "+$(this).prop("checked"));
$.ajax({
url: "debugfs.php?cmd=echo&file="+$(this).attr("file")+"&line="+$(this).attr("line")+"&pflag="+$(this).prop("checked")
url: "debugfs.php?cmd=echo&file="+$(this).attr("file")+"&line="+$(this).attr("line")+"&flags="+flags,
queue: true
});
});
......@@ -189,7 +190,6 @@ function fill_content_rebind_events(){
var index = $(this).attr("index");
var checked = $(this).prop("checked");
$("#content_"+index).find(".debug").prop("checked",checked).change();
});
}
......
......@@ -121,14 +121,17 @@ function apply_config_to_control(){
echo "Done";
}
function sync_to_config($file,$line,$flag){
function sync_from_debugfs_to_config($file,$line,$flags,$sign){
global $tmp_config;
//$arr_debugfs = get_control("/sys/kernel/debug/dynamic_debug/control");
$arr_config = json_decode(file_get_contents($tmp_config),true);
foreach($arr_config as $k => $v){
if ($v['file']==$file) $dc = $k;
if ($v['file']==$file) {
$dc = $k;
break;
}
}
echo "DC=$dc\n";
......@@ -136,23 +139,28 @@ function sync_to_config($file,$line,$flag){
$tmp_arr1 = $arr_config[$dc]['configs'];
foreach($tmp_arr1 as $k => $v){
if ($v['state']==1) $dcc = $k;
if ($v['state']==1) {
$dcc = $k;
break;
}
}
$tmp_arr2 = $arr_config[$dc]['configs'][$dcc]['lines'];
foreach($tmp_arr2 as $k => $v){
if ($v['lineno']==$line) $dccc = $k;
if ($v['lineno']==$line) {
$dccc = $k;
break;
}
}
if ($flag=="+") $flag = "p";
if ($sign=="+") $flag = "p";
else $flag = "_";
$arr_config[$dc]['configs'][$dcc]['lines'][$dccc]['flags'] = $flag;
print_r($arr_config);
update_config(json_encode($arr_config));
//print_r($arr_config);
}
function filter_record_by_file($a,$f){
......@@ -195,18 +203,16 @@ if ($cmd=="do_nothing"){
if ($cmd=="echo") {
$file = $_GET['file'];
$line = $_GET['line'];
$flag = $_GET['pflag'];
$flags = $_GET['flags'];
//$config name
if ($flag=="true"){
$flag="+";
if (strpos($flags,"p")===FALSE){
$sign = "-p";
}else{
$flag="-";
$sign = "+";
}
exec("echo -n 'file $file line $line ${flag}p' > $DEBUGFSFILE");
sync_to_config($file,$line,$flag);
exec("echo -n 'file $file line $line ${sign}${flags}' > $DEBUGFSFILE");
sync_from_debugfs_to_config($file,$line,$flags,$sign);
}
$debugfs_configs = "debugfs_configs";
......
// credits: https://blog.alexmaccaw.com/queuing-ajax-requests
// Generated by CoffeeScript 1.6.2
(function() {
var $, next, push, queue, queues, remove, running;
$ = jQuery;
queues = {};
running = false;
queue = function(name) {
if (name === true) {
name = 'default';
}
return queues[name] || (queues[name] = []);
};
next = function(name) {
var deferred, list, options, _ref;
list = queue(name);
if (!list.length) {
running = false;
return;
}
_ref = list.shift(), options = _ref[0], deferred = _ref[1];
return $.ajax(options).always(function() {
return next(name);
}).done(function() {
return deferred.resolve.apply(deferred, arguments);
}).fail(function() {
return deferred.reject.apply(deferred, arguments);
});
};
push = function(name, options) {
var deferred, list;
list = queue(name);
deferred = $.Deferred();
list.push([options, deferred]);
if (!running) {
next(name);
}
running = true;
return deferred.promise();
};
remove = function(name, options) {
var i, list, value, _, _i, _len, _ref, _results;
list = queue(name);
_results = [];
for (i = _i = 0, _len = list.length; _i < _len; i = ++_i) {
_ref = list[i], value = _ref[0], _ = _ref[1];
if (!(value === options)) {
continue;
}
list.splice(i, 1);
break;
}
return _results;
};
$.ajaxTransport('+*', function(options) {
var queuedOptions;
if (options.queue) {
queuedOptions = $.extend({}, options);
queuedOptions.queue = false;
queuedOptions.processData = false;
return {
send: function(headers, complete) {
return push(options.queue, queuedOptions).done(function(data, textStatus, jqXHR) {
return complete(jqXHR.status, jqXHR.statusText, {
text: jqXHR.responseText
}, jqXHR.getAllResponseHeaders());
}).fail(function(jqXHR, textStatus, errorThrown) {
return complete(jqXHR.status, jqXHR.statusText, {
text: jqXHR.responseText
}, jqXHR.getAllResponseHeaders());
});
},
abort: function() {
return remove(options.queue, queuedOptions);
}
};
}
});
}).call(this);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment