MCPcopy
hub / github.com/cloudflare/tableflip / New

Function New

upgrader.go:59–76  ·  view source on GitHub ↗

New creates a new Upgrader. Files are passed from the parent and may be empty. Only the first call to this function will succeed. May return ErrNotSupported.

(opts Options)

Source from the content-addressed store, hash-verified

57//
58// Only the first call to this function will succeed. May return ErrNotSupported.
59func New(opts Options) (upg *Upgrader, err error) {
60 stdEnvMu.Lock()
61 defer stdEnvMu.Unlock()
62
63 if !isSupportedOS() {
64 return nil, fmt.Errorf("%w", ErrNotSupported)
65 }
66
67 if stdEnvUpgrader != nil {
68 return nil, errors.New("tableflip: only a single Upgrader allowed")
69 }
70
71 upg, err = newUpgrader(stdEnv, opts)
72 // Store a reference to upg in a private global variable, to prevent
73 // it from being GC'ed and exitFd being closed prematurely.
74 stdEnvUpgrader = upg
75 return
76}
77
78func newUpgrader(env *env, opts Options) (*Upgrader, error) {
79 if initialWD == "" {

Callers 4

Example_tcpServerFunction · 0.92
Example_httpShutdownFunction · 0.92
Example_httpShutdownFunction · 0.92
TestMainFunction · 0.70

Calls 2

isSupportedOSFunction · 0.85
newUpgraderFunction · 0.85

Tested by 4

Example_tcpServerFunction · 0.74
Example_httpShutdownFunction · 0.74
Example_httpShutdownFunction · 0.74
TestMainFunction · 0.56