Skip to content

Commit

Permalink
Bugfixes in front-end
Browse files Browse the repository at this point in the history
- prevent duplicated results in getConnectedNodes()
- fix the 'leftover bubble' issue when ignoring nodes
- fix 'set name' issue
  • Loading branch information
Jelte Jansen committed Sep 30, 2017
1 parent 3a75f3a commit fe23ff4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 92 deletions.
9 changes: 7 additions & 2 deletions html/js/spingraphs.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function initGraphs() {
sendCommand("add_name", argument); // talk to Websocket

node.label = newname;
node.name = newname;
nodes.update(node);
}

Expand Down Expand Up @@ -868,7 +869,9 @@ function getConnectedNodes(nodeId) {
});
for (var i=0; i < cedges.length; i++) {
var edge = cedges[i];
result.push(edge.to);
if (!contains(result, edge.to)) {
result.push(edge.to);
}
}
cedges = edges.get({
filter: function(item) {
Expand All @@ -877,7 +880,9 @@ function getConnectedNodes(nodeId) {
});
for (var i=0; i < cedges.length; i++) {
var edge = cedges[i];
result.push(edge.from);
if (!contains(result, edge.from)) {
result.push(edge.from);
}
}
return result;
}
Expand Down
28 changes: 0 additions & 28 deletions kernelmod/spin_traffic_send_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,29 +294,21 @@ traffic_clients_t* traffic_clients_create(struct sock* traffic_nl_sk) {
void traffic_clients_destroy(traffic_clients_t* traffic_clients) {
// stop anny running client, then free up the data
int i = 0;
printk("[XX] stopping all clients %p\n", traffic_clients);
while (!down_write_trylock(&traffic_clients->sem)) {
printk("[XX] locked, waiting\n");
msleep(1000);
}
for (i = 0; i < traffic_clients->count; i++) {
printk("[XX] stopping all clients count %d\n", traffic_clients->count);
// todo: _destroy for traffic_client_t
// stop thread from destructor or here/separately?
printk("[XX] stopping client nr %d\n", i);
printk("[XX] stopping client at %p\n", traffic_clients->clients[i]);
up_write(&traffic_clients->sem);
while (!down_write_trylock(&traffic_clients->clients[i]->sem)) {
printk("[XX] client locked, waiting\n");
msleep(1000);
}
traffic_client_stop(traffic_clients->clients[i]);
up_write(&traffic_clients->clients[i]->sem);
while (!down_write_trylock(&traffic_clients->sem)) {
printk("[XX] locked, waiting\n");
msleep(1000);
}
printk("[XX] client stopped\n");
//traffic_client_destroy(traffic_clients->clients[i]);
}
up_write(&traffic_clients->sem);
Expand All @@ -326,7 +318,6 @@ void traffic_clients_destroy(traffic_clients_t* traffic_clients) {
int traffic_clients_add(traffic_clients_t* traffic_clients, uint32_t client_port_id) {
int i;
int count;
int j;
printv(4, KERN_INFO "add traffic client %u\n", client_port_id);
while (!down_read_trylock(&traffic_clients->sem)) {
msleep(1000);
Expand All @@ -349,11 +340,6 @@ int traffic_clients_add(traffic_clients_t* traffic_clients, uint32_t client_port
traffic_clients->clients[traffic_clients->count] = traffic_client_create(traffic_clients, traffic_clients->traffic_nl_sk, client_port_id);
printv(4, KERN_INFO "created data handler for client %d at %p\n", traffic_clients->count, traffic_clients->clients[traffic_clients->count]);
traffic_clients->count++;
printk("[XX] client count now: %d\n", traffic_clients->count);
printk("[XX] clients i have after add: %d\n", traffic_clients->count);
for (j =0 ; j < traffic_clients->count; j++) {
printk("[XX] %d: %d\n", j, traffic_clients->clients[j]->client_port_id);
}
up_write(&traffic_clients->sem);
return i;
} else {
Expand All @@ -365,10 +351,7 @@ int traffic_clients_add(traffic_clients_t* traffic_clients, uint32_t client_port
int traffic_clients_remove(traffic_clients_t* traffic_clients, uint32_t client_port_id) {
int found = 0;
int i = 0;
int j;
printk("[XX] remove traffic client %u\n", client_port_id);
while (!down_write_trylock(&traffic_clients->sem)) {
printk("[XX] clients locked, waiting to remove (%d)\n", i);
msleep(1000);
i++;
if (i >= 5) {
Expand Down Expand Up @@ -398,17 +381,8 @@ int traffic_clients_remove(traffic_clients_t* traffic_clients, uint32_t client_p
}
if (found) {
printv(4, KERN_INFO "client removed. count now %u\n", traffic_clients->count);
printk("[XX] client %d remove, count now: %d\n", client_port_id, traffic_clients->count);
printk("[XX] clients i have after removal: %d\n", traffic_clients->count);
for (j =0 ; j < traffic_clients->count; j++) {
printk("[XX] %d: %d\n", j, traffic_clients->clients[j]->client_port_id);
}
} else {
printv(4, KERN_INFO "client was not found\n");
printk("[XX] clients i have still: %d\n", traffic_clients->count);
for (j =0 ; j < traffic_clients->count; j++) {
printk("[XX] %d: %d\n", j, traffic_clients->clients[j]->client_port_id);
}
}
up_write(&traffic_clients->sem);
return found;
Expand All @@ -422,7 +396,6 @@ void traffic_clients_send(traffic_clients_t* traffic_clients, int msg_size, void
int i;
// add it to all queues
if (!down_read_trylock(&traffic_clients->sem)) {
printk("[XX] clients list locked, not sending data\n");
return;
}
for (i = 0; i < traffic_clients->count; i++) {
Expand All @@ -439,7 +412,6 @@ void traffic_clients_send(traffic_clients_t* traffic_clients, int msg_size, void
printv(5, KERN_DEBUG "queue size for %u: %lu\n", traffic_clients->clients[i]->client_port_id, send_queue_size(traffic_clients->clients[i]->send_queue));

if (!down_read_trylock(&traffic_clients->sem)) {
printk("[XX] clients list locked, not sending data\n");
return;
}
}
Expand Down
8 changes: 1 addition & 7 deletions lua/spin_enforcer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,12 @@ function history_stats()
local ports = {}
local dests = {}

--print("[XX] " .. json.encode(nodes))
for frm,a in pairs(nodes) do
print("[XX] DEVICE: " .. frm .. "(" .. squash_node_info(node_info[frm]) ..")")
local size_count = 0
local port_count = 0
local port_most_used = nil
local to_count = 0
for to,b in pairs(a) do
--print(" " .. squash_node_info(node_info[to]))
to_count = to_count + 1
for port,size in pairs(b) do
if ports[port] == nil then
Expand All @@ -136,7 +133,6 @@ function history_stats()
port_most_used = port
end
end
--print("[XX] " .. squash_node_info(node_info[frm]) .. " -> " .. squash_node_info(node_info[to]) .. " " .. port .. " " .. size)
end
end
print(" contacted " .. to_count .. " external nodes")
Expand All @@ -151,7 +147,7 @@ function history_stats()
i = i + 1
if i >= 10 then break end
end
if (port_count) > 40 then
if (port_count) > 200 then
block_node(node_info[frm])
end

Expand Down Expand Up @@ -236,7 +232,6 @@ function history_clean()
end

function handle_traffic_message(payload)
--print(json.encode(payload))
local timestamp = payload["timestamp"]
history[timestamp] = payload["flows"]
history_clean()
Expand All @@ -262,7 +257,6 @@ while true do
--history_print()
--history_stats_full()
history_stats()
print("")
last_print = cur
end

Expand Down
Loading

0 comments on commit fe23ff4

Please sign in to comment.