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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/DNS.pmod:429:    }   }         class async_client   {    inherit client;    inherit spider.dumUDP : udp;    int id;    + #if constant(thread_create) +  object lock = Thread.Mutex(); + #endif /* constant(thread_create) */ +     class Request    {    string req;    string domain;    function callback;    int retries;    mixed *args;    };       mapping requests=([]);
pike.git/lib/modules/Protocols.pmod/DNS.pmod:471:    }       send(nameservers[nsno],53,r->req);    call_out(retry,5,r,nsno+1);    }       void do_query(string domain, int cl, int type,    function(string,mapping,mixed...:void) callback,    mixed ... args)    { + #if constant(thread_create) +  object key = lock->lock(); + #endif /* constant(thread_create) */    id++;    id&=65535; -  string req=low_mkquery(id,domain,cl,type); +  int lid = id;    -  if(requests[id]) + #if constant(thread_create) +  key = 0; + #endif /* constant(thread_create) */ +  +  if(requests[lid])    throw(({"Cannot find an empty request slot.\n",backtrace()})); -  +  +  string req=low_mkquery(lid,domain,cl,type); +     object r=Request();    r->req=req;    r->domain=domain;    r->callback=callback;    r->args=args; -  requests[id]=r; +  requests[lid]=r;    udp::send(nameservers[0],53,r->req);    call_out(retry,5,r,1);    }       static private void rec_data()    {    mapping m=udp::read();    if(m->port != 53 || search(nameservers, m->ip) == -1) return;    sscanf(m->data,"%2c",int id);    object r=requests[id];