-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
24 changed files
with
610 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef __connection_counters_h__ | ||
#define __connection_counters_h__ 1 | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/**@file | ||
* System-wide counters for tracking open connections per protocol type. | ||
*/ | ||
|
||
#include "qpid/dispatch/protocols.h" | ||
|
||
#include <stdint.h> | ||
|
||
// Increment the connection counter for the 'proto' protocol | ||
// | ||
void qd_connection_counter_inc(qd_protocol_t proto); | ||
|
||
// Decrement the connection counter for the 'proto' protocol | ||
// | ||
void qd_connection_counter_dec(qd_protocol_t proto); | ||
|
||
// Fetch the current value of the connection counter for 'proto' | ||
// | ||
uint64_t qd_connection_count(qd_protocol_t proto); | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef __protocols_h__ | ||
#define __protocols_h__ 1 | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#include "qpid/dispatch/enum.h" | ||
|
||
// Network protocols supported by the router | ||
// | ||
typedef enum { | ||
QD_PROTOCOL_TCP, | ||
QD_PROTOCOL_AMQP, | ||
QD_PROTOCOL_HTTP1, | ||
QD_PROTOCOL_HTTP2, | ||
QD_PROTOCOL_TOTAL // must be last | ||
} qd_protocol_t; | ||
|
||
// Defines qd_protocol_name(qd_protocol_t) | ||
// | ||
ENUM_DECLARE(qd_protocol); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#include "qpid/dispatch/connection_counters.h" | ||
#include "qpid/dispatch/atomic.h" | ||
|
||
atomic_uint_fast64_t qd_connection_counters[QD_PROTOCOL_TOTAL]; | ||
|
||
void qd_connection_counter_inc(qd_protocol_t proto) | ||
{ | ||
assert(proto < QD_PROTOCOL_TOTAL); | ||
atomic_fetch_add_explicit(&qd_connection_counters[proto], 1, memory_order_relaxed); | ||
} | ||
|
||
void qd_connection_counter_dec(qd_protocol_t proto) | ||
{ | ||
assert(proto < QD_PROTOCOL_TOTAL); | ||
uint64_t old = atomic_fetch_sub_explicit(&qd_connection_counters[proto], 1, memory_order_relaxed); | ||
(void) old; | ||
assert(old != 0); // underflow! | ||
} | ||
|
||
uint64_t qd_connection_count(qd_protocol_t proto) | ||
{ | ||
assert(proto < QD_PROTOCOL_TOTAL); | ||
return (uint64_t) atomic_load_explicit(&qd_connection_counters[proto], memory_order_relaxed); | ||
} | ||
|
||
|
Oops, something went wrong.