pike.git / lib / modules / Protocols.pmod / DNS.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/DNS.pmod:1861:   #define GIVE_UP_DELAY (RETRIES * RETRY_DELAY + REMOVE_DELAY)*2      // FIXME: Randomized source port!   //! Asynchronous DNS client.   class async_client   {    inherit client;    inherit Stdio.UDP : udp;    async_client next_client;    -  class Request +  class Request(string domain, string req, +  function(string,mapping,mixed...:void) callback, +  array(mixed) args)    { -  string req; -  string domain; -  function callback; +     int retries; -  int timestamp; -  array args; +  int timestamp = time(); +  +  void cancel() +  { +  remove(this_object()); +  }    };       mapping requests=([]);       protected private void remove(object(Request) r)    {    if(!r) return;    sscanf(r->req,"%2c",int id);    m_delete(requests,id);    r->callback(r->domain,0,@r->args);
pike.git/lib/modules/Protocols.pmod/DNS.pmod:1911:    function(string,mapping,mixed...:void) callback,    mixed ... args)    {    for(int e=next_client ? 100 : 256;e>=0;e--)    {    int lid = random(65536);    if(!catch { requests[lid]++; })    {    string req=low_mkquery(lid,domain,cl,type);    -  object r=Request(); -  r->req=req; -  r->domain=domain; -  r->callback=callback; -  r->args=args; -  r->timestamp=time(); +  object r = Request(domain, req, callback, args);    requests[lid]=r;    udp::send(nameservers[0],53,r->req);    call_out(retry,RETRY_DELAY,r,1);    return;    }    }       /* We failed miserably to find a request id to use,    * so we create a second UDP port to be able to have more    * requests 'in the air'. /Hubbe