MCPcopy Index your code
hub / github.com/koding/kite / run

Method run

client.go:388–415  ·  view source on GitHub ↗

run consumes incoming dnode messages. Reconnects if necessary.

()

Source from the content-addressed store, hash-verified

386
387// run consumes incoming dnode messages. Reconnects if necessary.
388func (c *Client) run() {
389 err := c.readLoop()
390 if err != nil {
391 c.LocalKite.Log.Debug("readloop err: %s", err)
392 }
393
394 // falls here when connection disconnects
395 c.callOnDisconnectHandlers()
396
397 // let others know that the client has disconnected
398 c.disconnectMu.Lock()
399 if c.disconnect != nil {
400 close(c.disconnect)
401 c.disconnect = nil
402 }
403 c.disconnectMu.Unlock()
404
405 if c.reconnect() {
406 // we override it so it doesn't get selected next time. Because we are
407 // redialing, so after redial if a new method is called, the disconnect
408 // channel is being read and the local "disconnect" message will be the
409 // final response. This shouldn't be happen for redials.
410 c.disconnectMu.Lock()
411 c.disconnect = make(chan struct{}, 1)
412 c.disconnectMu.Unlock()
413 go c.dialForever(nil)
414 }
415}
416
417func (c *Client) reconnect() bool {
418 c.muReconnect.Lock()

Callers 2

DialTimeoutMethod · 0.95
dialForeverMethod · 0.95

Calls 5

readLoopMethod · 0.95
reconnectMethod · 0.95
dialForeverMethod · 0.95
DebugMethod · 0.80

Tested by

no test coverage detected