@@ -166,6 +166,11 @@ pub struct JobState<'a> {
166
166
/// Channel back to the main thread to coordinate messages and such.
167
167
messages : Arc < Queue < Message > > ,
168
168
169
+ /// Normally messages are handled in a bounded way. When the job is fresh
170
+ /// however we need to immediately return to prevent a deadlock as the messages
171
+ /// are processed on the same thread as they are sent from.
172
+ messages_bounded : bool ,
173
+
169
174
/// The job id that this state is associated with, used when sending
170
175
/// messages back to the main thread.
171
176
id : JobId ,
@@ -232,11 +237,19 @@ impl<'a> JobState<'a> {
232
237
}
233
238
234
239
pub fn stdout ( & self , stdout : String ) {
235
- self . messages . push_bounded ( Message :: Stdout ( stdout) ) ;
240
+ if self . messages_bounded {
241
+ self . messages . push_bounded ( Message :: Stdout ( stdout) ) ;
242
+ } else {
243
+ self . messages . push ( Message :: Stdout ( stdout) ) ;
244
+ }
236
245
}
237
246
238
247
pub fn stderr ( & self , stderr : String ) {
239
- self . messages . push_bounded ( Message :: Stderr ( stderr) ) ;
248
+ if self . messages_bounded {
249
+ self . messages . push_bounded ( Message :: Stderr ( stderr) ) ;
250
+ } else {
251
+ self . messages . push ( Message :: Stderr ( stderr) ) ;
252
+ }
240
253
}
241
254
242
255
/// A method used to signal to the coordinator thread that the rmeta file
@@ -830,6 +843,7 @@ impl<'cfg> DrainState<'cfg> {
830
843
let state = JobState {
831
844
id,
832
845
messages : messages. clone ( ) ,
846
+ messages_bounded : job. freshness ( ) == Freshness :: Dirty ,
833
847
rmeta_required : Cell :: new ( rmeta_required) ,
834
848
_marker : marker:: PhantomData ,
835
849
} ;
0 commit comments