Understand that a return value of 0 from NgRecvMsg() means that the

socket was closed.

This prevents erroneous ``Unexpected netgraph version'' from turning
up in the log.
This commit is contained in:
Brian Somers 2001-08-24 14:52:38 +00:00
parent fd048a1c8a
commit 321d268b28
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=82276

View File

@ -141,7 +141,7 @@ ConfigureNode(const char *prog, const char *iface, const char *provider,
/* Get our list back */
resp = (struct ng_mesg *)rbuf;
if (NgRecvMsg(cs, resp, sizeof rbuf, NULL) < 0) {
if (NgRecvMsg(cs, resp, sizeof rbuf, NULL) <= 0) {
perror("Cannot get netgraph response");
return EX_UNAVAILABLE;
}
@ -359,11 +359,17 @@ Spawn(const char *prog, const char *acname, const char *provider,
syslog(LOG_INFO, "Waiting for a SUCCESS reply %s", path);
do {
if (NgRecvMsg(cs, rep, sizeof msgbuf, NULL) < 0) {
if ((ret = NgRecvMsg(cs, rep, sizeof msgbuf, NULL) < 0)) {
syslog(LOG_ERR, "%s: Cannot receive a message: %m", path);
_exit(EX_OSERR);
}
if (ret == 0) {
/* The socket has been closed */
syslog(LOG_INFO, "%s: Client timed out", path);
_exit(EX_TEMPFAIL);
}
if (rep->header.version != NG_VERSION) {
syslog(LOG_ERR, "%ld: Unexpected netgraph version, expected %ld",
(long)rep->header.version, (long)NG_VERSION);