Skip to content

Commit

Permalink
improve lmake-lmakeserver connection loss management
Browse files Browse the repository at this point in the history
  • Loading branch information
cesar-douady committed Apr 25, 2024
1 parent 37296bb commit 2722ac5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/lmakeserver/backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,9 @@ namespace Backends {

void Backend::s_config( ::array<Config::Backend,N<Tag>> const& config , bool dynamic ) {
static ::jthread heartbeat_thread { _s_heartbeat_thread_func } ;
static JobThread job_start_thread {'S',_s_handle_job_start ,1000/*backlog*/} ; _s_job_start_thread = &job_start_thread ;
static JobMngtThread job_mngt_thread {'M',_s_handle_job_mngt ,1000/*backlog*/} ; _s_job_mngt_thread = &job_mngt_thread ;
static JobThread job_end_thread {'E',_s_handle_job_end ,1000/*backlog*/} ; _s_job_end_thread = &job_end_thread ;
static JobThread job_start_thread {'S',_s_handle_job_start ,4096/*backlog*/} ; _s_job_start_thread = &job_start_thread ; // 4096 : max usual value as set in ...
static JobMngtThread job_mngt_thread {'M',_s_handle_job_mngt ,4096/*backlog*/} ; _s_job_mngt_thread = &job_mngt_thread ; // ... /proc/sys/net/core/somaxconn
static JobThread job_end_thread {'E',_s_handle_job_end ,4096/*backlog*/} ; _s_job_end_thread = &job_end_thread ; // .
static DeferredThread deferred_report_thread{'R',_s_handle_deferred_report } ; _s_deferred_report_thread = &deferred_report_thread ;
static DeferredThread deferred_wakeup_thread{'W',_s_handle_deferred_wakeup } ; _s_deferred_wakeup_thread = &deferred_wakeup_thread ;
Trace trace(BeChnl,"s_config",STR(dynamic)) ;
Expand Down
7 changes: 4 additions & 3 deletions src/lmakeserver/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ void reqs_thread_func( ::stop_token stop , Fd in_fd , Fd out_fd ) {
for( Epoll::Event event : events ) {
EventKind kind = event.data<EventKind>() ;
Fd fd = event.fd() ;
trace("event",kind,fd) ;
switch (kind) {
// it may be that in a single poll, we get the end of a previous run and a request for a new one
// problem lies in this sequence :
Expand All @@ -167,7 +168,6 @@ void reqs_thread_func( ::stop_token stop , Fd in_fd , Fd out_fd ) {
trace("stop_requested") ;
goto Done ;
}
trace("int",kind) ;
switch (kind) {
case EventKind::Int : { struct signalfd_siginfo event ; ssize_t cnt = ::read(_g_int_fd ,&event,sizeof(event)) ; SWEAR( cnt==sizeof(event) , cnt ) ; } break ;
case EventKind::Watch : { struct inotify_event event ; ssize_t cnt = ::read(_g_watch_fd,&event,sizeof(event)) ; SWEAR( cnt==sizeof(event) , cnt ) ; } break ;
Expand All @@ -186,7 +186,7 @@ void reqs_thread_func( ::stop_token stop , Fd in_fd , Fd out_fd ) {
try { if (!in_tab.at(fd).first.receive_step(fd,rrr)) continue ; }
catch (...) { rrr.proc = ReqProc::None ; }
Fd ofd = kind==EventKind::Std ? out_fd : fd ;
trace("req",kind,fd,rrr) ;
trace("req",rrr) ;
switch (rrr.proc) {
case ReqProc::Make : {
Req r{New} ;
Expand All @@ -200,7 +200,7 @@ void reqs_thread_func( ::stop_token stop , Fd in_fd , Fd out_fd ) {
case ReqProc::Forget :
case ReqProc::Mark :
case ReqProc::Show :
epoll.del(fd) ; trace("stop_fd",rrr.proc,fd) ; // must precede close(fd) which may occur as soon as we push to g_engine_queue
epoll.del(fd) ; trace("del_fd",rrr.proc,fd) ; // must precede close(fd) which may occur as soon as we push to g_engine_queue
in_tab.erase(fd) ;
//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
g_engine_queue.emplace( rrr.proc , fd , ofd , rrr.files , rrr.options ) ;
Expand Down Expand Up @@ -424,6 +424,7 @@ int main( int argc , char** argv ) {
else g_startup_dir_s = new ::string ;
//
_g_int_fd = open_sig_fd({SIGINT,SIGHUP}) ; // must be done before app_init so that all threads block the signal
set_sig({SIGPIPE},true/*block*/) ;
// vvvvvvvvvvvvvvv
Persistent::writable = true ;
Codec ::writable = true ;
Expand Down
3 changes: 1 addition & 2 deletions src/process.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ inline bool/*all_done*/ set_sig( ::vector<int> const& sigs , bool block ) {
inline Fd open_sig_fd(::vector<int> const& sigs) {
swear_prod(set_sig(sigs,true/*block*/),"some of signals",sigs,"are already blocked") ;
//
sigset_t mask ;
::sigemptyset(&mask) ;
sigset_t mask ; ::sigemptyset(&mask) ;
for( int s : sigs) ::sigaddset(&mask,s) ;
//
return ::signalfd( -1 , &mask , SFD_CLOEXEC ) ;
Expand Down

0 comments on commit 2722ac5

Please sign in to comment.