fix agent bugs

This commit is contained in:
xenia 2020-12-12 22:26:16 -05:00
parent da1e3f16bd
commit 630c1b96f0
3 changed files with 19 additions and 15 deletions

View File

@ -167,9 +167,11 @@
(define num-cpus (count-cpus))
;; TODO : handle smp
(define pattern (manifest-pattern manifest))
(for ([interval (in-list work-range)])
(define pp-start (resolve-pattern-pos (pos->pattern-pos (car interval))))
(define pp-end (resolve-pattern-pos (pos->pattern-pos (cdr interval))))
(define pp-start (resolve-pattern-pos pattern (pos->pattern-pos pattern (car interval))))
(define pp-end (resolve-pattern-pos pattern (pos->pattern-pos pattern (cdr interval))))
(define args (for/fold ([args '()]) ([pps (in-vector pp-start)] [ppe (in-vector pp-end)])
;; TODO : this isn't very efficient...
(append args (list (number->string (car pps) 16)
@ -181,16 +183,20 @@
(parameterize ([current-custodian cust])
(apply subprocess #f #f (current-error-port) 'new (append cmd args))))
(with-handlers ([exn:break (lambda (_) (subprocess-kill proc #f)
(with-handlers ([exn:break? (lambda (_) (subprocess-kill proc #f)
(sync/timeout *subproc-kill-delay* proc)
;; will handle killing for us :P
(custodian-shutdown-all cust)
;; exit without reporting status
(kill-thread (current-thread)))])
(define line-match (regexp-match-evt #px"^[^\n]*\n" out))
(define line-match (regexp-match-evt #px"^[^\n]*\n" in))
(let loop ()
(match (sync proc line-match)
[(== proc) (void "TODO")]
[(== proc)
;; error if it's nonzero, otherwise stop looping
(unless (zero? (subprocess-status proc))
;; TODO : report stderr i guess
(error "got nonzero return status" (subprocess-status proc)))]
[(list line)
(define line-parts (map (lambda (x) (string->number x 16))
(string-split line " ")))
@ -202,9 +208,7 @@
(log-agent-warning "assignment ~a input loop got unparseable line ~a" aid line))
(loop)]
[x (log-agent-warning "assignment ~a input loop got unexpected value ~a" aid x)
(loop)])))
(void "TODO")))
(loop)])))))
(cleanup)
(void))

View File

@ -68,7 +68,7 @@
(struct manifest [data pattern psize] #:transparent)
(provide (contract-out
[struct manifest ((data manifest-def/c)
(pattern (vector/c integer-set?))
(pattern (vectorof integer-set?))
(psize integer?))]))

View File

@ -366,7 +366,7 @@
(define file-hash (server-hash-file id))
(define sema (make-semaphore 1))
(define agent-todo (make-hash))
(define init-pattern-range (range->integer-set 0 (manifest-psize mf)))
(define init-pattern-range (range->integer-set 0 (sub1 (manifest-psize mf))))
;; subtract the pattern ranges that were already logged as complete
(define-values [pattern-range completed-work]
(for/fold ([pattern-range init-pattern-range]