From 6c951cb023f52226309f1d7cfdb5b86d35fe7fd7 Mon Sep 17 00:00:00 2001 From: Cesar Douady Date: Fri, 3 May 2024 14:55:55 +0200 Subject: [PATCH] fix rare crash in presence of lost jobs --- src/lmakeserver/backend.cc | 3 +++ src/lmakeserver/backend.x.hh | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lmakeserver/backend.cc b/src/lmakeserver/backend.cc index ca73748a..66ec5989 100644 --- a/src/lmakeserver/backend.cc +++ b/src/lmakeserver/backend.cc @@ -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*/ ) ; @@ -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. @@ -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 diff --git a/src/lmakeserver/backend.x.hh b/src/lmakeserver/backend.x.hh index ff41b5f5..64ff1191 100644 --- a/src/lmakeserver/backend.x.hh +++ b/src/lmakeserver/backend.x.hh @@ -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 ; @@ -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() {