summaryrefslogtreecommitdiffstats
path: root/lib/libnetgraph
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2006-01-12 19:14:40 +0000
committerglebius <glebius@FreeBSD.org>2006-01-12 19:14:40 +0000
commita8f06e957080a331d9ecc145c6607b6288af3659 (patch)
treeb2c0019bd35fabc0a5c9e34912a888b49f88722b /lib/libnetgraph
parent658b743414248c41e39ec8f375117931bc29b5e2 (diff)
downloadFreeBSD-src-a8f06e957080a331d9ecc145c6607b6288af3659.zip
FreeBSD-src-a8f06e957080a331d9ecc145c6607b6288af3659.tar.gz
In the splnet(9) times netgraph(4) was synchronous and if a message
had been replied, the reply was always delivered to the originator synchronously. With introduction of netgraph item callbacks and a wait channel with mutex in ng_socket(4), we have fixed the problem with ngctl(8) returning earlier than the command has been proceeded by target node. But still ngctl(8) can return prior to the reply has arrived to its node. To fix this: - Introduce a new flag for netgraph(4) messages - NGM_HASREPLY. This flag is or'ed with message like NGM_READONLY. - In netgraph userland library if we have sent a message with NGM_HASREPLY flag, then select(2) until reply comes. - Mark appropriate generic commands with NGM_HASREPLY flag, gathering them into one enum {}. Bump generic cookie.
Diffstat (limited to 'lib/libnetgraph')
-rw-r--r--lib/libnetgraph/msg.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/libnetgraph/msg.c b/lib/libnetgraph/msg.c
index cca9573..8b4ca06 100644
--- a/lib/libnetgraph/msg.c
+++ b/lib/libnetgraph/msg.c
@@ -232,6 +232,22 @@ NgDeliverMsg(int cs, const char *path,
goto done;
}
+ /* Wait for reply if there should be one. */
+ if (msg->header.cmd & NGM_HASREPLY) {
+ fd_set rfds;
+ int n;
+
+ FD_ZERO(&rfds);
+ FD_SET(cs, &rfds);
+ n = select(cs + 1, &rfds, NULL, NULL, NULL);
+ if (n == -1) {
+ errnosv = errno;
+ if (_gNgDebugLevel >= 1)
+ NGLOG("select");
+ rtn = -1;
+ }
+ }
+
done:
/* Done */
free(buf); /* OK if buf is NULL */
OpenPOWER on IntegriCloud