outbound_list.c revision 238106
1238106Sdes/* 2238106Sdes * services/outbound_list.c - keep list of outbound serviced queries. 3238106Sdes * 4238106Sdes * Copyright (c) 2007, NLnet Labs. All rights reserved. 5238106Sdes * 6238106Sdes * This software is open source. 7238106Sdes * 8238106Sdes * Redistribution and use in source and binary forms, with or without 9238106Sdes * modification, are permitted provided that the following conditions 10238106Sdes * are met: 11238106Sdes * 12238106Sdes * Redistributions of source code must retain the above copyright notice, 13238106Sdes * this list of conditions and the following disclaimer. 14238106Sdes * 15238106Sdes * Redistributions in binary form must reproduce the above copyright notice, 16238106Sdes * this list of conditions and the following disclaimer in the documentation 17238106Sdes * and/or other materials provided with the distribution. 18238106Sdes * 19238106Sdes * Neither the name of the NLNET LABS nor the names of its contributors may 20238106Sdes * be used to endorse or promote products derived from this software without 21238106Sdes * specific prior written permission. 22238106Sdes * 23238106Sdes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24238106Sdes * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 25238106Sdes * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26238106Sdes * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 27238106Sdes * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28238106Sdes * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29238106Sdes * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30238106Sdes * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31238106Sdes * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32238106Sdes * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33238106Sdes * POSSIBILITY OF SUCH DAMAGE. 34238106Sdes */ 35238106Sdes 36238106Sdes/** 37238106Sdes * \file 38238106Sdes * 39238106Sdes * This file contains functions to help a module keep track of the 40238106Sdes * queries it has outstanding to authoritative servers. 41238106Sdes */ 42238106Sdes#include "config.h" 43238106Sdes#include <sys/time.h> 44238106Sdes#include "services/outbound_list.h" 45238106Sdes#include "services/outside_network.h" 46238106Sdes 47238106Sdesvoid 48238106Sdesoutbound_list_init(struct outbound_list* list) 49238106Sdes{ 50238106Sdes list->first = NULL; 51238106Sdes} 52238106Sdes 53238106Sdesvoid 54238106Sdesoutbound_list_clear(struct outbound_list* list) 55238106Sdes{ 56238106Sdes struct outbound_entry *p, *np; 57238106Sdes p = list->first; 58238106Sdes while(p) { 59238106Sdes np = p->next; 60238106Sdes outnet_serviced_query_stop(p->qsent, p); 61238106Sdes /* in region, no free needed */ 62238106Sdes p = np; 63238106Sdes } 64238106Sdes outbound_list_init(list); 65238106Sdes} 66238106Sdes 67238106Sdesvoid 68238106Sdesoutbound_list_insert(struct outbound_list* list, struct outbound_entry* e) 69238106Sdes{ 70238106Sdes if(list->first) 71238106Sdes list->first->prev = e; 72238106Sdes e->next = list->first; 73238106Sdes e->prev = NULL; 74238106Sdes list->first = e; 75238106Sdes} 76238106Sdes 77238106Sdesvoid 78238106Sdesoutbound_list_remove(struct outbound_list* list, struct outbound_entry* e) 79238106Sdes{ 80238106Sdes if(!e) 81238106Sdes return; 82238106Sdes outnet_serviced_query_stop(e->qsent, e); 83238106Sdes if(e->next) 84238106Sdes e->next->prev = e->prev; 85238106Sdes if(e->prev) 86238106Sdes e->prev->next = e->next; 87238106Sdes else list->first = e->next; 88238106Sdes /* in region, no free needed */ 89238106Sdes} 90