MCPcopy
hub / github.com/git-lfs/git-lfs / Connection

Method Connection

ssh/connection.go:101–124  ·  view source on GitHub ↗

Connection returns the nth connection (starting from 0) in this transfer instance if it is initialized and otherwise initializes a new connection and saves it in the nth position. In all cases, nil is returned with an error if n is greater than the maximum number of connections, including when the

(n int)

Source from the content-addressed store, hash-verified

99// if n is greater than the maximum number of connections, including when
100// the connection array itself is nil.
101func (st *SSHTransfer) Connection(n int) (*PktlineConnection, error) {
102 st.lock.RLock()
103 if n >= len(st.conn) {
104 st.lock.RUnlock()
105 return nil, errors.New(tr.Tr.Get("pure SSH connection unavailable (#%d)", n))
106 }
107 if st.conn[n] != nil {
108 defer st.lock.RUnlock()
109 return st.conn[n], nil
110 }
111 st.lock.RUnlock()
112
113 st.lock.Lock()
114 defer st.lock.Unlock()
115 if st.conn[n] != nil {
116 return st.conn[n], nil
117 }
118 conn, _, err := st.spawnConnection(n)
119 if err != nil {
120 return nil, err
121 }
122 st.conn[n] = conn
123 return conn, nil
124}
125
126// ConnectionCount returns the number of connections this object has.
127func (st *SSHTransfer) ConnectionCount() int {

Callers 5

connectionMethod · 0.80
batchInternalMethod · 0.80
doDownloadMethod · 0.80
verifyUploadMethod · 0.80
doUploadMethod · 0.80

Calls 5

spawnConnectionMethod · 0.95
NewFunction · 0.92
GetMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected