svn commit: r210869 - head/sbin/hastd
Pawel Jakub Dawidek
pjd at FreeBSD.org
Thu Aug 5 17:56:41 UTC 2010
Author: pjd
Date: Thu Aug 5 17:56:41 2010
New Revision: 210869
URL: http://svn.freebsd.org/changeset/base/210869
Log:
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
Modified:
head/sbin/hastd/proto.c
head/sbin/hastd/proto_impl.h
head/sbin/hastd/proto_socketpair.c
head/sbin/hastd/proto_tcp4.c
head/sbin/hastd/proto_uds.c
Modified: head/sbin/hastd/proto.c
==============================================================================
--- head/sbin/hastd/proto.c Thu Aug 5 17:48:37 2010 (r210868)
+++ head/sbin/hastd/proto.c Thu Aug 5 17:56:41 2010 (r210869)
@@ -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)
{
+ static bool seen_default = false;
- LIST_INSERT_HEAD(&protos, proto, hp_next);
+ 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, str
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) */
Modified: head/sbin/hastd/proto_impl.h
==============================================================================
--- head/sbin/hastd/proto_impl.h Thu Aug 5 17:48:37 2010 (r210868)
+++ head/sbin/hastd/proto_impl.h Thu Aug 5 17:56:41 2010 (r210869)
@@ -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);
Modified: head/sbin/hastd/proto_socketpair.c
==============================================================================
--- head/sbin/hastd/proto_socketpair.c Thu Aug 5 17:48:37 2010 (r210868)
+++ head/sbin/hastd/proto_socketpair.c Thu Aug 5 17:56:41 2010 (r210869)
@@ -271,5 +271,5 @@ static __constructor void
sp_ctor(void)
{
- proto_register(&sp_proto);
+ proto_register(&sp_proto, false);
}
Modified: head/sbin/hastd/proto_tcp4.c
==============================================================================
--- head/sbin/hastd/proto_tcp4.c Thu Aug 5 17:48:37 2010 (r210868)
+++ head/sbin/hastd/proto_tcp4.c Thu Aug 5 17:56:41 2010 (r210869)
@@ -515,5 +515,5 @@ static __constructor void
tcp4_ctor(void)
{
- proto_register(&tcp4_proto);
+ proto_register(&tcp4_proto, true);
}
Modified: head/sbin/hastd/proto_uds.c
==============================================================================
--- head/sbin/hastd/proto_uds.c Thu Aug 5 17:48:37 2010 (r210868)
+++ head/sbin/hastd/proto_uds.c Thu Aug 5 17:56:41 2010 (r210869)
@@ -326,5 +326,5 @@ static __constructor void
uds_ctor(void)
{
- proto_register(&uds_proto);
+ proto_register(&uds_proto, false);
}
More information about the svn-src-all
mailing list