@@ -34,9 +34,10 @@ type Invocation struct {
34
34
cxxIDirs IncludeDirs // -I / -iquote / -isystem go here
35
35
depsFlags DepCmdFlags // -MD -MF file and others, used for .d files generation (not passed to server)
36
36
37
- doneState int32 // see Invocation.DoneRecvObj
38
- wgUpload sync.WaitGroup
39
- wgRecv sync.WaitGroup
37
+ waitUploads int32 // files still waiting for upload to finish; 0 releases wgUpload; see Invocation.DoneUploadFile
38
+ doneRecv int32 // 1 if o file received or failed receiving; 1 releases wgRecv; see Invocation.DoneRecvObj
39
+ wgUpload sync.WaitGroup
40
+ wgRecv sync.WaitGroup
40
41
41
42
// when remote compilation starts, the server starts a server.Session (with the same sessionID)
42
43
// after it finishes, we have these fields filled (and objOutFile saved)
@@ -232,7 +233,7 @@ func (invocation *Invocation) CollectDependentIncludes(disableOwnIncludes bool)
232
233
}
233
234
234
235
func (invocation * Invocation ) DoneRecvObj (err error ) {
235
- if atomic .SwapInt32 (& invocation .doneState , 1 ) == 0 {
236
+ if atomic .SwapInt32 (& invocation .doneRecv , 1 ) == 0 {
236
237
if err != nil {
237
238
invocation .err = err
238
239
}
@@ -244,11 +245,16 @@ func (invocation *Invocation) DoneUploadFile(err error) {
244
245
if err != nil {
245
246
invocation .err = err
246
247
}
248
+ atomic .AddInt32 (& invocation .waitUploads , - 1 )
247
249
invocation .wgUpload .Done () // will end up after all required files uploaded/failed
248
250
}
249
251
250
252
func (invocation * Invocation ) ForceInterrupt (err error ) {
251
- // hopefully, an invocation can't hang on uploading files, it could hang only on waiting for obj
252
253
logClient .Error ("force interrupt" , "sessionID" , invocation .sessionID , invocation .cppInFile , err )
254
+ // release invocation.wgUpload
255
+ for atomic .LoadInt32 (& invocation .waitUploads ) != 0 {
256
+ invocation .DoneUploadFile (err )
257
+ }
258
+ // release invocation.wgDone
253
259
invocation .DoneRecvObj (err )
254
260
}
0 commit comments