9 make_tube(const char *name
)
15 strncpy(t
->name
, name
, MAX_TUBE_NAME_LEN
);
16 if (t
->name
[MAX_TUBE_NAME_LEN
- 1] != '\0') {
17 t
->name
[MAX_TUBE_NAME_LEN
- 1] = '\0';
18 twarnx("truncating tube name");
21 t
->ready
.less
= job_pri_less
;
22 t
->delay
.less
= job_delay_less
;
23 t
->ready
.setpos
= job_setpos
;
24 t
->delay
.setpos
= job_setpos
;
26 Job j
= {.tube
= NULL
};
28 t
->buried
.prev
= t
->buried
.next
= &t
->buried
;
29 ms_init(&t
->waiting_conns
, NULL
, NULL
);
40 ms_clear(&t
->waiting_conns
);
49 twarnx("refs is zero for tube: %s", t
->name
);
66 make_and_insert_tube(const char *name
)
75 /* We want this global tube list to behave like "weak" refs, so don't
76 * increment the ref count. */
77 r
= ms_append(&tubes
, t
);
79 return tube_dref(t
), (Tube
*) 0;
85 tube_find(Ms
*tubeset
, const char *name
)
89 for (i
= 0; i
< tubeset
->len
; i
++) {
90 Tube
*t
= tubeset
->items
[i
];
91 if (strncmp(t
->name
, name
, MAX_TUBE_NAME_LEN
) == 0)
98 tube_find_or_make(const char *name
)
100 Tube
*t
= tube_find(&tubes
, name
);
103 return make_and_insert_tube(name
);