Download raw body.
iscsid: cleanup initiator functions a bit
Claudio Jeker <cjeker@diehard.n-r-g.com> writes:
> The initator object is a singleton and there is no need to pass a pointer
> around for it. The result is a somewhat cleaner interaction between
> sessions and initator.
>
> Tested against netbsd-iscsi-target.
just one remark, else it is fine with me.
-struct session *
-session_new(struct initiator *i, u_int8_t st)
-{
- struct session *s;
-
- if (!(s = calloc(1, sizeof(*s))))
- return NULL;
-
- /* use the same qualifier unless there is a conflict */
- s->isid_base = i->config.isid_base;
- s->isid_qual = i->config.isid_qual;
- s->cmdseqnum = arc4random();
- s->itt = arc4random();
- s->initiator = i;
in the rewrite of `session_new()' to `initiator_new_session()', the
`initiator` member isn't copied. it is fine as it is static variable
now.
but could we remove the field from `struct session` too ?
- s->state = SESS_INIT;
-
- s->sev.sess = s;
- evtimer_set(&s->sev.ev, session_fsm_callback, &s->sev);
-
- if (st == SESSION_TYPE_DISCOVERY)
- s->target = 0;
- else
- s->target = s->initiator->target++;
-
- TAILQ_INSERT_HEAD(&i->sessions, s, entry);
- TAILQ_INIT(&s->connections);
- TAILQ_INIT(&s->tasks);
-
- return s;
-}
-
thanks
--
Sebastien Marie
iscsid: cleanup initiator functions a bit