+
+static void
+cb_Connect_to_Server(int fd, UNUSED short events)
+{
+ /* Read result of resolver sub-process from pipe and start connection */
+ int i;
+ size_t len;
+ char readbuf[HOST_LEN + 1];
+
+#ifdef DEBUG
+ Log( LOG_DEBUG, "Resolver: Got forward lookup callback on fd %d, events %d", fd, events);
+#endif
+ for (i=0; i < MAX_SERVERS; i++) {
+ if (Resolve_Getfd(&Conf_Server[i].res_stat) == fd )
+ break;
+ }
+
+ if( i >= MAX_SERVERS) {
+ /* Ops, no matching server found?! */
+ io_close( fd );
+#ifdef DEBUG
+ Log( LOG_DEBUG, "Resolver: Got Forward Lookup callback for unknown server!?" );
+#endif
+ return;
+ }
+
+ /* Read result from pipe */
+ len = Resolve_Read(&Conf_Server[i].res_stat, readbuf, sizeof readbuf -1);
+ if (len == 0)
+ return;
+
+ readbuf[len] = '\0';
+#ifdef DEBUG
+ Log( LOG_DEBUG, "Got result from resolver: \"%s\" (%u bytes read).", readbuf, len);
+#endif
+ strlcpy( Conf_Server[i].ip, readbuf, sizeof( Conf_Server[i].ip ));
+
+ /* connect() */
+ New_Server(i);
+} /* cb_Read_Forward_Lookup */
+
+