Method: ADNS::Query#check

Defined in:
ext/adns/mod_adns.c

#checkHash, raises ADNS::NotReadyError

Check pending asynchronous request and retrieve answer or raises ADNS::NotReadyError, if request is still pending.

Returns:



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'ext/adns/mod_adns.c', line 357

static VALUE cQuery_check(VALUE self)
{
    rb_adns_query_t *rb_adq_r;
    adns_answer *answer_r;
    int ecode;
  
    Data_Get_Struct(self, rb_adns_query_t, rb_adq_r);
  if (rb_adq_r->answer != Qnil)
    return rb_adq_r->answer;
  if (!rb_adq_r->adq)
    rb_raise(mADNS__eQueryError, "invalid query");
  ecode = adns_check(rb_adq_r->rb_ads_r->ads, &rb_adq_r->adq, &answer_r, NULL);
  if (ecode)
    {
    if (ecode == EWOULDBLOCK)
      rb_raise(mADNS__eNotReadyError, strerror(ecode));
    else
        {
      rb_adq_r->adq = NULL;
      rb_raise(mADNS__eError, strerror(ecode));
    }
  }
  rb_adq_r->answer = rb_hash_new();
  rb_hash_aset(rb_adq_r->answer, CSTR2SYM("type"), INT2FIX(answer_r->type));
  rb_hash_aset(rb_adq_r->answer, CSTR2SYM("owner"), CSTR2STR(answer_r->owner));
  rb_hash_aset(rb_adq_r->answer, CSTR2SYM("status"), INT2FIX(answer_r->status));
  rb_hash_aset(rb_adq_r->answer, CSTR2SYM("expires"), INT2FIX(answer_r->expires));
  rb_hash_aset(rb_adq_r->answer, CSTR2SYM("answer"), parse_adns_answer(answer_r));
  rb_adq_r->adq = NULL; /* mark query as completed, thus making it invalid */
  return rb_adq_r->answer;
}