void* responderThread(void *p)
{
DownstreamState* state = (DownstreamState*)p;
- if(g_verbose)
- cout << "Added downstream server "<<state->remote.toStringWithPort()<<endl;
char packet[65536];
struct dnsheader* dh = (struct dnsheader*)packet;
chosen = n;
lowest=g_dstates[n].outstanding;
}
- }
-
+ }
return g_dstates[chosen];
}
void* udpClientThread(void* p)
{
ClientState* cs = (ClientState*) p;
- if(g_verbose)
- cout<<"Listening on "<<cs->local.toStringWithPort()<<endl;
ComboAddress remote;
remote.sin4.sin_family = cs->local.sin4.sin_family;
int getTCPDownstream(DownstreamState** ds)
{
*ds = &getBestDownstream();
- cout<<"TCP connecting to downstream "<<(*ds)->remote.toStringWithPort()<<endl;
+ if(g_verbose)
+ cout<<"TCP connecting to downstream "<<(*ds)->remote.toStringWithPort()<<endl;
int sock = SSocket((*ds)->remote.sin4.sin_family, SOCK_STREAM, 0);
SConnect(sock, (*ds)->remote);
return sock;
dss.idStates.resize(g_maxOutstanding);
+ if(g_verbose)
+ cout << "Added downstream server "<<dss.remote.toStringWithPort()<<endl;
+
pthread_create(&dss.tid, 0, responderThread, (void*)&dss);
}
SSetsockopt(cs->udpFD, IPPROTO_IPV6, IPV6_V6ONLY, 1);
}
SBind(cs->udpFD, cs->local);
+ if(g_verbose)
+ cout<<"Listening on "<<cs->local.toStringWithPort()<<endl;
+
pthread_create(&tid, 0, udpClientThread, (void*) cs);
}