|
|
| version 1.1, 2012/02/21 23:02:54 | version 1.1.1.1.2.1, 2013/07/22 01:09:34 |
|---|---|
| Line 158 typedef unsigned int uint; | Line 158 typedef unsigned int uint; |
| #define CLASS_INET EVDNS_CLASS_INET | #define CLASS_INET EVDNS_CLASS_INET |
| #ifdef HAVE_SETFD | |
| #define FD_CLOSEONEXEC(x) do { \ | |
| if (fcntl(x, F_SETFD, 1) == -1) \ | |
| event_warn("fcntl(%d, F_SETFD)", x); \ | |
| } while (0) | |
| #else | |
| #define FD_CLOSEONEXEC(x) (void)0 | |
| #endif | |
| struct request { | struct request { |
| u8 *request; /* the dns packet data */ | u8 *request; /* the dns packet data */ |
| unsigned int request_len; | unsigned int request_len; |
| Line 1099 evdns_set_transaction_id_fn(ev_uint16_t (*fn)(void)) | Line 1108 evdns_set_transaction_id_fn(ev_uint16_t (*fn)(void)) |
| static u16 | static u16 |
| transaction_id_pick(void) { | transaction_id_pick(void) { |
| for (;;) { | for (;;) { |
| const struct request *req = req_head, *started_at; | |
| u16 trans_id = trans_id_function(); | u16 trans_id = trans_id_function(); |
| if (trans_id == 0xffff) continue; | if (trans_id == 0xffff) continue; |
| /* now check to see if that id is already inflight */ | |
| req = started_at = req_head; | if (request_find_from_trans_id(trans_id) == NULL) |
| if (req) { | return trans_id; |
| do { | |
| if (req->trans_id == trans_id) break; | |
| req = req->next; | |
| } while (req != started_at); | |
| } | |
| /* we didn't find it, so this is a good id */ | |
| if (req == started_at) return trans_id; | |
| } | } |
| } | } |
| Line 2132 _evdns_nameserver_add_impl(unsigned long int address, | Line 2133 _evdns_nameserver_add_impl(unsigned long int address, |
| ns->socket = socket(PF_INET, SOCK_DGRAM, 0); | ns->socket = socket(PF_INET, SOCK_DGRAM, 0); |
| if (ns->socket < 0) { err = 1; goto out1; } | if (ns->socket < 0) { err = 1; goto out1; } |
| evutil_make_socket_nonblocking(ns->socket); | FD_CLOSEONEXEC(ns->socket); |
| evutil_make_socket_nonblocking(ns->socket); | |
| ns->address = address; | ns->address = address; |
| ns->port = htons(port); | ns->port = htons(port); |