From 584a0e07dc46120fd0a25c52f834281113ace8a6 Mon Sep 17 00:00:00 2001 From: Cesar Douady Date: Fri, 3 May 2024 10:11:55 +0200 Subject: [PATCH] fixup --- src/autodep/gather.cc | 6 ++++-- src/lmakeserver/codec.cc | 6 ++---- src/lmakeserver/main.cc | 10 ++++------ src/rpc_job.cc | 3 ++- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/autodep/gather.cc b/src/autodep/gather.cc index 3e9de9ab..de24b060 100644 --- a/src/autodep/gather.cc +++ b/src/autodep/gather.cc @@ -202,10 +202,11 @@ void Gather::_send_to_server ( Fd fd , Jerr&& jerr ) { case Proc::ChkDeps : reorder(false/*at_end*/) ; break ; // ensure server sees a coherent view case Proc::DepVerbose : _new_accesses(fd,::copy(jerr)) ; break ; // - case Proc::Decode : SWEAR(jerr.files.size()==1) ; _codec_files[fd] = Codec::mk_decode_node( jerr.files[0].first , jerr.ctx , jerr.txt ) ; break ; - case Proc::Encode : SWEAR(jerr.files.size()==1) ; _codec_files[fd] = Codec::mk_encode_node( jerr.files[0].first , jerr.ctx , jerr.txt ) ; break ; + case Proc::Decode : SWEAR( jerr.sync && jerr.files.size()==1 ) ; _codec_files[fd] = Codec::mk_decode_node( jerr.files[0].first , jerr.ctx , jerr.txt ) ; break ; + case Proc::Encode : SWEAR( jerr.sync && jerr.files.size()==1 ) ; _codec_files[fd] = Codec::mk_encode_node( jerr.files[0].first , jerr.ctx , jerr.txt ) ; break ; default : ; } + if (!jerr.sync) fd = {} ; // dont reply if not sync try { JobMngtRpcReq jmrr ; if (jerr.proc==JobExecProc::ChkDeps) jmrr = { JobMngtProc::ChkDeps , seq_id , job , fd , cur_deps_cb() } ; @@ -451,6 +452,7 @@ Status Gather::exec_child( ::vector_s const& args , Fd cstdin , Fd cstdout , Fd case JobMngtProc::ChkDeps : if (jmrr.ok==Maybe) { set_status(Status::ChkDeps) ; kill_step = KillStep::Kill ; rfd = {} ; } break ; case JobMngtProc::Decode : case JobMngtProc::Encode : { + SWEAR(+jmrr.fd) ; auto it = _codec_files.find(jmrr.fd) ; _new_access( rfd , PD(New) , ::move(it->second) , {.accesses=Access::Reg} , jmrr.crc , false/*parallel*/ , ::string(snake(jmrr.proc)) ) ; _codec_files.erase(it) ; diff --git a/src/lmakeserver/codec.cc b/src/lmakeserver/codec.cc index da308249..22144ba5 100644 --- a/src/lmakeserver/codec.cc +++ b/src/lmakeserver/codec.cc @@ -281,10 +281,8 @@ namespace Codec { case JobMngtProc::Decode : jmrr = cc.decode() ; break ; case JobMngtProc::Encode : jmrr = cc.encode() ; break ; DF} - if (cc.fd) { - jmrr.fd = cc.fd ; // seq_id will be filled in by send_reply - Backends::send_reply( cc.job , ::move(jmrr) ) ; - } + jmrr.fd = cc.fd ; // seq_id will be filled in by send_reply + Backends::send_reply( cc.job , ::move(jmrr) ) ; } } diff --git a/src/lmakeserver/main.cc b/src/lmakeserver/main.cc index e82607d5..c030e02b 100644 --- a/src/lmakeserver/main.cc +++ b/src/lmakeserver/main.cc @@ -376,12 +376,10 @@ bool/*interrupted*/ engine_loop() { ::vector deps ; deps.reserve(ecjm.deps.size()) ; for( auto const& [dn,dd] : ecjm.deps ) deps.emplace_back(Node(dn),dd) ; JobMngtRpcReply jmrr = je.job_info(ecjm.proc,deps) ; - if (+ecjm.fd) { - jmrr.fd = ecjm.fd ; // seq_id will be filled in by send_reply - //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - Backends::send_reply( +je , ::move(jmrr) ) ; - //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - } + jmrr.fd = ecjm.fd ; // seq_id will be filled in by send_reply + //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv + Backends::send_reply( +je , ::move(jmrr) ) ; + //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ } break ; DF} } break ; diff --git a/src/rpc_job.cc b/src/rpc_job.cc index f5538e9a..eed2ae8e 100644 --- a/src/rpc_job.cc +++ b/src/rpc_job.cc @@ -199,7 +199,8 @@ ::ostream& operator<<( ::ostream& os , JobMngtRpcReq const& jmrr ) { return os <<')' ; } -JobMngtRpcReq::JobMngtRpcReq( SI si , JI j , Fd fd_ , JobExecRpcReq&& jerr ) : seq_id{si} , job{j} , fd{jerr.sync?fd_:Fd()} { +JobMngtRpcReq::JobMngtRpcReq( SI si , JI j , Fd fd_ , JobExecRpcReq&& jerr ) : seq_id{si} , job{j} , fd{fd_} { + SWEAR( jerr.sync || !fd , jerr,fd ) ; switch (jerr.proc) { case JobExecProc::Decode : proc = P::Decode ; ctx = ::move(jerr.ctx) ; file = ::move(jerr.files[0].first) ; txt = ::move(jerr.txt) ; break ; case JobExecProc::Encode : proc = P::Encode ; ctx = ::move(jerr.ctx) ; file = ::move(jerr.files[0].first) ; txt = ::move(jerr.txt) ; min_len = jerr.min_len ; break ;