mirror of
https://github.com/osmarks/ngircd.git
synced 2024-12-12 09:50:29 +00:00
simplify Resolve_Read().
This commit is contained in:
parent
8423b89996
commit
939ee6a39b
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "portab.h"
|
#include "portab.h"
|
||||||
|
|
||||||
static char UNUSED id[] = "$Id: resolve.c,v 1.24 2006/05/10 21:24:01 alex Exp $";
|
static char UNUSED id[] = "$Id: resolve.c,v 1.25 2006/08/12 11:54:23 fw Exp $";
|
||||||
|
|
||||||
#include "imp.h"
|
#include "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -340,33 +340,24 @@ Resolve_Shutdown( RES_STAT *s)
|
|||||||
GLOBAL size_t
|
GLOBAL size_t
|
||||||
Resolve_Read( RES_STAT *s, void* readbuf, size_t buflen)
|
Resolve_Read( RES_STAT *s, void* readbuf, size_t buflen)
|
||||||
{
|
{
|
||||||
int err;
|
|
||||||
ssize_t bytes_read;
|
ssize_t bytes_read;
|
||||||
|
|
||||||
assert(buflen > 0);
|
assert(buflen > 0);
|
||||||
|
|
||||||
/* Read result from pipe */
|
/* Read result from pipe */
|
||||||
errno = 0;
|
|
||||||
bytes_read = read(s->resolver_fd, readbuf, buflen);
|
bytes_read = read(s->resolver_fd, readbuf, buflen);
|
||||||
if (bytes_read < 0) {
|
if (bytes_read < 0) {
|
||||||
if (errno != EAGAIN) {
|
if (errno == EAGAIN)
|
||||||
err = errno;
|
|
||||||
Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror(err));
|
|
||||||
Resolve_Shutdown(s);
|
|
||||||
errno = err;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Resolve_Shutdown(s);
|
Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror(errno));
|
||||||
if (bytes_read == 0) { /* EOF: lookup failed */
|
bytes_read = 0;
|
||||||
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
else if (bytes_read == 0)
|
||||||
Log( LOG_DEBUG, "Resolver: Can't read result: EOF");
|
Log( LOG_DEBUG, "Resolver: Can't read result: EOF");
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
Resolve_Shutdown(s);
|
||||||
}
|
|
||||||
|
|
||||||
return (size_t)bytes_read;
|
return (size_t)bytes_read;
|
||||||
}
|
}
|
||||||
/* -eof- */
|
/* -eof- */
|
||||||
|
Loading…
Reference in New Issue
Block a user