}
/* Read result from pipe */
- len = Resolve_Read(&Conf_Server[i].res_stat, dest_addrs, sizeof(dest_addrs));
+ len = Proc_Read(&Conf_Server[i].res_stat, dest_addrs, sizeof(dest_addrs));
if (len == 0)
return;
}
/* Read result from pipe */
- len = Resolve_Read(&My_Connections[i].proc_stat, readbuf, sizeof readbuf -1);
+ len = Proc_Read(&My_Connections[i].proc_stat, readbuf, sizeof readbuf -1);
if (len == 0)
return;
}
}
+/**
+ * Read bytes from a pipe of a forked child process.
+ */
+GLOBAL size_t
+Proc_Read(PROC_STAT *proc, void *buffer, size_t buflen)
+{
+ ssize_t bytes_read = 0;
+
+ assert(buffer != NULL);
+ assert(buflen > 0);
+
+ bytes_read = read(proc->pipe_fd, buffer, buflen);
+ if (bytes_read < 0) {
+ if (errno == EAGAIN)
+ return 0;
+ Log(LOG_CRIT, "Can't read from child process %ld: %s",
+ proc->pid, strerror(errno));
+ bytes_read = 0;
+ }
+#if DEBUG
+ else if (bytes_read == 0)
+ LogDebug("Can't read from child process %ld: EOF", proc->pid);
+#endif
+ Proc_Kill(proc);
+ return (size_t)bytes_read;
+}
+
/* -eof- */
GLOBAL void Proc_GenericSignalHandler PARAMS((int Signal));
+GLOBAL size_t Proc_Read PARAMS((PROC_STAT *proc, void *buffer, size_t buflen));
+
#endif
/* -eof- */
} /* Do_ResolveName */
-/**
- * Read result of resolver sub-process from pipe
- */
-GLOBAL size_t
-Resolve_Read( PROC_STAT *s, void* readbuf, size_t buflen)
-{
- ssize_t bytes_read;
-
- assert(buflen > 0);
-
- /* Read result from pipe */
- bytes_read = read(Proc_GetPipeFd(s), readbuf, buflen);
- if (bytes_read < 0) {
- if (errno == EAGAIN)
- return 0;
-
- Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror(errno));
- bytes_read = 0;
- }
-#ifdef DEBUG
- else if (bytes_read == 0)
- Log( LOG_DEBUG, "Resolver: Can't read result: EOF");
-#endif
- Proc_Kill(s);
- return (size_t)bytes_read;
-}
-
-
/* -eof- */
int identsock, void (*cbfunc) (int, short)));
GLOBAL bool Resolve_Name PARAMS((PROC_STAT * s, const char *Host,
void (*cbfunc) (int, short)));
-GLOBAL size_t Resolve_Read PARAMS((PROC_STAT * s, void *buf, size_t buflen));
#endif