(sources, bases []profileSource, fetch plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper)
| 127 | } |
| 128 | |
| 129 | func grabSourcesAndBases(sources, bases []profileSource, fetch plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper) (*profile.Profile, *profile.Profile, plugin.MappingSources, plugin.MappingSources, bool, error) { |
| 130 | wg := sync.WaitGroup{} |
| 131 | wg.Add(2) |
| 132 | var psrc, pbase *profile.Profile |
| 133 | var msrc, mbase plugin.MappingSources |
| 134 | var savesrc, savebase bool |
| 135 | var errsrc, errbase error |
| 136 | var countsrc, countbase int |
| 137 | go func() { |
| 138 | defer wg.Done() |
| 139 | psrc, msrc, savesrc, countsrc, errsrc = chunkedGrab(sources, fetch, obj, ui, tr) |
| 140 | }() |
| 141 | go func() { |
| 142 | defer wg.Done() |
| 143 | pbase, mbase, savebase, countbase, errbase = chunkedGrab(bases, fetch, obj, ui, tr) |
| 144 | }() |
| 145 | wg.Wait() |
| 146 | save := savesrc || savebase |
| 147 | |
| 148 | if errsrc != nil { |
| 149 | return nil, nil, nil, nil, false, fmt.Errorf("problem fetching source profiles: %v", errsrc) |
| 150 | } |
| 151 | if errbase != nil { |
| 152 | return nil, nil, nil, nil, false, fmt.Errorf("problem fetching base profiles: %v,", errbase) |
| 153 | } |
| 154 | if countsrc == 0 { |
| 155 | return nil, nil, nil, nil, false, fmt.Errorf("failed to fetch any source profiles") |
| 156 | } |
| 157 | if countbase == 0 && len(bases) > 0 { |
| 158 | return nil, nil, nil, nil, false, fmt.Errorf("failed to fetch any base profiles") |
| 159 | } |
| 160 | if want, got := len(sources), countsrc; want != got { |
| 161 | ui.PrintErr(fmt.Sprintf("Fetched %d source profiles out of %d", got, want)) |
| 162 | } |
| 163 | if want, got := len(bases), countbase; want != got { |
| 164 | ui.PrintErr(fmt.Sprintf("Fetched %d base profiles out of %d", got, want)) |
| 165 | } |
| 166 | |
| 167 | return psrc, pbase, msrc, mbase, save, nil |
| 168 | } |
| 169 | |
| 170 | // chunkedGrab fetches the profiles described in source and merges them into |
| 171 | // a single profile. It fetches a chunk of profiles concurrently, with a maximum |
no test coverage detected
searching dependent graphs…