Changeset 81c4e6ec in mainline for uspace/srv/sysman/job_closure.c
- Timestamp:
- 2020-07-05T20:46:27Z (5 years ago)
- Parents:
- a73aaec1
- git-author:
- Matthieu Riolo <matthieu.riolo@…> (2020-07-05 20:37:10)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2020-07-05 20:46:27)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/job_closure.c
ra73aaec1 r81c4e6ec 63 63 static errno_t job_add_blocked_job(job_t *blocking_job, job_t *blocked_job) 64 64 { 65 assert( blocking_job->blocked_jobs.size==65 assert(list_count(&blocking_job->blocked_jobs) == 66 66 blocking_job->blocked_jobs_count); 67 67 68 errno_t rc = array_append(&blocking_job->blocked_jobs, job_t *, 69 blocked_job); 70 if (rc != EOK) { 68 job_link_t *job_link = calloc(1, sizeof(job_link_t)); 69 if (job_link == NULL) { 71 70 return ENOMEM; 72 71 } 72 73 job_link->job = blocked_job; 74 75 list_append(&job_link->link, &blocking_job->blocked_jobs); 76 73 77 job_add_ref(blocked_job); 74 78 … … 97 101 goto finish; 98 102 } 99 job_t *first_job = array_last(closure, job_t *); 103 104 link_t *last_link = list_last(closure); 105 job_link_t *job_link = list_get_instance(last_link, job_link_t, link); 106 job_t *first_job = job_link->job; 100 107 101 108 job_add_ref(first_job); … … 118 125 } 119 126 127 job_link_t *job_link = calloc(1, sizeof(job_link_t)); 128 if (job_link == NULL) { 129 goto finish; 130 } 131 132 job_link->job = created_job; 133 120 134 /* Pass job reference to closure and add one for unit */ 121 rc = array_append(closure, job_t *, created_job); 122 if (rc != EOK) { 123 goto finish; 124 } 135 list_append(&job_link->link, closure); 125 136 126 137 job_add_ref(created_job); … … 164 175 } 165 176 177 job_link_t *job_link = calloc(1, sizeof(job_link_t)); 178 if (job_link == NULL) { 179 goto finish; 180 } 181 182 job_link->job = created_job; 183 166 184 /* Pass job reference to closure and add one for unit */ 167 rc = array_append(closure, job_t *, created_job); 168 if (rc != EOK) { 169 goto finish; 170 } 185 list_append(&job_link->link, closure); 171 186 } 172 187 rc = visit_propagate_job(u, e, ops, closure); … … 308 323 } 309 324 310 errno_t rc = array_append(job_closure, job_t *, main_job); 311 if (rc != EOK) { 312 return rc; 313 } 325 job_link_t *job_link = calloc(1, sizeof(job_link_t)); 326 if (job_link == NULL) { 327 return ENOMEM; 328 } 329 330 job_link->job = main_job; 331 332 list_append(&job_link->link, job_closure); 333 314 334 job_add_ref(main_job); /* Add one for the closure */ 315 335 … … 330 350 } 331 351 332 rc = bfs_traverse_component(main_job->unit, &propagate_ops, job_closure);352 errno_t rc = bfs_traverse_component(main_job->unit, &propagate_ops, job_closure); 333 353 334 354 sysman_log(LVL_DEBUG2, "%s: %i&%i", __func__, flags, CLOSURE_ISOLATE); … … 343 363 344 364 if (rc == EOK) { 345 array_foreach(*job_closure, job_t *, job_it) { 365 list_foreach(*job_closure, link, job_link_t, job_it) { 366 job_t *job = job_it->job; 346 367 sysman_log(LVL_DEBUG2, "%s\t%s, refs: %u", __func__, 347 unit_name( (*job_it)->unit), atomic_load(&(*job_it)->refcnt));368 unit_name(job->unit), atomic_load(&job->refcnt)); 348 369 } 349 370 } 350 371 351 372 /* Clean after ourselves (BFS tag jobs) */ 352 array_foreach(*job_closure, job_t *, job_it) {353 job_t *j = (*job_it)->unit->bfs_data;354 assert( *job_it== j);373 list_foreach(*job_closure, link, job_link_t, job_it) { 374 job_t *j = job_it->job->unit->bfs_data; 375 assert(job_it->job == j); 355 376 job_del_ref(&j); 356 (*job_it)->unit->bfs_data = NULL;357 } 358 359 return rc; 360 } 377 job_it->job->unit->bfs_data = NULL; 378 } 379 380 return rc; 381 }
Note:
See TracChangeset
for help on using the changeset viewer.