id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c164100
s.mu.Unlock() return len(s.clients) }
c164101
defer s.mu.Unlock() return s.clients[cid] }
c164102
s.mu.Unlock() return s.numSubscriptions() }
c164103
{ acc := v.(*Account) if acc.sl != nil { subs += acc.TotalSubs() } return true }) return uint32(subs) }
c164104
defer s.mu.Unlock() return s.configTime }
c164105
return nil } return s.listener.Addr() }
c164106
return nil } return s.http.Addr().(*net.TCPAddr) }
c164107
nil } return s.routeListener.Addr().(*net.TCPAddr) }
c164108
return nil } return s.profiler.Addr().(*net.TCPAddr) }
c164109
nil) && (opts.Gateway.Name == "" || s.gatewayListener != nil) s.mu.Unlock() if ok { return true } time.Sleep(25 * time.Millisecond) } return false }
c164110
s.mu.Unlock() return s.info.ID }
c164111
// and not add any address in the array in the loop above, and we // ended-up returning 0.0.0.0, which is problematic for Windows clients. // Check for 0.0.0.0 or :: specifically, and ignore if that's the case. if opts.Host == "0.0.0.0" || opts.Host == "::" { s.Errorf("Address %q can not be resolved pr...
c164112
= append(hostPorts, net.JoinHostPort(ip.String(), port)) case *net.IPAddr: ip = v.IP hostPorts = append(hostPorts, net.JoinHostPort(ip.String(), port)) default: continue } } } } else { hostPorts = append(hostPorts, net.JoinHostPort(hp.IP.String(), port)) } return hostPorts }
c164113
hostports[i] = fmt.Sprintf("%s://%s", protocol, hp) } return hostports }
c164114
clusterProto := "nats" if opts.Cluster.TLSConfig != nil { clusterProto = "tls" } ports.Cluster = formatURL(clusterProto, clusterListener) } if profileListener != nil { ports.Profile = formatURL("http", profileListener) } return &ports } return nil }
c164115
filepath.Join(dirname, fmt.Sprintf("%s_%d.ports", filepath.Base(os.Args[0]), os.Getpid())) }
c164116
"" { if err := os.Remove(portsFile); err != nil { s.Errorf("Error cleaning up ports file %s: %v", portsFile, err) } } }
c164117
ports file: %v", err) return } if err := ioutil.WriteFile(portsFile, data, 0666); err != nil { s.Errorf("Error writing ports file (%s): %v", portsFile, err) return } }() } }
c164118
} ok := true for _, l := range listeners { if l == nil { ok = false break } } if ok { return true } select { case <-s.quitCh: return false case <-time.After(25 * time.Millisecond): // continue - unable to select from quit - we are still running } } return false }
c164119
!= 0 { listeners = append(listeners, s.http) } if opts.ProfPort != 0 { listeners = append(listeners, s.profiler) } return listeners }
c164120
defer s.mu.Unlock() return s.ldm }
c164121
t := time.NewTimer(time.Duration(atomic.LoadInt64(&lameDuckModeInitialDelay))) // Delay start of closing of client connections in case // we have several servers that we want to signal to enter LD mode // and not have their client reconnect to each other. select { case <-t.C: s.Noticef("Closing existing clients...
c164122
uintptr(PDH_FMT_DOUBLE), uintptr(unsafe.Pointer(lpdwBufferSize)), uintptr(unsafe.Pointer(lpdwBufferCount)), uintptr(unsafe.Pointer(itemBuffer))) return uint32(ret) }
c164123
strings.TrimRight(name, ".exe") return }
c164124
vssQuery := fmt.Sprintf("\\Process(%s)\\Virtual Bytes", name) if err = pdhAddCounter(pcHandle, pidQuery, 0, &pidCounter); err != nil { return err } if err = pdhAddCounter(pcHandle, cpuQuery, 0, &cpuCounter); err != nil { return err } if err = pdhAddCounter(pcHandle, rssQuery, 0, &rssCounter); err != nil { ...
c164125
if rssAry, err = getCounterArrayData(rssCounter); err != nil { return err } if vssAry, err = getCounterArrayData(vssCounter); err != nil { return err } // find the index of the entry for this process idx := int(-1) for i := range pidAry { if int(pidAry[i]) == processPid { idx = i break } } // no ...
c164126
s.mu.Lock() defer s.mu.Unlock() return s.nonceRequired() }
c164127
> 0 || len(s.trustedKeys) > 0 }
c164128
s.prand.Read(data) base64.RawURLEncoding.Encode(n, data) }
c164129
*cf |= c return true } return false }
c164130
return nil } state := tc.ConnectionState() return &state }
c164131
{ return nil } return c.nc.RemoteAddr() }
c164132
c.Errorf("Problem registering with account [%s]", acc.Name) c.sendErr("Failed Account Registration") }
c164133
if kind == CLIENT && acc.MaxTotalConnectionsReached() { return ErrTooManyAccountConnections } else if kind == LEAF && acc.MaxTotalLeafNodesReached() { return ErrTooManyAccountConnections } // Add in new one. if prev := acc.addClient(c); prev == 0 && srv != nil { srv.incActiveAccounts() } return nil }
c164134
c.msubs != jwt.NoLimit && len(c.subs) >= int(c.msubs) }
c164135
// Assign permissions. if user.Permissions == nil { // Reset perms to nil in case client previously had them. c.perms = nil c.mperms = nil return } c.setPermissions(user.Permissions) }
c164136
return err } } c.mu.Lock() c.user = user // Assign permissions. if user.Permissions == nil { // Reset perms to nil in case client previously had them. c.perms = nil c.mperms = nil } else { c.setPermissions(user.Permissions) } c.mu.Unlock() return nil }
c164137
for _, pubSubject := range perms.Publish.Deny { sub := &subscription{subject: []byte(pubSubject)} c.perms.pub.deny.Insert(sub) } } // Loop over subscribe permissions if perms.Subscribe != nil { if len(perms.Subscribe.Allow) > 0 { c.perms.sub.allow = NewSublist() } for _, subSubject := range perms...
c164138
c.mperms.deny.Insert(&subscription{subject: []byte(sub)}) } }
c164139
c.out.sg.Wait() c.out.sgw = false } // Flush data // TODO(dlc) - This could spin if another go routine in flushOutbound waiting on a slow IO. waitOk = c.flushOutbound() isClosed := c.flags.isSet(clearConnection) c.mu.Unlock() if isClosed { return } } }
c164140
Just ignore if this was closed. if cp.flags.isSet(clearConnection) { cp.mu.Unlock() continue } if budget > 0 && cp.flushOutbound() { budget -= cp.out.lft } else { cp.flushSignal() } cp.mu.Unlock() } return last }
c164141
c.out.p = nil return append(c.out.nb, p) } return c.out.nb }
c164142
// The partial needs to be first, so append nb to pnb c.out.nb = append(pnb, nb...) }
c164143
return true } return false }
c164144
c.processGatewayInfo(&info) case LEAF: c.processLeafnodeInfo(&info) } return nil }
c164145
4 { continue } start := i[2] end := i[3] // Replace password substring. buf = append(buf[:start], append(redactedPass, buf[end:]...)...) break } return buf }
c164146
pcs := [][]byte{[]byte("INFO"), b, []byte(CR_LF)} return bytes.Join(pcs, []byte(" ")) }
c164147
} else if hasWC { if subjectIsSubsetMatch(im.prefix+im.from, subj) { froms = append(froms, im) } } } acc.mu.RUnlock() var shadow []*subscription if len(ims) > 0 || len(froms) > 0 { shadow = make([]*subscription, 0, len(ims)+len(froms)) } // Now walk through collected importMaps for _, im := ra...
c164148
{ errs := fmt.Sprintf("Could not add shadow import subscription for account %q", im.acc.Name) c.Debugf(errs) return nil, fmt.Errorf(errs) } // Update our route map here. c.srv.updateRouteSubscriptionMap(im.acc, &nsub, 1) return &nsub, nil }
c164149
len(r.psubs) == 0 // We use the actual subscription to signal us to spin up the deny mperms // and cache. We check if the subject is a wildcard that contains any of // the deny clauses. // FIXME(dlc) - We could be smarter and track when these go away and remove. if allowed && c.mperms == nil && subjectHasWi...
c164150
acc.sl.Remove(sub) } // Check to see if we have shadow subscriptions. var updateRoute bool shadowSubs := sub.shadow sub.shadow = nil if len(shadowSubs) > 0 { updateRoute = (c.kind == CLIENT || c.kind == SYSTEM || c.kind == LEAF) && c.srv != nil } c.mu.Unlock() for _, nsub := range shadowSubs { if err :...
c164151
c.mperms.dcache[subject] = false } if len(c.mperms.dcache) > maxDenyPermCacheSize { c.pruneDenyCache() } return false }
c164152
delete(c.mperms.dcache, subject) if r++; r > pruneSize { break } } }
c164153
delete(c.perms.pcache, subject) if r++; r > pruneSize { break } } }
c164154
true } // If we have a deny list and are currently allowed, check that as well. if allowed && c.perms.pub.deny != nil { r := c.perms.pub.deny.Match(subject) allowed = len(r.psubs) == 0 } // Update our cache here. c.perms.pcache[string(subject)] = allowed // Prune if needed. if len(c.perms.pcache) > maxPerm...
c164155
'.'} rn := c.in.prand.Int63() for i, l := replyPrefixLen, rn; i < len(b); i++ { b[i] = digits[l%base] l /= base } return b[:] }
c164156
c.processInboundGatewayMsg(msg) case LEAF: c.processInboundLeafMsg(msg) } }
c164157
from above. rr := rm.acc.sl.Match(rm.to) // If we are a route or gateway and this message is flipped to a queue subscriber we // need to handle that since the processMsgResults will want a queue filter. if (c.kind == ROUTER || c.kind == GATEWAY) && c.pa.queues == nil && len(rr.qsubs) > 0 { c.makeQFilter(rr...
c164158
!c.flags.isSet(connectReceived) && c.atmr != nil }
c164159
c.atmr = time.AfterFunc(d, c.authExpired) c.mu.Unlock() }
c164160
rtt := c.rtt c.mu.Unlock() return rtt }
c164161
defer c.mu.Unlock() return c.acc }
c164162
n++; n > prunePerAccountCacheSize { break } } }
c164163
return fmt.Sprintf("User %q", c.opts.Username) default: return `User "N/A"` } }
c164164
timeout := time.Now().Add(10 * time.Second) for status.State != to { if timeout.Before(time.Now()) { return fmt.Errorf("timeout waiting for service to go to state=%d", to) } time.Sleep(300 * time.Millisecond) status, err = s.Query() if err != nil { return fmt.Errorf("could not retrieve service status:...
c164165
failed:%v", err) } fmt.Sscanf(string(out), "%f %d %d", pcpu, rss, vss) *rss *= 1024 // 1k blocks, want bytes. *vss *= 1024 // 1k blocks, want bytes. return nil }
c164166
clone.TLSConfig = r.TLSConfig.Clone() clone.TLSTimeout = r.TLSTimeout } return clone }
c164167
in the list %d has no name", i) } if len(g.URLs) == 0 { return fmt.Errorf("gateway %q has no URL", g.Name) } if g.TLSConfig != nil && g.TLSConfig.InsecureSkipVerify { return fmt.Errorf("tls InsecureSkipVerify not supported for remote gateway %q", g.Name) } } return nil }
c164168
= append(prefix, gwReplyPrefix...) prefix = append(prefix, fullHash[:4]...) prefix = append(prefix, '.') return prefix }
c164169
make(map[string]*url.URL, len(rgo.URLs)), } if opts.Gateway.TLSConfig != nil && cfg.TLSConfig == nil { cfg.TLSConfig = opts.Gateway.TLSConfig.Clone() } if cfg.TLSTimeout == 0 { cfg.TLSTimeout = opts.Gateway.TLSTimeout } for _, u := range rgo.URLs { // For TLS, look for a hostname that we can us...
c164170
n := g.name g.RUnlock() return n }
c164171
0, len(g.URLs)) for u := range g.URLs { a = append(a, u) } return a }
c164172
:= g.runknown g.RUnlock() return reject }
c164173
is using different gateway port than this one, or error // saying that it tried to connect to itself. s.Errorf("Could not find any non-local IP for gateway %q with listen specification %q", gw.name, info.Host) } else { // Take the first from the list... info.Host = ips[0] } } } gw.URL = ...
c164174
} g.infoJSON = []byte(fmt.Sprintf(InfoProto, b)) }
c164175
+= gatewayReconnectDelay } select { case <-time.After(delay): case <-s.quitCh: return } s.solicitGateway(cfg) }
c164176
typeStr, cfg.Name, u.Host, address, err) // Break this loop if server is being shutdown... if !s.isRunning() { break } } if isImplicit { attempts++ if opts.Gateway.ConnectRetries == 0 || attempts > opts.Gateway.ConnectRetries { s.gateway.Lock() delete(s.gateway.remotes, cfg.Name) s.g...
c164177
TLS: tlsRequired, Name: c.srv.info.ID, Gateway: c.srv.getGatewayName(), } b, err := json.Marshal(cinfo) if err != nil { panic(err) } c.sendProto([]byte(fmt.Sprintf(ConProto, b)), true) }
c164178
urls := cfg.getURLsAsStrings() if len(urls) > 0 { info.Gateway = gwCfgName info.GatewayURLs = urls b, _ := json.Marshal(&info) c.mu.Lock() c.sendProto([]byte(fmt.Sprintf(InfoProto, b)), true) c.mu.Unlock() } } }
c164179
will not have host/port defined. info := &Info{ ID: "GW" + s.info.ID, Gateway: oinfo.Gateway, GatewayURLs: oinfo.GatewayURLs, GatewayCmd: gatewayCmdGossip, } b, _ := json.Marshal(info) infoJSON := []byte(fmt.Sprintf(InfoProto, b)) for _, r := range s.routes { r.mu.Lock() r.sendInfo(info...
c164180
s.sendSubsToGateway(c, accName) }
c164181
!= nil { gwCfgs = append(gwCfgs, c.gw.cfg) } c.mu.Unlock() } gw.RUnlock() if len(gwCfgs) == 0 { return } // Check forwardNewGatewayToLocalCluster() as to why we set ID this way. info := Info{ ID: "GW" + s.info.ID, GatewayCmd: gatewayCmdGossip, } for _, cfg := range gwCfgs { urls := cfg....
c164182
n := len(s.gateway.out) s.gateway.RUnlock() return n }
c164183
n := len(s.gateway.in) s.gateway.RUnlock() return n }
c164184
ca := g.connAttempts g.Unlock() return ca }
c164185
ii := g.implicit g.RUnlock() return ii }
c164186
0, len(g.urls)) for _, u := range g.urls { a = append(a, u) } g.RUnlock() return a }
c164187
{ a = append(a, u.Host) } g.RUnlock() return a }
c164188
g.urls[u.Host] = u } // Then add the ones from the infoURLs array we got. g.addURLs(infoURLs) g.Unlock() }
c164189
if a tlsName has not been set yet and we are dealing // with a hostname and not a bare IP, save the hostname. g.saveTLSHostname(u) // Use u.Host for the key. g.urls[u.Host] = u } } } }
c164190
s.gateway.URLs[urlStr] = struct{}{} s.gateway.Unlock() }
c164191
delete(s.gateway.URLs, urlStr) s.gateway.Unlock() }
c164192
url := s.gateway.URL s.gateway.RUnlock() return url }
c164193
{ *a = append(*a, s.gateway.outo[i]) } s.gateway.RUnlock() }
c164194
return g.outo[i].getRTTValue() < g.outo[j].getRTTValue() }) }
c164195
for _, gwc := range s.gateway.in { *a = append(*a, gwc) } s.gateway.RUnlock() }
c164196
} c.mu.Unlock() // Update total count of qsubs in remote gateways. atomic.AddInt64(&c.srv.gateway.totalQSubs, -qSubsRemoved) } else { var subsa [1024]*subscription var subs = subsa[:0] // For inbound GW connection, if we have subs, those are // local subs on "_R_." subjects. c.mu.Lock() for _, sub...
c164197
nil } return s.gatewayListener.Addr().(*net.TCPAddr) }
c164198
var e *insie var ok bool gin.mu.Lock() if e, ok = gin.gw.insim[accName]; !ok || e == nil { e = &insie{} gin.gw.insim[accName] = e } gin.gatewaySwitchAccountToSendAllSubs(e, []byte(accName)) gin.mu.Unlock() } }
c164199
s.gateway.pasi.m[string(accName)] if inMap && si != nil && len(si) > 0 { return } c.sendAccountUnsubToGateway(accName) }