Changeset 102f641 in mainline for uspace/srv/sysman/job_closure.c
- Timestamp:
- 2019-09-02T19:01:50Z (6 years ago)
- Children:
- 25697163
- Parents:
- 241f1985
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/job_closure.c
r241f1985 r102f641 37 37 #include "log.h" 38 38 39 40 39 /** Struct describes how to traverse units graph */ 41 40 struct bfs_ops; … … 52 51 * return result of visit (error stops further traversal) 53 52 */ 54 int (* 53 int (*visit)(unit_t *, unit_edge_t *, bfs_ops_t *, void *); 55 54 56 55 /** Clean units remaining in BFS queue after error */ 57 void (* 56 void (*clean)(unit_t *, bfs_ops_t *, void *); 58 57 }; 59 58 … … 65 64 { 66 65 assert(blocking_job->blocked_jobs.size == 67 66 blocking_job->blocked_jobs_count); 68 67 69 68 int rc = dyn_array_append(&blocking_job->blocked_jobs, job_t *, … … 203 202 unit->bfs_tag = true; 204 203 list_append(&unit->bfs_link, &units_fifo); 205 204 206 205 while (!list_empty(&units_fifo)) { 207 206 unit = list_get_instance(list_first(&units_fifo), unit_t, … … 209 208 list_remove(&unit->bfs_link); 210 209 211 212 if (ops->direction == BFS_FORWARD) 213 list_foreach(unit->edges_out, edges_out, unit_edge_t, e) { 214 unit_t *u = e->output; 215 if (!u->bfs_tag) { 216 u->bfs_tag = true; 217 list_append(&u->bfs_link, &units_fifo); 210 if (ops->direction == BFS_FORWARD) { 211 list_foreach(unit->edges_out, edges_out, unit_edge_t, e) { 212 unit_t *u = e->output; 213 if (!u->bfs_tag) { 214 u->bfs_tag = true; 215 list_append(&u->bfs_link, &units_fifo); 216 } 217 rc = ops->visit(u, e, ops, arg); 218 if (rc != EOK) { 219 goto finish; 220 } 218 221 } 219 rc = ops->visit(u, e, ops, arg); 220 if (rc != EOK) { 221 goto finish; 222 } 223 } else 224 list_foreach(unit->edges_in, edges_in, unit_edge_t, e) { 225 unit_t *u = e->input; 226 if (!u->bfs_tag) { 227 u->bfs_tag = true; 228 list_append(&u->bfs_link, &units_fifo); 229 } 230 rc = ops->visit(u, e, ops, arg); 231 if (rc != EOK) { 232 goto finish; 222 } else { 223 list_foreach(unit->edges_in, edges_in, unit_edge_t, e) { 224 unit_t *u = e->input; 225 if (!u->bfs_tag) { 226 u->bfs_tag = true; 227 list_append(&u->bfs_link, &units_fifo); 228 } 229 rc = ops->visit(u, e, ops, arg); 230 if (rc != EOK) { 231 goto finish; 232 } 233 233 } 234 234 } … … 243 243 list_remove(cur_link); 244 244 } 245 245 246 246 return rc; 247 247 } … … 349 349 } 350 350 351 352 351 /* Clean after ourselves (BFS tag jobs) */ 353 352 dyn_array_foreach(*job_closure, job_t *, job_it) { … … 360 359 return rc; 361 360 } 362
Note:
See TracChangeset
for help on using the changeset viewer.