MCPcopy Create free account
hub / github.com/libgit2/git2go / newRegisteredSmartTransport

Function newRegisteredSmartTransport

transport.go:232–277  ·  view source on GitHub ↗
(
	name string,
	stateless bool,
	callback SmartSubtransportCallback,
	global bool,
)

Source from the content-addressed store, hash-verified

230}
231
232func newRegisteredSmartTransport(
233 name string,
234 stateless bool,
235 callback SmartSubtransportCallback,
236 global bool,
237) (*RegisteredSmartTransport, error) {
238 if !global {
239 // Check if we had already registered a smart transport for this protocol. If
240 // we had, free it. The user is now responsible for this transport for the
241 // lifetime of the library.
242 globalRegisteredSmartTransports.Lock()
243 if managed, ok := globalRegisteredSmartTransports.transports[name]; ok {
244 delete(globalRegisteredSmartTransports.transports, name)
245 globalRegisteredSmartTransports.Unlock()
246
247 err := managed.Free()
248 if err != nil {
249 return nil, err
250 }
251 } else {
252 globalRegisteredSmartTransports.Unlock()
253 }
254 }
255
256 cstr := C.CString(name)
257 defer C.free(unsafe.Pointer(cstr))
258
259 runtime.LockOSThread()
260 defer runtime.UnlockOSThread()
261
262 registeredSmartTransport := &RegisteredSmartTransport{
263 name: name,
264 stateless: stateless,
265 callback: callback,
266 }
267 registeredSmartTransport.handle = pointerHandles.Track(registeredSmartTransport)
268
269 ret := C._go_git_transport_register(cstr, registeredSmartTransport.handle)
270 if ret != 0 {
271 pointerHandles.Untrack(registeredSmartTransport.handle)
272 return nil, MakeGitError(ret)
273 }
274
275 runtime.SetFinalizer(registeredSmartTransport, (*RegisteredSmartTransport).Free)
276 return registeredSmartTransport, nil
277}
278
279// Free releases all resources used by the RegisteredSmartTransport and
280// unregisters the custom transport definition referenced by it.

Callers 3

registerManagedHTTPFunction · 0.85
registerManagedSSHFunction · 0.85

Calls 5

MakeGitErrorFunction · 0.85
freeMethod · 0.80
TrackMethod · 0.80
UntrackMethod · 0.80
FreeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…