Changeset ee0e95f in code
- Timestamp:
- Mar 31, 2014, 2:14:10 PM (11 years ago)
- Branches:
- master
- Children:
- dab4135
- Parents:
- cdd2ff5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
rcdd2ff5 ree0e95f 11 11 CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare 12 12 13 # hook up asynchronous resolver14 CFLAGS+= -I${BSDSRCDIR}/lib/libc/asr15 16 13 DPADD= ${LIBEVENT} 17 14 LDADD= -levent -
dns.c
rcdd2ff5 ree0e95f 24 24 #include <sys/time.h> 25 25 #include <netinet/in.h> 26 #include <netdb.h> 26 27 #include <errno.h> 27 28 #include <event.h> … … 31 32 #include <syslog.h> 32 33 33 #include "asr.h"34 #include <asr.h> 34 35 35 36 #include "icb.h" … … 37 38 38 39 struct async_event; 39 struct async_event *async_run_event(struct as ync*,40 void (*)( int, struct async_res*, void *), void *);41 void dns_done( int, struct async_res*, void *);40 struct async_event *async_run_event(struct asr_query *, 41 void (*)(struct asr_result *, void *), void *); 42 void dns_done(struct asr_result *, void *); 42 43 43 44 extern int dodns; 44 45 45 46 void 46 dns_done( int ev __attribute__((__unused__)), struct async_res*ar, void *arg)47 dns_done(struct asr_result *ar, void *arg) 47 48 { 48 49 struct icb_session *is = arg; … … 64 65 dns_rresolv(struct icb_session *is, struct sockaddr *sa) 65 66 { 66 struct as ync*as;67 struct asr_query *as; 67 68 68 69 if (!dodns) … … 80 81 81 82 struct async_event { 82 struct as ync*async;83 struct asr_query *async; 83 84 struct event ev; 84 void (*callback)( int, struct async_res*, void *);85 void (*callback)(struct asr_result *, void *); 85 86 void *arg; 86 87 }; … … 89 90 90 91 struct async_event * 91 async_run_event(struct as ync *async,92 void (*cb)( int, struct async_res*, void *), void *arg)92 async_run_event(struct asr_query *async, 93 void (*cb)(struct asr_result *, void *), void *arg) 93 94 { 94 95 struct async_event *aev; … … 113 114 { 114 115 struct async_event *aev = arg; 115 struct async_res ar; 116 int r; 116 struct asr_result ar; 117 117 struct timeval tv; 118 118 119 while ((r = asr_async_run(aev->async, &ar)) == ASYNC_YIELD) 120 aev->callback(r, &ar, aev->arg); 119 event_del(&aev->ev); 121 120 122 event_del(&aev->ev); 123 if (r == ASYNC_COND) { 121 if (asr_run(aev->async, &ar) == 0) { 124 122 event_set(&aev->ev, ar.ar_fd, 125 ar.ar_cond == ASYNC_READ ? EV_READ : EV_WRITE,126 123 ar.ar_cond == ASR_WANT_READ ? EV_READ : EV_WRITE, 124 async_event_dispatch, aev); 127 125 tv.tv_sec = ar.ar_timeout / 1000; 128 126 tv.tv_usec = (ar.ar_timeout % 1000) * 1000; 129 127 event_add(&aev->ev, &tv); 130 } else { /* ASYNC_DONE*/131 aev->callback( r,&ar, aev->arg);128 } else { /* done */ 129 aev->callback(&ar, aev->arg); 132 130 free(aev); 133 131 }
Note:
See TracChangeset
for help on using the changeset viewer.