while (total_bytes_recv < reply_len) {
bytes_recv = recv(sk, reply + 2, reply_len, 0);
if (bytes_recv < 0)
- return TRUE;
+ break;
total_bytes_recv += bytes_recv;
}
forward_dns_reply(reply, reply_len + 2, IPPROTO_TCP);
g_free(reply);
+
+ return FALSE;
}
return TRUE;
}
data = find_server(interface, domain, server, protocol);
- if (data)
+ if (data) {
+ if (data->watch > 0)
+ g_source_remove(data->watch);
+ data->watch = g_io_add_watch(data->channel,
+ G_IO_OUT | G_IO_IN | G_IO_HUP | G_IO_NVAL | G_IO_ERR,
+ tcp_server_event, data);
return data;
+ }
sk = socket(AF_INET, type, protocol);
if (sk < 0) {