id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c164200
= append(proto, accName...) proto = append(proto, CR_LF...) c.sendProto(proto, false) if c.trace { c.traceOutOp("", proto[:len(proto)-LEN_CR_LF]) } } c.mu.Unlock() }
c164201
absent from receive-all-subscriptions-%s command", cmd)) c.closeConnection(ProtocolViolation) return "" } return string(info.GatewayCmdPayload) }
c164202
logger: log.New(os.Stderr, pre, flags), debug: debug, trace: trace, } if colors { setColoredLabelFormats(l) } else { setPlainLabelFormats(l) } return l }
c164203
= pidPrefix() } l := &Logger{ logger: log.New(f, pre, flags), debug: debug, trace: trace, logFile: f, } setPlainLabelFormats(l) return l }
c164204
return f.Close() } return nil }
c164205
l.logger.Printf(l.warnLabel+format, v...) }
c164206
rs[sub] = time.AfterFunc(d, func() { c.mu.Lock() delete(rs, sub) sub.max = 0 c.mu.Unlock() c.unsubscribe(acc, sub, true) }) }
c164207
acc, _ := c.srv.LookupAccount(string(sub.sid[:i])); acc != nil { acc.sl.Remove(sub) } c.mu.Lock() c.removeReplySubTimeout(sub) delete(c.subs, string(sub.sid)) c.mu.Unlock() } }
c164208
ok := c.route.replySubs[sub]; ok { t.Stop() delete(c.route.replySubs, sub) } }
c164209
sid := make([]byte, 0, len(acc.Name)+len(c.pa.reply)+1) sid = append(sid, acc.Name...) sid = append(sid, ' ') sid = append(sid, c.pa.reply...) // Copy off the reply since otherwise we are referencing a buffer that will be reused. reply := make([]byte, len(c.pa.reply)) copy(reply, c.pa.reply) sub := &subs...
c164210
if len(qsub) > 0 { qs = append(qs, qsub[0].queue) } } c.pa.queues = qs }
c164211
url, err := url.Parse(fmt.Sprintf("nats-route://%s/", hp)) if err != nil { c.Errorf("Error parsing URL from INFO: %v\n", err) c.mu.Unlock() c.closeConnection(ParseError) return } c.route.url = url } // Mark that the INFO protocol has been received. Will allow // to detect INFO updates. c.flags.s...
c164212
c.sendRouteSubProtos(localSubs, false, func(sub *subscription) bool { subj := string(sub.subject) // If the remote can now export but could not before, and this server can import this // subject, then send SUB protocol. if newPermsTester.canExport(subj) && !oldPermsTester.canExport(subj) && c.canImport(subj) {...
c164213
PING (see client.processPing) if c.opts.Protocol >= ClientProtoInfo && c.flags.isSet(firstPongSent) { // sendInfo takes care of checking if the connection is still // valid or not, so don't duplicate tests here. c.sendInfo(c.generateClientInfoJSON(s.copyInfo())) } c.mu.Unlock() } }
c164214
s.Errorf("Error parsing URL from INFO: %v\n", err) return } // Snapshot server options. opts := s.getOpts() if info.AuthRequired { r.User = url.UserPassword(opts.Cluster.Username, opts.Cluster.Password) } s.startGoRoutine(func() { s.connectToRoute(r, false) }) }
c164215
infoJSON := []byte(fmt.Sprintf(InfoProto, b)) for _, r := range s.routes { r.mu.Lock() if r.route.remoteID != info.ID { r.sendInfo(infoJSON) } r.mu.Unlock() } }
c164216
to Subscribe. // For meaning of Import/Export, see canImport and canExport. p := &Permissions{ Publish: perms.Import, Subscribe: perms.Export, } c.setPermissions(p) }
c164217
ase := as[accountName] if ase == nil { acc, _ := srv.LookupAccount(accountName) if acc == nil { continue } as[accountName] = &asubs{acc: acc, subs: []*subscription{sub}} } else { ase.subs = append(ase.subs, sub) } if srv.gateway.enabled { srv.gatewayUpdateSubInterest(accountName, sub, -1)...
c164218
// TODO(dlc) - This code needs to change, but even if left alone could be more // efficient with these tmp subs. sub := &subscription{client: c, subject: subj, queue: qn, qw: n} subs = append(subs, sub) } a.mu.RUnlock() closed = route.sendRouteSubProtos(subs, false, func(sub *subscription) bo...
c164219
func(sub *subscription) bool) bool { return c.sendRouteSubOrUnSubProtos(subs, true, trace, filter) }
c164220
func(sub *subscription) bool) bool { return c.sendRouteSubOrUnSubProtos(subs, false, trace, filter) }
c164221
key = append(key, byte(' ')) key = append(key, sub.queue...) // We always update for a queue subscriber since we need to send our relative weight. update = true } else { key = sub.subject } // Copy to hold outside acc lock. var n int32 var ok bool acc.mu.Lock() if n, ok = rm[string(key)]; ok { n += ...
c164222
for _, route := range s.routes { route.mu.Lock() route.sendRouteUnSubProtos(subs, trace, func(sub *subscription) bool { return route.canImport(string(sub.subject)) }) route.mu.Unlock() } s.mu.Unlock() }
c164223
s.routeInfo.Host = s.opts.Cluster.Host s.routeInfo.Port = s.opts.Cluster.Port s.routeInfo.IP = "" } // (re)generate the routeInfoJSON byte array s.generateRouteInfoJSON() return nil }
c164224
:= range s.getOpts().Routes { if urlsAreEqual(ri, rURL) { return true } } return false }
c164225
} w, err := eventlog.Open(natsEventSource) if err != nil { panic(fmt.Sprintf("could not open event log: %v", err)) } return &SysLogger{ writer: w, debug: debug, trace: trace, } }
c164226
not open event log: %v", err)) } return &SysLogger{ writer: w, debug: debug, trace: trace, } }
c164227
rb := &closedRingBuffer{} rb.conns = make([]*closedClient, max) return rb }
c164228
*closedClient) { rb.conns[rb.next()] = cc rb.total++ }
c164229
:= rb.conns[head:] sp := rb.conns[:head] copy(dup, fp) copy(dup[len(fp):], sp) } return dup }
c164230
:= svc.IsAnInteractiveSession() if err != nil { return err } if isInteractive { run = debug.Run } return run(serviceName, &winServiceWrapper{server}) }
c164231
na.imports = a.imports na.exports = a.exports return na }
c164232
+ int(a.nrclients) a.mu.RUnlock() return nc }
c164233
nlc := a.numLocalConnections() a.mu.RUnlock() return nlc }
c164234
- int(a.sysclients) - int(a.nleafs) }
c164235
a.maxTotalConnectionsReached() a.mu.RUnlock() return mtc }
c164236
int(a.mconns) a.mu.RUnlock() return mconns }
c164237
+ a.nrleafs) a.mu.RUnlock() return nln }
c164238
:= int(a.nrleafs) a.mu.RUnlock() return nrn }
c164239
a.mu.RUnlock() return len(a.rm) }
c164240
a.mu.RUnlock() return int(a.sl.Count()) }
c164241
added { if c.kind == SYSTEM { a.sysclients++ } else if c.kind == LEAF { a.nleafs++ } } a.mu.Unlock() if c != nil && c.srv != nil && a != c.srv.gacc && added { c.srv.accConnsUpdate(a) } return n }
c164242
defer a.mu.RUnlock() return len(a.imports.services) }
c164243
&& a.srv.gateway.enabled { a.srv.gatewayHandleServiceImport(a, []byte(subject), nil, -1) } }
c164244
defer a.mu.RUnlock() return int(a.maxnae) }
c164245
defer a.mu.Unlock() a.maxnae = int32(max) }
c164246
defer a.mu.RUnlock() return a.maxaettl }
c164247
defer a.mu.Unlock() a.maxaettl = ttl }
c164248
aesis = append(aesis, si) } } sort.Slice(aesis, func(i, j int) bool { return aesis[i].ts < aesis[j].ts }) return aesis }
c164249
autoexpire { a.nae++ si.ts = time.Now().Unix() if a.nae > a.maxnae && !a.pruning { a.pruning = true go a.pruneAutoExpireResponseMaps() } } a.mu.Unlock() return nil }
c164250
:= range sis { if now-si.ts >= ttl { a.removeServiceImport(si.from) } else { sis = sis[i:] break } } a.mu.RLock() numOver := int(a.nae - a.maxnae) a.mu.RUnlock() if numOver <= 0 { return } else if numOver >= len(sis) { numOver = len(sis) - 1 } // These are in sorted order, ...
c164251
{ return ErrStreamImportAuthorization } a.mu.Lock() defer a.mu.Unlock() if a.imports.streams == nil { a.imports.streams = make(map[string]*streamImport) } if prefix != "" && prefix[len(prefix)-1] != btsep { prefix = prefix + string(btsep) } // TODO(dlc) - collisions, etc. a.imports.streams[from] = &str...
c164252
return a.AddStreamImportWithClaim(account, from, prefix, nil) }
c164253
if len(accounts) == 0 { ea.tokenReq = true } else { if ea.approved == nil { ea.approved = make(map[string]*Account, len(accounts)) } for _, acc := range accounts { ea.approved[acc.Name] = acc } } } a.exports.streams[subject] = ea return nil }
c164254
list. a.mu.RLock() defer a.mu.RUnlock() return a.checkStreamImportAuthorizedNoLock(account, subject, imClaim) }
c164255
} defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return "" } return string(body) }
c164256
len(a.clients)) for _, c := range a.clients { clients = append(clients, c) } awcsti := map[string]struct{}{a.Name: struct{}{}} a.mu.Unlock() for _, c := range clients { c.processSubsOnConfigReload(awcsti) } }
c164257
if si.acc.checkActivation(a, si.claim, false) { // The token has been updated most likely and we are good to go. return } a.mu.Lock() si.invalid = true a.mu.Unlock() }
c164258
kind { case jwt.Stream: a.streamActivationExpired(subject) case jwt.Service: a.serviceActivationExpired(subject) } }
c164259
if vr.IsBlocking(true) { return false } if !a.isIssuerClaimTrusted(act) { return false } if act.Expires != 0 { tn := time.Now().Unix() if act.Expires <= tn { return false } if expTimer { expiresAt := time.Duration(act.Expires - tn) time.AfterFunc(expiresAt*time.Second, func() { acc.activa...
c164260
ia, err := a.srv.lookupAccount(claims.IssuerAccount) if err != nil { return false } return ia.hasIssuer(claims.Issuer) } // couldn't verify return false }
c164261
return false } if aim.acc.Name != bim.acc.Name || aim.from != bim.from || aim.prefix != bim.prefix { return false } } return true }
c164262
|| !IsValidLiteralSubject(subject) { return false } return a.checkExportApproved(account, subject, imClaim, a.exports.services) }
c164263
a.mu.RUnlock() return exp }
c164264
0, len(a.clients)) a.mu.RLock() for c := range a.clients { cs = append(cs, c) } a.mu.RUnlock() for _, c := range cs { c.accountAuthExpired() } }
c164265
time.AfterFunc(d, a.expiredTimeout) }
c164266
a.expired = true return } expiresAt := time.Duration(claims.Expires - tn) a.setExpirationTimer(expiresAt * time.Second) a.expired = false }
c164267
i++ { if a.signingKeys[i] == issuer { return true } } return false }
c164268
s.accResolver = ar s.mu.Unlock() }
c164269
defer s.mu.Unlock() return s.accResolver }
c164270
ac *jwt.AccountClaims) { s.updateAccountClaims(a, ac) }
c164271
{ acc := NewAccount(ac.Subject) acc.Issuer = ac.Issuer s.updateAccountClaims(acc, ac) return acc }
c164272
if len(uc.Sub.Allow) > 0 || len(uc.Sub.Deny) > 0 { if p == nil { p = &Permissions{} } p.Subscribe = &SubjectPermission{} p.Subscribe.Allow = uc.Sub.Allow p.Subscribe.Deny = uc.Sub.Deny } nu.Permissions = p return nu }
c164273
j.(string), nil } return _EMPTY_, ErrMissingAccount }
c164274
m.sm.Store(name, jwt) return nil }
c164275
c: &http.Client{Timeout: 2 * time.Second}, } if _, err := ur.Fetch(""); err != nil { return nil, err } return ur, nil }
c164276
{ return _EMPTY_, fmt.Errorf("could not fetch <%q>: %v", url, resp.Status) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return _EMPTY_, err } return string(body), nil }
c164277
nil, fmt.Errorf("error opening config file: %v", err) } p, err := parse(string(data), fp, false) if err != nil { return nil, err } return p.mapping, nil }
c164278
parse(string(data), fp, true) if err != nil { return nil, err } return p.mapping, nil }
c164279
ok := ctx.(map[string]interface{}); ok { if v, ok := m[varReference]; ok { return v, ok, nil } } } // If we are here, we have exhausted our context maps and still not found anything. // Parse from the environment. if vStr, ok := os.LookupEnv(varReference); ok { // Everything we get here will be a st...
c164280
findQSlot(sub.queue, nr.qsubs); i >= 0 { nr.qsubs[i] = append(nr.qsubs[i], sub) } else { nr.qsubs = append(nr.qsubs, []*subscription{sub}) } } return nr }
c164281
return } s.cache.Range(func(k, v interface{}) bool { key := k.(string) r := v.(*SublistResult) if matchLiteral(key, subject) { s.cache.Store(key, r.addSubToResult(sub)) } return true }) }
c164282
atomic.AddInt32(&s.cacheNum, -1) } return } s.cache.Range(func(k, v interface{}) bool { key := k.(string) if matchLiteral(key, subject) { // Since someone else may be referecing, can't modify the list // safely, just let it re-populate. s.cache.Delete(key) atomic.AddInt32(&s.cacheNum, -1) } ...
c164283
FIXME(dlc) - Make shared pool between sublist and client readLoop? result := &SublistResult{} // Get result from the main structure and place into the shared cache. // Hold the read lock to avoid race between match and store. var n int32 s.RLock() matchLevel(s.root, tokens, result) // Check for empty result. ...
c164284
!= nil && sub.queue != nil && sub.client != nil && sub.client.kind == ROUTER }
c164285
will be flushed. s.Lock() s.removeFromCache(string(sub.subject), sub) atomic.AddUint64(&s.genid, 1) s.Unlock() }
c164286
results.qsubs = append(results.qsubs, nqsub) } for _, sub := range qr { if isRemoteQSub(sub) { ns := atomic.LoadInt32(&sub.qw) // Shadow these subscriptions for n := 0; n < int(ns); n++ { results.qsubs[i] = append(results.qsubs[i], sub) } } else { results.qsubs[i] = append(results...
c164287
bytes.Equal(queue, qr[0].queue) { return i } } return -1 }
c164288
tokens { lt := len(t) if lt == 0 || sfwc { return ErrInvalidSubject } if l == nil { return ErrNotFound } if lt > 1 { n = l.nodes[t] } else { switch t[0] { case pwc: n = l.pwc case fwc: n = l.fwc sfwc = true default: n = l.nodes[t] } } if n != nil { levels = ...
c164289
error { return s.remove(sub, true) }
c164290
if err := s.remove(sub, false); err != nil { return err } } return nil }
c164291
s.removeClientSubs(s.root, c) if s.removes != removes { atomic.AddUint64(&s.genid, 1) } s.Unlock() }
c164292
l.pwc { l.pwc = nil } else { delete(l.nodes, t) } }
c164293
} if l.fwc != nil { num++ } return num }
c164294
defer s.RUnlock() return s.count }
c164295
v interface{}) bool { clen++ r := v.(*SublistResult) l := len(r.psubs) + len(r.qsubs) tot += l if l > max { max = l } return true }) st.MaxFanout = uint32(max) if tot > 0 { st.AvgFanout = float64(tot) / float64(clen) } return st }
c164296
maxDepth { maxDepth = pwcDepth } } if l.fwc != nil { fwcDepth := visitLevel(l.fwc.next, depth) if fwcDepth > maxDepth { maxDepth = fwcDepth } } return maxDepth }
c164297
== len(subject) || subject[i+1] == btsep) { return false } } } return true }
c164298
return false } if len(t) > 1 { continue } switch t[0] { case fwc: sfwc = true } } return true }
c164299
s.collectLocalSubs(s.root, subs) s.RUnlock() }