Commit df81955d authored by Pekka Pessi's avatar Pekka Pessi

Keeping track of soa instance name.

darcs-hash:20050928194342-65a35-92d362478fdf88d647a7357c18e64a198cab49ab.gz
parent be599de0
......@@ -200,6 +200,7 @@ soa_session_t *soa_create(char const *name,
struct soa_session_actions const *actions = &soa_default_actions;
soa_session_t *ss;
size_t namelen;
if (name && name[0]) {
struct soa_namenode const *n;
......@@ -214,17 +215,22 @@ soa_session_t *soa_create(char const *name,
actions = n->actions; assert(actions);
}
else
name = "default";
assert(SOA_VALID_ACTIONS(actions));
if (root == NULL)
return (void)(errno = EFAULT), NULL;
ss = su_home_new(actions->sizeof_soa_session);
namelen = strlen(name) + 1;
ss = su_home_new(actions->sizeof_soa_session + namelen);
if (ss) {
ss->ss_root = root;
ss->ss_magic = magic;
ss->ss_actions = actions;
ss->ss_name = strcpy((char *)ss + actions->sizeof_soa_session, name);
if (ss->ss_actions->soa_init(name, ss, NULL) < 0)
ss->ss_actions->soa_deinit(ss), ss = NULL;
......@@ -238,15 +244,20 @@ soa_session_t *soa_clone(soa_session_t *parent_ss,
soa_magic_t *magic)
{
soa_session_t *ss;
size_t namelen;
if (parent_ss == NULL || root == NULL)
return (void)(errno = EFAULT), NULL;
ss = su_home_new(parent_ss->ss_actions->sizeof_soa_session);
namelen = strlen(parent_ss->ss_name) + 1;
ss = su_home_new(parent_ss->ss_actions->sizeof_soa_session + namelen);
if (ss) {
ss->ss_root = root;
ss->ss_magic = magic;
ss->ss_actions = parent_ss->ss_actions;
ss->ss_name = strcpy((char *)ss + ss->ss_actions->sizeof_soa_session,
parent_ss->ss_name);
if (ss->ss_actions->soa_init(NULL, ss, parent_ss) < 0)
ss->ss_actions->soa_deinit(ss), ss = NULL;
......
......@@ -122,6 +122,7 @@ struct soa_session
su_home_t ss_home[1];
struct soa_session_actions const *ss_actions;
char const *ss_name; /**< Our name */
su_root_t *ss_root;
soa_magic_t *ss_magic; /**< Application data */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment