aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2010-08-05 17:56:41 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2010-08-05 17:56:41 +0000
commit50692f84c6f8b324e31b8e12620e9b8fd879c1e1 (patch)
tree48b475c8b7ae21f32d97a4a4382177b6c20ca836 /sbin
parente2865ebbc237ef9b0940ccfc5c61ed4a6b150e52 (diff)
downloadsrc-50692f84c6f8b324e31b8e12620e9b8fd879c1e1.tar.gz
src-50692f84c6f8b324e31b8e12620e9b8fd879c1e1.zip
Add an argument to the proto_register() function which allows protocol to
declare it is the default and be placed at the end of the queue so it is checked last. MFC after: 1 month
Notes
Notes: svn path=/head/; revision=210869
Diffstat (limited to 'sbin')
-rw-r--r--sbin/hastd/proto.c17
-rw-r--r--sbin/hastd/proto_impl.h4
-rw-r--r--sbin/hastd/proto_socketpair.c2
-rw-r--r--sbin/hastd/proto_tcp4.c2
-rw-r--r--sbin/hastd/proto_uds.c2
5 files changed, 17 insertions, 10 deletions
diff --git a/sbin/hastd/proto.c b/sbin/hastd/proto.c
index 531e7e5fc059..8f003de6fdde 100644
--- a/sbin/hastd/proto.c
+++ b/sbin/hastd/proto.c
@@ -52,13 +52,20 @@ struct proto_conn {
#define PROTO_SIDE_SERVER_WORK 2
};
-static LIST_HEAD(, hast_proto) protos = LIST_HEAD_INITIALIZER(protos);
+static TAILQ_HEAD(, hast_proto) protos = TAILQ_HEAD_INITIALIZER(protos);
void
-proto_register(struct hast_proto *proto)
+proto_register(struct hast_proto *proto, bool isdefault)
{
-
- LIST_INSERT_HEAD(&protos, proto, hp_next);
+ static bool seen_default = false;
+
+ if (!isdefault)
+ TAILQ_INSERT_HEAD(&protos, proto, hp_next);
+ else {
+ assert(!seen_default);
+ seen_default = true;
+ TAILQ_INSERT_TAIL(&protos, proto, hp_next);
+ }
}
static int
@@ -75,7 +82,7 @@ proto_common_setup(const char *addr, struct proto_conn **connp, int side)
if (conn == NULL)
return (-1);
- LIST_FOREACH(proto, &protos, hp_next) {
+ TAILQ_FOREACH(proto, &protos, hp_next) {
if (side == PROTO_SIDE_CLIENT)
ret = proto->hp_client(addr, &ctx);
else /* if (side == PROTO_SIDE_SERVER_LISTEN) */
diff --git a/sbin/hastd/proto_impl.h b/sbin/hastd/proto_impl.h
index ea6548d58042..f0dfadd5836b 100644
--- a/sbin/hastd/proto_impl.h
+++ b/sbin/hastd/proto_impl.h
@@ -64,10 +64,10 @@ struct hast_proto {
hp_local_address_t *hp_local_address;
hp_remote_address_t *hp_remote_address;
hp_close_t *hp_close;
- LIST_ENTRY(hast_proto) hp_next;
+ TAILQ_ENTRY(hast_proto) hp_next;
};
-void proto_register(struct hast_proto *proto);
+void proto_register(struct hast_proto *proto, bool isdefault);
int proto_common_send(int fd, const unsigned char *data, size_t size);
int proto_common_recv(int fd, unsigned char *data, size_t size);
diff --git a/sbin/hastd/proto_socketpair.c b/sbin/hastd/proto_socketpair.c
index 08d0c667a069..0d040f394540 100644
--- a/sbin/hastd/proto_socketpair.c
+++ b/sbin/hastd/proto_socketpair.c
@@ -271,5 +271,5 @@ static __constructor void
sp_ctor(void)
{
- proto_register(&sp_proto);
+ proto_register(&sp_proto, false);
}
diff --git a/sbin/hastd/proto_tcp4.c b/sbin/hastd/proto_tcp4.c
index 5af82d531853..09e9e653915d 100644
--- a/sbin/hastd/proto_tcp4.c
+++ b/sbin/hastd/proto_tcp4.c
@@ -515,5 +515,5 @@ static __constructor void
tcp4_ctor(void)
{
- proto_register(&tcp4_proto);
+ proto_register(&tcp4_proto, true);
}
diff --git a/sbin/hastd/proto_uds.c b/sbin/hastd/proto_uds.c
index 0fac82f24d06..cd7292674911 100644
--- a/sbin/hastd/proto_uds.c
+++ b/sbin/hastd/proto_uds.c
@@ -326,5 +326,5 @@ static __constructor void
uds_ctor(void)
{
- proto_register(&uds_proto);
+ proto_register(&uds_proto, false);
}