Skip to content

Commit

Permalink
fix rare crash in presence of lost jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
cesar-douady committed May 3, 2024
1 parent 584a0e0 commit 6c951cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/lmakeserver/backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Backends {
auto it = Backend::_s_start_tab.find(job) ;
if (it==Backend::_s_start_tab.end()) return ; // job is dead without waiting for reply, curious but possible
Backend::StartEntry const& e = it->second ;
if (!e ) return ; // .
try {
jmrr.seq_id = e.conn.seq_id ;
ClientSockFd fd( e.conn.host , e.conn.port , 3/*n_trials*/ ) ;
Expand Down Expand Up @@ -166,6 +167,7 @@ namespace Backends {

void Backend::_s_wakeup_remote( JobIdx job , StartEntry::Conn const& conn , SigDate const& start_date , JobMngtProc proc ) {
Trace trace(BeChnl,"_s_wakeup_remote",job,conn,proc) ;
SWEAR(conn.seq_id,job,conn) ;
try {
ClientSockFd fd(conn.host,conn.port) ;
OMsgBuf().send( fd , JobMngtRpcReply(proc,conn.seq_id) ) ; // XXX : straighten out Fd : Fd must not detach on mv and Epoll must take an AutoCloseFd as arg to take close resp.
Expand Down Expand Up @@ -510,6 +512,7 @@ namespace Backends {
for( auto jit = _s_start_tab.begin() ; jit!=_s_start_tab.end() ;) { // /!\ we erase entries while iterating
JobIdx j = jit->first ;
StartEntry& e = jit->second ;
if (!e) { jit++ ; continue ; }
if (ri) {
if ( e.reqs.size()==1 && e.reqs[0]==ri ) goto Kill ;
for( auto it = e.reqs.begin() ; it!=e.reqs.end() ; it++ ) { // e.reqs is a non-sorted vector, we must search ri by hand
Expand Down
8 changes: 6 additions & 2 deletions src/lmakeserver/backend.x.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ namespace Backends {
friend ::ostream& operator<<( ::ostream& , StartEntry const& ) ;
struct Conn {
friend ::ostream& operator<<( ::ostream& , Conn const& ) ;
// accesses
bool operator+() const { return seq_id ; }
bool operator!() const { return !+*this ; }
// data
in_addr_t host = NoSockAddr ;
in_port_t port = 0 ;
SeqId seq_id = 0 ;
Expand All @@ -63,8 +67,8 @@ namespace Backends {
StartEntry( ) = default ;
StartEntry(NewType) { open() ; }
// accesses
bool operator+() const { return conn.seq_id ; }
bool operator!() const { return !+*this ; }
bool operator+() const { return +conn ; }
bool operator!() const { return !+*this ; }
bool useful () const ;
// services
void open() {
Expand Down

0 comments on commit 6c951cb

Please sign in to comment.