Ejemplo n.º 1
0
static void
do_adns_free(adns_state s)
{
  adns_forallqueries_begin(s);

  if (adns_forallqueries_next(s, NULL))
    werror("Dropping queries on the floor.\n");

  adns_finish(s);
}
Ejemplo n.º 2
0
static void
do_adns_mark(adns_state s,
	     void (*mark)(struct lsh_object *o))
{
  adns_query q;
  void *ctx;
  
  adns_forallqueries_begin(s);
  
  while( (q = adns_forallqueries_next(s, &ctx)) )
    mark( (struct lsh_object *) ctx);
}
Ejemplo n.º 3
0
/* void dns_do_callbacks(void)
 * Input: None.
 * Output: None.
 * Side effects: Call all the callbacks(into the ircd core) for the
 *               results of a DNS resolution.
 */
void
dns_do_callbacks(void)
{
	adns_query q, r;
	adns_answer *answer;
	void *xr = &r;
	struct DNSQuery *query;
	void *xq = &query;
	int failure = 0;
	adns_forallqueries_begin(dns_state);

	while ((q = adns_forallqueries_next(dns_state, xr)) != NULL)
	{
		switch (adns_check(dns_state, &q, &answer, xq))
		{
		case 0:
			/* Looks like we got a winner */
			assert(query->callback != NULL);
			if(query->callback != NULL)
			{
				query->query = NULL;
				query->callback(query->ptr, answer);
			}
			break;

		case EAGAIN:
			/* Go into the queue again */
			continue;

		default:
			assert(query->callback != NULL);
			if(query->callback != NULL)
			{
				/* Awww we failed, what a shame */
				query->query = NULL;
				query->callback(query->ptr, NULL);
			}
			if(answer != NULL && answer->status == adns_s_systemfail)
				failure = 1;
			
			break;
		}
	}
        if(failure == 1)
        {       
	        sendto_realops_flags(UMODE_ALL, L_ALL, "adns got a global system failure..attempting to restart resolver");
                init_resolver();
        }
}
Ejemplo n.º 4
0
/* void dns_do_callbacks(void)
 * Input: None.
 * Output: None.
 * Side effects: Call all the callbacks(into the ircd core) for the
 *               results of a DNS resolution.
 */
void dns_do_callbacks(void)
{
  adns_query q, r;
  adns_answer *answer;
  struct DNSQuery *query;
  
  adns_forallqueries_begin(dns_state);
  
  while((q = adns_forallqueries_next(dns_state, (void **)&r)) != NULL)
  {
    switch(adns_check(dns_state, &q, &answer, (void **)&query))  
    {
      case 0:
        /* Looks like we got a winner */            
        assert(query->callback != NULL);
        if(query->callback != NULL)
        {
          query->query = NULL;
          query->callback(query->ptr, answer);
        }
        break;
	
      case EAGAIN:
        /* Go into the queue again */
        break;
	
      default:
        assert(query->callback != NULL);
        if(query->callback != NULL)
        {
          /* Awww we failed, what a shame */
          query->query = NULL;
          query->callback(query->ptr, NULL);      
        }
        break;
    } 
  }
}