Remember specified rate limit

This commit is contained in:
Jeremy Lakeman 2014-05-12 13:39:08 +09:30
parent eb08cf27ce
commit 55db779f8c
2 changed files with 4 additions and 2 deletions

View File

@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define INTERFACE_STATE_DETECTING 2 #define INTERFACE_STATE_DETECTING 2
struct limit_state{ struct limit_state{
uint32_t rate_micro_seconds;
// length of time for a burst // length of time for a burst
time_ms_t burst_length; time_ms_t burst_length;
// how many in a burst // how many in a burst
@ -40,7 +41,7 @@ struct limit_state{
time_ms_t limit_next_allowed(struct limit_state *state); time_ms_t limit_next_allowed(struct limit_state *state);
int limit_is_allowed(struct limit_state *state); int limit_is_allowed(struct limit_state *state);
int limit_init(struct limit_state *state, int rate_micro_seconds); int limit_init(struct limit_state *state, uint32_t rate_micro_seconds);
struct overlay_interface; struct overlay_interface;

View File

@ -69,7 +69,8 @@ int limit_is_allowed(struct limit_state *state){
} }
/* Initialise burst size and length based on the number we can do in one MIN_BURST */ /* Initialise burst size and length based on the number we can do in one MIN_BURST */
int limit_init(struct limit_state *state, int rate_micro_seconds){ int limit_init(struct limit_state *state, uint32_t rate_micro_seconds){
state->rate_micro_seconds = rate_micro_seconds;
if (rate_micro_seconds==0){ if (rate_micro_seconds==0){
state->burst_size=0; state->burst_size=0;
state->burst_length=1; state->burst_length=1;