Skip to content

Commit

Permalink
Fix goroutine scheduler buffer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
buger committed Jun 11, 2018
1 parent 6990b15 commit 515a9b3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion mw_api_rate_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (k *RateLimitForAPI) ProcessRequest(w http.ResponseWriter, r *http.Request,
storeRef,
true,
false,
k.Spec.GlobalConfig,
&k.Spec.GlobalConfig,
)

if reason == sessionFailRateLimit {
Expand Down
4 changes: 2 additions & 2 deletions mw_organisation_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (k *OrganizationMonitor) ProcessRequestLive(r *http.Request) (error, int) {
k.Spec.OrgSessionManager.Store(),
session.Per > 0 && session.Rate > 0,
true,
k.Spec.GlobalConfig,
&k.Spec.GlobalConfig,
)

k.Spec.OrgSessionManager.UpdateSession(k.Spec.OrgID, &session, session.Lifetime(k.Spec.SessionLifetime), false)
Expand Down Expand Up @@ -191,7 +191,7 @@ func (k *OrganizationMonitor) AllowAccessNext(
k.Spec.OrgSessionManager.Store(),
session.Per > 0 && session.Rate > 0,
true,
k.Spec.GlobalConfig,
&k.Spec.GlobalConfig,
)

k.Spec.OrgSessionManager.UpdateSession(k.Spec.OrgID, &session, session.Lifetime(k.Spec.SessionLifetime), false)
Expand Down
2 changes: 1 addition & 1 deletion mw_rate_limiting.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (k *RateLimitAndQuotaCheck) ProcessRequest(w http.ResponseWriter, r *http.R
storeRef,
!k.Spec.DisableRateLimit,
!k.Spec.DisableQuota,
k.Spec.GlobalConfig,
&k.Spec.GlobalConfig,
)

// If either are disabled, save the write roundtrip
Expand Down
4 changes: 2 additions & 2 deletions session_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type SessionLimiter struct {
bucketStore leakybucket.Storage
}

func (l *SessionLimiter) doRollingWindowWrite(key, rateLimiterKey, rateLimiterSentinelKey string, currentSession *user.SessionState, store storage.Handler, globalConf config.Config) bool {
func (l *SessionLimiter) doRollingWindowWrite(key, rateLimiterKey, rateLimiterSentinelKey string, currentSession *user.SessionState, store storage.Handler, globalConf *config.Config) bool {
log.Debug("[RATELIMIT] Inbound raw key is: ", key)
log.Debug("[RATELIMIT] Rate limiter key is: ", rateLimiterKey)
pipeline := globalConf.EnableNonTransactionalRateLimiter
Expand Down Expand Up @@ -73,7 +73,7 @@ const (
// sessionFailReason if session limits have been exceeded.
// Key values to manage rate are Rate and Per, e.g. Rate of 10 messages
// Per 10 seconds
func (l *SessionLimiter) ForwardMessage(currentSession *user.SessionState, key string, store storage.Handler, enableRL, enableQ bool, globalConf config.Config) sessionFailReason {
func (l *SessionLimiter) ForwardMessage(currentSession *user.SessionState, key string, store storage.Handler, enableRL, enableQ bool, globalConf *config.Config) sessionFailReason {
rateLimiterKey := RateLimitKeyPrefix + storage.HashKey(key)
rateLimiterSentinelKey := RateLimitKeyPrefix + storage.HashKey(key) + ".BLOCKED"

Expand Down

0 comments on commit 515a9b3

Please sign in to comment.