diff --git a/tdi/remote/MdsConnect.fun b/tdi/remote/MdsConnect.fun index f64cd602bc..7f1ef67bdb 100644 --- a/tdi/remote/MdsConnect.fun +++ b/tdi/remote/MdsConnect.fun @@ -13,6 +13,7 @@ call: _host = Host name eg elpp1.epfl.ch or elpp1.epfl.ch:9000 write(*,"Host taken from MDS_HOST ["//_host//"]"); } _status = TdiShrExt->rMdsConnect(ref(_host//char(0))); - if (present(_abort) && _status == 0) abort(); + _invalid_id = -1; + if (present(_abort) && _status == _invalid_id) abort(); return(_status); } diff --git a/tdi/remote/remote_submit_helper.fun b/tdi/remote/remote_submit_helper.fun index a113cc9fd8..0b36845c62 100644 --- a/tdi/remote/remote_submit_helper.fun +++ b/tdi/remote/remote_submit_helper.fun @@ -20,17 +20,25 @@ public fun remote_submit_helper(_host,_file,_shot) if (_host == "any") { _queues = remote_submit_queues(); - _stat = 0; - while (_stat == 0) + + _start = cvttime(); + _elapsed = 0; + _max_seconds = 300; + _invalid_id = -1; + + /* Note that mdsconnect() returns a connection id, not a status code */ + _stat = _invalid_id; + while ((_stat == _invalid_id) AND (_elapsed < _max_seconds)) { _host = _queues[long(random()*size(_queues))]; write(*,"Trying ",_host); _stat = mdsconnect(_host); + _elapsed = cvttime() - _start; } } else _stat=mdsconnect(_host); - if (_stat > 0) + if (_stat > _invalid_id) { _stat=mdsvalue('tcl("spawn/nowait unix_submit '//_file//' '//_shot//'")'); } else {