pike.git / lib / modules / Protocols.pmod / Bittorrent.pmod / DHT.test

version» Context lines:

pike.git/lib/modules/Protocols.pmod/Bittorrent.pmod/DHT.test:238:    ports[addr] = udp;    return 1;    }       int(0..1) send(string addr, int port, mapping msg)    {    addr += " " + port;    if (ports[addr]) {    if (!ports[addr]->lossyness ||    (Crypto.Random.random(256) >= ports[addr]->lossyness)) { +  if (!ports[addr]->lag) +  ports[addr]->internal_recv(msg); +  else    call_out(ports[addr]->internal_recv, ports[addr]->lag/65536.0, msg);    }    return 1;    }    return 0;    }       void close(string addr, int port)    {    m_delete(ports, addr + " " + port);
pike.git/lib/modules/Protocols.pmod/Bittorrent.pmod/DHT.test:349:    this_program::port->set_nonblocking(read_callback);    }   }      array(mapping) dhts = ({});   mapping(string:object) dhts_by_id = ([]);      System.Timer timer = System.Timer();   int good, bad;    - object mt; -  +    mixed state;      int test_state = 0;   void run_tests() {       switch(test_state) {    case 0:    state = ([    "nodes" : dhts->dht,    ]);
pike.git/lib/modules/Protocols.pmod/Bittorrent.pmod/DHT.test:380:    if (!q || !sizeof(q->result)) {    // Query failed somehow    bad++;    Tools.Testsuite.log_msg("Failed to perform bootstrap request on node %s\n",    String.string2hex(dht->get_node_id()));    run_tests();    return;    }    state->op = 0;    good++; -  run_tests(); +  call_out(run_tests, 0.0);    })->execute();    break;    } else {    test_state++;    }       case 2: // Announce    state = ([    "hashes" : String.hex2string(random_hashes[*]),    ]);
pike.git/lib/modules/Protocols.pmod/Bittorrent.pmod/DHT.test:526:       if (err) {    Tools.Testsuite.log_msg("Failed to bind port %d: %s\n", di->port, strerror(errno()));    Tools.Testsuite.report_result(0,1);    exit(4);    }    }       // At this point, we have a private DHT cloud we can work with.    -  mt = Thread.thread_create(run_tests); +  call_out(run_tests, 0.0);    return -1;   }