diff --git a/include/haproxy/protocol-t.h b/include/haproxy/protocol-t.h index 0419191ad..aa8aa662c 100644 --- a/include/haproxy/protocol-t.h +++ b/include/haproxy/protocol-t.h @@ -127,7 +127,7 @@ struct protocol { /* default I/O handler */ void (*default_iocb)(int fd); /* generic I/O handler (typically accept callback) */ - /* 4-byte hole here on 64-bit machines */ + uint flags; /* flags describing protocol support (PROTO_F_*) */ uint nb_receivers; /* number of receivers (under proto_lock) */ struct list receivers; /* list of receivers using this protocol (under proto_lock) */ struct list list; /* list of registered protocols (under proto_lock) */ diff --git a/include/haproxy/protocol.h b/include/haproxy/protocol.h index 05bba78d9..5c0871aec 100644 --- a/include/haproxy/protocol.h +++ b/include/haproxy/protocol.h @@ -38,6 +38,12 @@ void protocol_register(struct protocol *proto); */ void protocol_unregister(struct protocol *proto); +/* clears flag on all protocols. */ +void protocol_clrf_all(uint flag); + +/* sets flag on all protocols. */ +void protocol_setf_all(uint flag); + /* binds all listeners of all registered protocols. Returns a composition * of ERR_NONE, ERR_RETRYABLE, ERR_FATAL, ERR_ABORT. */ diff --git a/src/protocol.c b/src/protocol.c index c627d5c73..7cc967436 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -61,6 +61,28 @@ void protocol_unregister(struct protocol *proto) HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); } +/* clears flag on all protocols. */ +void protocol_clrf_all(uint flag) +{ + struct protocol *proto; + + HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); + list_for_each_entry(proto, &protocols, list) + proto->flags &= ~flag; + HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); +} + +/* sets flag on all protocols. */ +void protocol_setf_all(uint flag) +{ + struct protocol *proto; + + HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); + list_for_each_entry(proto, &protocols, list) + proto->flags |= flag; + HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); +} + /* binds all listeners of all registered protocols. Returns a composition * of ERR_NONE, ERR_RETRYABLE, ERR_FATAL. */