|
Lines 1335-1341
bandwidth_limit_init(struct bwlimit *bw, u_int64_t kbps, size_t buflen)
Link Here
|
| 1335 |
{ |
1335 |
{ |
| 1336 |
bw->buflen = buflen; |
1336 |
bw->buflen = buflen; |
| 1337 |
bw->rate = kbps; |
1337 |
bw->rate = kbps; |
| 1338 |
bw->thresh = bw->rate; |
1338 |
bw->thresh = buflen; |
| 1339 |
bw->lamt = 0; |
1339 |
bw->lamt = 0; |
| 1340 |
timerclear(&bw->bwstart); |
1340 |
timerclear(&bw->bwstart); |
| 1341 |
timerclear(&bw->bwend); |
1341 |
timerclear(&bw->bwend); |
|
Lines 1348-1359
bandwidth_limit(struct bwlimit *bw, size_t read_len)
Link Here
|
| 1348 |
u_int64_t waitlen; |
1348 |
u_int64_t waitlen; |
| 1349 |
struct timespec ts, rm; |
1349 |
struct timespec ts, rm; |
| 1350 |
|
1350 |
|
|
|
1351 |
bw->lamt += read_len; |
| 1352 |
|
| 1351 |
if (!timerisset(&bw->bwstart)) { |
1353 |
if (!timerisset(&bw->bwstart)) { |
| 1352 |
monotime_tv(&bw->bwstart); |
1354 |
monotime_tv(&bw->bwstart); |
| 1353 |
return; |
1355 |
return; |
| 1354 |
} |
1356 |
} |
| 1355 |
|
1357 |
|
| 1356 |
bw->lamt += read_len; |
|
|
| 1357 |
if (bw->lamt < bw->thresh) |
1358 |
if (bw->lamt < bw->thresh) |
| 1358 |
return; |
1359 |
return; |
| 1359 |
|
1360 |
|