Changeset db34424 in mainline


Ignore:
Timestamp:
2019-08-07T09:37:45Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
cf172c5
Parents:
9532981
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-11-03 00:15:00)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 09:37:45)
Message:

sysman: Simple check for multiedges in graph

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/sysman/edge.c

    r9532981 rdb34424  
    4141}
    4242
     43static unit_edge_t *edge_extract_internal(unit_t *input, unit_t *output)
     44{
     45        list_foreach(input->edges_out, edges_out, unit_edge_t, e) {
     46                if (e->output == output) {
     47                        return e;
     48                }
     49        }
     50
     51        return NULL;
     52}
     53
    4354unit_edge_t *edge_create(void)
    4455{
     
    6879int edge_sprout_out(unit_t *input, const char *output_name)
    6980{
     81        int rc;
    7082        unit_edge_t *e = edge_create();
    71         int rc;
    7283
    7384        if (e == NULL) {
     
    7687        }
    7788
     89        //TODO check multi-edges
    7890        e->output_name = str_dup(output_name);
    7991        if (e->output_name == NULL) {
     
    94106}
    95107
    96 void edge_resolve_output(unit_edge_t *e, unit_t *unit)
     108void edge_resolve_output(unit_edge_t *e, unit_t *output)
    97109{
    98110        assert(e->output == NULL);
    99111        assert(e->output_name != NULL);
    100112
    101         // TODO add to other side edges_in list
    102         e->output = unit;
     113        e->output = output;
     114        list_append(&e->edges_in, output->edges_id);
     115
    103116        free(e->output_name);
    104117        e->output_name = NULL;
     
    109122 * @return        EOK on success
    110123 * @return        ENOMEM
     124 * @return        EEXISTS
    111125 */
    112126int edge_connect(unit_t *input, unit_t *output)
    113127{
     128        if (edge_extract_internal(input, output)) {
     129                return EEXISTS;
     130        }
     131
    114132        unit_edge_t *e = edge_create();
    115133        if (e == NULL) {
     
    117135        }
    118136
    119         // TODO check existence of the e
    120         // TODO locking
    121         // TODO check types and states of connected units
    122137        list_append(&e->edges_in, &output->edges_in);
    123138        list_append(&e->edges_out, &input->edges_out);
     
    128143}
    129144
    130 /** Remove output from output graph
     145/** Remove edge from dependency graph
    131146 *
    132  * Given output is removed from graph and unallocated.
     147 * Given edge is removed from graph and unallocated.
    133148 */
    134149void edge_remove(unit_edge_t **e_ptr)
    135150{
    136         // TODO here should be some checks, othewise replace this wrapper with
    137         //      direct destroy
     151        /*
     152         * So far it's just passing, however, edge_destroy is considered
     153         * low-level and edge_remove could later e.g. support transactions.
     154         */
    138155        edge_destroy(e_ptr);
    139156}
Note: See TracChangeset for help on using the changeset viewer.