Commit efff15e4 authored by Ryan Jackson's avatar Ryan Jackson

Modified all functions in libtmcd to be reentrant and thread-safe. Also a bit of general clean-up

parent 8ec627ba
......@@ -67,19 +67,12 @@
__count__; \
})
static int debug = 0;
static int verbose = 0;
static char fshostid[HOSTID_SIZE];
static char dbname[DBNAME_SIZE];
static struct in_addr myipaddr;
#ifdef EVENTSYS
int myevent_send(address_tuple_t address);
static event_handle_t event_handle = NULL;
int myevent_send(tmcdreq_t* reqp, address_tuple_t address);
#endif
static MYSQL_RES * mydb_query(char *query, int ncols, ...);
static int mydb_update(char *query, ...);
static MYSQL_RES * mydb_query(tmcdreq_t* reqp, char *query, int ncols, ...);
static int mydb_update(tmcdreq_t* reqp, char *query, ...);
static int safesymlink(char *name1, char *name2);
......@@ -368,14 +361,14 @@ static int numrawcommands = sizeof(raw_xml_command_array)/sizeof(struct raw_comm
* already connected. Returns 1 on failure, 0 on sucess.
*/
int
event_connect()
event_connect(tmcdreq_t *reqp)
{
if (!event_handle) {
event_handle =
if (!reqp->event_handle) {
reqp->event_handle =
event_register("elvin://localhost:" BOSSEVENTPORT, 0);
}
if (event_handle) {
if (reqp->event_handle) {
return 0;
} else {
error("event_connect: "
......@@ -388,35 +381,35 @@ event_connect()
* Send an event to the event system. Automatically connects (registers)
* if not already done. Returns 0 on sucess, 1 on failure.
*/
int myevent_send(address_tuple_t tuple) {
int myevent_send(tmcdreq_t *reqp, address_tuple_t tuple) {
event_notification_t notification;
if (event_connect()) {
if (event_connect(reqp)) {
return 1;
}
notification = event_notification_alloc(event_handle,tuple);
notification = event_notification_alloc(reqp->event_handle,tuple);
if (notification == (event_notification_t) NULL) {
error("myevent_send: Unable to allocate notification!");
return 1;
}
if (! event_notify(event_handle, notification)) {
event_notification_free(event_handle, notification);
if (! event_notify(reqp->event_handle, notification)) {
event_notification_free(reqp->event_handle, notification);
error("myevent_send: Unable to send notification!");
/*
* Let's try to disconnect from the event system, so that
* we'll reconnect next time around.
*/
if (!event_unregister(event_handle)) {
if (!event_unregister(reqp->event_handle)) {
error("myevent_send: "
"Unable to unregister with event system!");
}
event_handle = NULL;
reqp->event_handle = NULL;
return 1;
} else {
event_notification_free(event_handle,notification);
event_notification_free(reqp->event_handle,notification);
return 0;
}
}
......@@ -444,7 +437,7 @@ bievent_send(struct in_addr ipaddr, void *opaque, char *event)
tuple->objname = reqp->nodeid;
tuple->eventtype = event;
if (myevent_send(tuple)) {
if (myevent_send(reqp, tuple)) {
error("bievent_send: Error sending event\n");
return -1;
}
......@@ -452,7 +445,7 @@ bievent_send(struct in_addr ipaddr, void *opaque, char *event)
}
#endif /* EVENTSYS */
tmcdresp_t *tmcd_handle_request(int sock, char *command, char *rdata, tmcdreq_t *reqp)
tmcdresp_t *tmcd_handle_request(tmcdreq_t *reqp, int sock, char *command, char *rdata)
{
xmlDoc *doc = NULL;
xmlChar *xmlbuf;
......@@ -518,7 +511,7 @@ tmcdresp_t *tmcd_handle_request(int sock, char *command, char *rdata, tmcdreq_t
}
if (!reqp->allocated && (flags & F_ALLOCATED) != 0) {
if (verbose || (flags & F_MINLOG) == 0)
if (reqp->verbose || (flags & F_MINLOG) == 0)
error("%s: %s: Invalid request from free node\n",
reqp->nodeid, command);
goto skipit;
......@@ -529,10 +522,10 @@ tmcdresp_t *tmcd_handle_request(int sock, char *command, char *rdata, tmcdreq_t
*/
if ((flags & F_MAXLOG) != 0) {
/* XXX Ryan? overbose = verbose; */
verbose = 1;
reqp->verbose = 1;
}
#if 0
if (verbose || (xml_command_array[i].flags & F_MINLOG) == 0)
if (reqp->verbose || (xml_command_array[i].flags & F_MINLOG) == 0)
info("%s: reqp->version%d %s %s\n", reqp->nodeid,
version, cp, xml_command_array[i].cmdname);
setproctitle("%s: %s %s", reqp->nodeid, cp, xml_command_array[i].cmdname);
......@@ -540,7 +533,7 @@ tmcdresp_t *tmcd_handle_request(int sock, char *command, char *rdata, tmcdreq_t
#if 0
if ((flags & F_MAXLOG) != 0)
verbose = overbose;
reqp->verbose = overbose;
#endif
response = malloc(sizeof(tmcdresp_t));
if (response == NULL) {
......@@ -667,7 +660,7 @@ XML_COMMAND_PROTOTYPE(doifconfig)
/*
* Find all the interfaces.
*/
res = mydb_query("select i.card,i.IP,i.MAC,i.current_speed,"
res = mydb_query(reqp, "select i.card,i.IP,i.MAC,i.current_speed,"
" i.duplex,i.IPaliases,i.iface,i.role,i.mask,"
" i.rtabid,i.interface_type,vl.vname "
" from interfaces as i "
......@@ -743,7 +736,7 @@ XML_COMMAND_PROTOTYPE(doifconfig)
MYSQL_ROW row2;
int nrows2;
res2 = mydb_query("select IP "
res2 = mydb_query(reqp, "select IP "
"from vinterfaces "
"where type='alias' "
"and node_id='%s'",
......@@ -793,7 +786,7 @@ XML_COMMAND_PROTOTYPE(doifconfig)
/*
* Interface settings.
*/
res = mydb_query("select i.MAC,s.capkey,s.capval "
res = mydb_query(reqp, "select i.MAC,s.capkey,s.capval "
"from interface_settings as s "
"left join interfaces as i on "
" s.node_id=i.node_id and s.iface=i.iface "
......@@ -832,7 +825,7 @@ XML_COMMAND_PROTOTYPE(doifconfig)
/*
* First do phys interfaces underlying veth/vlan interfaces
*/
res = mydb_query("select distinct "
res = mydb_query(reqp, "select distinct "
" i.interface_type,i.mac, "
" i.current_speed,i.duplex "
" from vinterfaces as v "
......@@ -864,7 +857,7 @@ XML_COMMAND_PROTOTYPE(doifconfig)
/*
* Now do phys interfaces underlying delay interfaces.
*/
res = mydb_query("select i.interface_type,i.MAC,"
res = mydb_query(reqp, "select i.interface_type,i.MAC,"
" i.current_speed,i.duplex, "
" j.interface_type,j.MAC,"
" j.current_speed,j.duplex "
......@@ -917,7 +910,7 @@ XML_COMMAND_PROTOTYPE(doifconfig)
/*
* Find all the virtual interfaces.
*/
res = mydb_query("select v.unit,v.IP,v.mac,i.mac,v.mask,v.rtabid, "
res = mydb_query(reqp, "select v.unit,v.IP,v.mac,i.mac,v.mask,v.rtabid, "
" v.type,vll.vname,v.virtlanidx,la.attrvalue "
" from vinterfaces as v "
"left join interfaces as i on "
......@@ -993,7 +986,7 @@ XML_COMMAND_PROTOTYPE(doifconfig)
add_key(node, "vtag", tag);
}
if (verbose)
if (reqp->verbose)
info("IFCONFIG: %s", buf);
}
mysql_free_result(res);
......@@ -1024,7 +1017,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
/*
* See if a per-node-type set of projects is specified for accounts.
*/
res = mydb_query("select na.attrvalue from nodes as n "
res = mydb_query(reqp, "select na.attrvalue from nodes as n "
"left join node_type_attributes as na on "
" n.type=na.type "
"where n.node_id='%s' and "
......@@ -1043,7 +1036,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
/*
* All groups!
*/
res = mydb_query("select unix_name,unix_gid from groups", 2);
res = mydb_query(reqp, "select unix_name,unix_gid from groups", 2);
}
else if (nodetypeprojects) {
/*
......@@ -1052,7 +1045,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
* set of groups, plus those in emulab-ops since we want
* to include admin people too.
*/
res = mydb_query("select g.unix_name,g.unix_gid "
res = mydb_query(reqp, "select g.unix_name,g.unix_gid "
" from projects as p "
"left join groups as g on "
" p.pid_idx=g.pid_idx "
......@@ -1067,7 +1060,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
2, reqp->nodeid, RELOADPID);
}
else if (reqp->islocal || reqp->isvnode) {
res = mydb_query("select unix_name,unix_gid from groups "
res = mydb_query(reqp, "select unix_name,unix_gid from groups "
"where pid='%s'",
2, reqp->pid);
}
......@@ -1078,7 +1071,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
* the jails. Lets use the same query as above for now,
* but switch over to emulab-ops.
*/
res = mydb_query("select unix_name,unix_gid from groups "
res = mydb_query(reqp, "select unix_name,unix_gid from groups "
"where pid='%s'",
2, RELOADPID);
}
......@@ -1088,7 +1081,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
*
* Added this for Dave. I love subqueries!
*/
res = mydb_query("select g.unix_name,g.unix_gid "
res = mydb_query(reqp, "select g.unix_name,g.unix_gid "
" from projects as p "
"left join groups as g on p.pid=g.pid "
"where p.approved!=0 and "
......@@ -1107,7 +1100,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
* that list, then return all of the project groups, for
* each project that is allowed to get accounts on the type.
*/
res = mydb_query("select g.unix_name,g.unix_gid "
res = mydb_query(reqp, "select g.unix_name,g.unix_gid "
" from projects as p "
"join groups as g on p.pid=g.pid "
"where p.approved!=0 and "
......@@ -1150,7 +1143,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
* update after this point, the node will end up getting to
* do it again in case it missed something.
*/
if (mydb_update("update nodes set update_accounts=update_accounts-1 "
if (mydb_update(reqp, "update nodes set update_accounts=update_accounts-1 "
"where node_id='%s' and update_accounts!=0",
reqp->nodeid)) {
error("ACCOUNTS: %s: DB Error setting exit update_accounts!\n",
......@@ -1168,7 +1161,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
* experimental nodes where the number of accounts is small,
* but is not scalable.
*/
res = mydb_query("select distinct "
res = mydb_query(reqp, "select distinct "
" u.uid,u.usr_pswd,u.unix_uid,u.usr_name, "
" p.trust,g.pid,g.gid,g.unix_gid,u.admin, "
" u.emulab_pubkey,u.home_pubkey, "
......@@ -1190,7 +1183,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
* set of users, plus those in emulab-ops since we want
* to include emulab-ops people too.
*/
res = mydb_query("select distinct "
res = mydb_query(reqp, "select distinct "
"u.uid,'*',u.unix_uid,u.usr_name, "
"m.trust,g.pid,g.gid,g.unix_gid,u.admin, "
"u.emulab_pubkey,u.home_pubkey, "
......@@ -1228,7 +1221,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
* user to return. Well, a primary group and a list of aux
* groups for that user.
*/
res = mydb_query("select distinct "
res = mydb_query(reqp, "select distinct "
" u.uid,u.usr_pswd,u.unix_uid,u.usr_name, "
" p.trust,g.pid,g.gid,g.unix_gid,u.admin, "
" u.emulab_pubkey,u.home_pubkey, "
......@@ -1252,7 +1245,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
* A remote node, doing jails. We still want to return
* accounts for the admin people outside the jails.
*/
res = mydb_query("select distinct "
res = mydb_query(reqp, "select distinct "
" u.uid,'*',u.unix_uid,u.usr_name, "
" p.trust,g.pid,g.gid,g.unix_gid,u.admin, "
" u.emulab_pubkey,u.home_pubkey, "
......@@ -1283,7 +1276,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
char subclause[MYBUFSIZE];
int count = 0;
res = mydb_query("select attrvalue from node_attributes "
res = mydb_query(reqp, "select attrvalue from node_attributes "
" where node_id='%s' and "
" attrkey='dp_projects'",
1, reqp->pnodeid);
......@@ -1312,7 +1305,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
}
}
res = mydb_query("select distinct "
res = mydb_query(reqp, "select distinct "
"u.uid,'*',u.unix_uid,u.usr_name, "
"m.trust,g.pid,g.gid,g.unix_gid,u.admin, "
"u.emulab_pubkey,u.home_pubkey, "
......@@ -1490,7 +1483,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
add_key(node, "email", row[12]);
add_key(node, "shell", row[13]);
if (verbose)
if (reqp->verbose)
info("ACCOUNTS: "
"ADDUSER LOGIN=%s "
"UID=%s GID=%d ROOT=%d GLIST=%s\n",
......@@ -1509,7 +1502,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
/*
* Need a list of keys for this user.
*/
pubkeys_res = mydb_query("select idx,pubkey "
pubkeys_res = mydb_query(reqp, "select idx,pubkey "
" from user_pubkeys "
"where uid='%s'",
2, row[0]);
......@@ -1549,7 +1542,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
/*
* Need a list of SFS keys for this user.
*/
sfskeys_res = mydb_query("select comment,pubkey "
sfskeys_res = mydb_query(reqp, "select comment,pubkey "
" from user_sfskeys "
"where uid='%s'",
2, row[0]);
......@@ -1569,7 +1562,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
sfskeys_nrows--;
if (verbose)
if (reqp->verbose)
info("ACCOUNTS: SFSKEY LOGIN=%s "
"COMMENT=%s\n",
row[0], sfskey_row[0]);
......@@ -1590,7 +1583,7 @@ XML_COMMAND_PROTOTYPE(doaccounts)
* we could get some duplicate entries, which won't
* really harm anything on the client.
*/
res = mydb_query("select distinct "
res = mydb_query(reqp, "select distinct "
"u.uid,'*',u.unix_uid,u.usr_name, "
"w.trust,'guest','guest',31,u.admin, "
"u.emulab_pubkey,u.home_pubkey, "
......@@ -1630,7 +1623,7 @@ XML_COMMAND_PROTOTYPE(dodelay)
* join is to get the type out so that we can pass it back. Of
* course, this assumes that the type is the BSD name, not linux.
*/
res = mydb_query("select i.MAC,j.MAC, "
res = mydb_query(reqp, "select i.MAC,j.MAC, "
"pipe0,delay0,bandwidth0,lossrate0,q0_red, "
"pipe1,delay1,bandwidth1,lossrate1,q1_red, "
"vname, "
......@@ -1753,7 +1746,7 @@ XML_COMMAND_PROTOTYPE(dolinkdelay)
else
strcpy(buf, "and v.vnode_id is NULL");
res = mydb_query("select i.MAC,d.type,vlan,vnode,d.ip,netmask, "
res = mydb_query(reqp, "select i.MAC,d.type,vlan,vnode,d.ip,netmask, "
"pipe,delay,bandwidth,lossrate, "
"rpipe,rdelay,rbandwidth,rlossrate, "
"q_red,q_limit,q_maxthresh,q_minthresh,q_weight,q_linterm, "
......@@ -1809,7 +1802,7 @@ XML_COMMAND_PROTOTYPE(dolinkdelay)
add_key(node, "gentle", row[26]);
nrows--;
if (verbose)
if (reqp->verbose)
info("LINKDELAY: %s", buf);
}
mysql_free_result(res);
......@@ -1864,7 +1857,7 @@ XML_COMMAND_PROTOTYPE(dohosts)
* network IP address. The intent is to give plab nodes some
* convenient aliases for refering to each other.
*/
res = mydb_query("select v.vname,v.vnode,v.ip,v.vport,v2p.node_id,"
res = mydb_query(reqp, "select v.vname,v.vnode,v.ip,v.vport,v2p.node_id,"
"v.protocol,i.IP "
" from virt_lans as v "
"left join v2pmap as v2p on "
......@@ -2064,7 +2057,7 @@ XML_COMMAND_PROTOTYPE(dohosts)
* List of control net addresses for jailed nodes.
* Temporary.
*/
res = mydb_query("select r.node_id,r.vname,n.jailip "
res = mydb_query(reqp, "select r.node_id,r.vname,n.jailip "
" from reserved as r "
"left join nodes as n on n.node_id=r.node_id "
"where r.pid='%s' and r.eid='%s' "
......@@ -2109,7 +2102,7 @@ XML_COMMAND_PROTOTYPE(dorpms)
/*
* Get RPM list for the node.
*/
res = mydb_query("select rpms from nodes where node_id='%s' ",
res = mydb_query(reqp, "select rpms from nodes where node_id='%s' ",
1, reqp->nodeid);
if (!res) {
......@@ -2157,7 +2150,7 @@ XML_COMMAND_PROTOTYPE(dotarballs)
/*
* Get Tarball list for the node.
*/
res = mydb_query("select tarballs from nodes where node_id='%s' ",
res = mydb_query(reqp, "select tarballs from nodes where node_id='%s' ",
1, reqp->nodeid);
if (!res) {
......@@ -2220,7 +2213,7 @@ XML_COMMAND_PROTOTYPE(dostartcmd)
/*
* Get run command for the node.
*/
res = mydb_query("select startupcmd from nodes where node_id='%s'",
res = mydb_query(reqp, "select startupcmd from nodes where node_id='%s'",
1, reqp->nodeid);
if (!res) {
......@@ -2268,7 +2261,7 @@ XML_COMMAND_PROTOTYPE(dostartstat)
return 1;
}
if (verbose)
if (reqp->verbose)
info("STARTSTAT: "
"%s is reporting startup command exit status: %d\n",
reqp->nodeid, exitstatus);
......@@ -2278,7 +2271,7 @@ XML_COMMAND_PROTOTYPE(dostartstat)
* field to a non-null string value is enough to tell whoever is
* watching it that the node is done.
*/
if (mydb_update("update nodes set startstatus='%d' "
if (mydb_update(reqp, "update nodes set startstatus='%d' "
"where node_id='%s'", exitstatus, reqp->nodeid)) {
error("STARTSTAT: %s: DB Error setting exit status!\n",
reqp->nodeid);
......@@ -2301,14 +2294,14 @@ XML_COMMAND_PROTOTYPE(doready)
/*
* Update the ready_bits table.
*/
if (mydb_update("update nodes set ready=1 "
if (mydb_update(reqp, "update nodes set ready=1 "
"where node_id='%s'", reqp->nodeid)) {
error("READY: %s: DB Error setting ready bit!\n",
reqp->nodeid);
return 1;
}
if (verbose)
if (reqp->verbose)
info("READY: %s: Node is reporting ready\n", reqp->nodeid);
/*
......@@ -2338,7 +2331,7 @@ XML_COMMAND_PROTOTYPE(doreadycount)
* keep asking until N and M are equal. Can only be used once
* of course, after experiment creation.
*/
res = mydb_query("select ready from reserved "
res = mydb_query(reqp, "select ready from reserved "
"left join nodes on nodes.node_id=reserved.node_id "
"where reserved.eid='%s' and reserved.pid='%s'",
1, reqp->eid, reqp->pid);
......@@ -2384,7 +2377,7 @@ XML_COMMAND_PROTOTYPE(domounts)
* Should SFS mounts be served?
*/
usesfs = 0;
if (strlen(fshostid)) {
if (strlen(reqp->fshostid)) {
if (strlen(reqp->sfshostid))
usesfs = 1;
else {
......@@ -2395,7 +2388,7 @@ XML_COMMAND_PROTOTYPE(domounts)
usesfs = 1;
}
if (verbose) {
if (reqp->verbose) {
if (usesfs) {
info("Using SFS\n");
}
......@@ -2494,14 +2487,14 @@ XML_COMMAND_PROTOTYPE(domounts)
*/
if (reqp->islocal) {
node = new_response(mount_node, "sfs");
snprintf(buf, sizeof(buf), "%s%s/%s", fshostid,
snprintf(buf, sizeof(buf), "%s%s/%s", reqp->fshostid,
FSDIR_PROJ, reqp->pid);
add_key(node, "remote", buf);
add_format_key(node, "local", "%s/%s", PROJDIR,
reqp->pid);
#if 0
if (verbose)
if (reqp->verbose)
info("MOUNTS: %s", buf);
#endif
......@@ -2510,7 +2503,7 @@ XML_COMMAND_PROTOTYPE(domounts)
*/
if (strcmp(reqp->pid, reqp->gid)) {
node = new_response(mount_node, "sfs");
snprintf(buf, sizeof(buf), "%s%s/%s/%s", fshostid,
snprintf(buf, sizeof(buf), "%s%s/%s/%s", reqp->fshostid,
FSDIR_GROUPS, reqp->pid, reqp->gid);
add_key(node, "remote", buf);
snprintf(buf, sizeof(buf), "%s/%s/%s", GROUPDIR,
......@@ -2527,13 +2520,13 @@ XML_COMMAND_PROTOTYPE(domounts)
*/
node = new_response(mount_node, "sfs");
snprintf(buf, sizeof(buf), "%s%s/%s", fshostid,
snprintf(buf, sizeof(buf), "%s%s/%s", reqp->fshostid,
FSDIR_SCRATCH, reqp->pid);
add_key(node, "remote", buf);
add_format_key(node, "local", "%s/%s", SCRATCHDIR, reqp->pid);
/*
if (verbose)
if (reqp->verbose)
info("MOUNTS: %s", buf);
*/
#endif
......@@ -2542,13 +2535,13 @@ XML_COMMAND_PROTOTYPE(domounts)
* Pointer to /share.
*/
node = new_response(mount_node, "sfs");
snprintf(buf, sizeof(buf), "%s%s", fshostid,
snprintf(buf, sizeof(buf), "%s%s", reqp->fshostid,
FSDIR_SHARE);
add_key(node, "remote", buf);
add_format_key(node, "local", "%s", SHAREDIR);
/*
if (verbose)
if (reqp->verbose)
info("MOUNTS: %s", buf);
*/
#endif
......@@ -2559,7 +2552,7 @@ XML_COMMAND_PROTOTYPE(domounts)
* nodes.
*/
node = new_response(mount_node, "sfs");
snprintf(buf, sizeof(buf), "%s%s/%s", fshostid,
snprintf(buf, sizeof(buf), "%s%s/%s", reqp->fshostid,
FSDIR_PROJ, DOTSFS);
add_key(node, "remote", buf);
add_format_key(node, "local", "%s%s", PROJDIR, DOTSFS);
......@@ -2572,13 +2565,13 @@ XML_COMMAND_PROTOTYPE(domounts)
* Pointer to /proj.
*/
node = new_response(mount_node, "sfs");
snprintf(buf, sizeof(buf), "%s%s", fshostid,
snprintf(buf, sizeof(buf), "%s%s", reqp->fshostid,
FSDIR_PROJ);
add_key(node, "remote", buf);
add_format_key(node, "local", "%s/%s", NETBEDDIR, PROJDIR);
#if 0
if (verbose)
if (reqp->verbose)
info("MOUNTS: %s", buf);
#endif
......@@ -2586,13 +2579,13 @@ XML_COMMAND_PROTOTYPE(domounts)
* Pointer to /groups
*/
node = new_response(mount_node, "sfs");
snprintf(buf, sizeof(buf), "%s%s", fshostid,
snprintf(buf, sizeof(buf), "%s%s", reqp->fshostid,
FSDIR_GROUPS);
add_key(node, "remote", buf);
add_format_key(node, "local", "%s%s", NETBEDDIR, PROJDIR);
#if 0
if (verbose)
if (reqp->verbose)
info("MOUNTS: %s", buf);
#endif
......@@ -2600,13 +2593,13 @@ XML_COMMAND_PROTOTYPE(domounts)
* Pointer to /users
*/
node = new_response(mount_node, "sfs");
snprintf(buf, sizeof(buf), "%s%s", fshostid,
snprintf(buf, sizeof(buf), "%s%s", reqp->fshostid,
FSDIR_USERS);
add_key(node, "remote", buf);
add_format_key(node, "local", "%s%s", NETBEDDIR, USERDIR);
#if 0
if (verbose)
if (reqp->verbose)
info("MOUNTS: %s", buf);
#endif
#ifdef FSSCRATCHDIR
......@@ -2614,13 +2607,13 @@ XML_COMMAND_PROTOTYPE(domounts)
* Pointer to per-project scratch directory.
*/
node = new_response(mount_node, "sfs");
snprintf(buf, sizeof(buf), "%s%s", fshostid,
snprintf(buf, sizeof(buf), "%s%s", reqp->fshostid,
FSDIR_SCRATCH);
add_key(node, "remote", buf);
add_format_key(node, "local", "%s/%s", NETBEDDIR, SCRATCHDIR);
#if 0
if (verbose)
if (reqp->verbose)
info("MOUNTS: %s", buf);
#endif
#endif
......@@ -2629,13 +2622,13 @@ XML_COMMAND_PROTOTYPE(domounts)
* Pointer to /share.
*/
node = new_response(mount_node, "sfs");
snprintf(buf, sizeof(buf), "%s%s", fshostid,
snprintf(buf, sizeof(buf), "%s%s", reqp->fshostid,
FSDIR_SHARE);
add_key(node, "remote", buf);
add_format_key(node, "local", "%s%s", NETBEDDIR, SHAREDIR);
#if 0
if (verbose)
if (reqp->verbose)
info("MOUNTS: %s", buf);
#endif
#endif
......@@ -2652,7 +2645,7 @@ XML_COMMAND_PROTOTYPE(domounts)
* Now check for aux project access. Return a list of mounts for
* those projects.
*/
res = mydb_query("select pid from exppid_access "
res = mydb_query(reqp, "select pid from exppid_access "
"where exp_pid='%s' and exp_eid='%s'",
1, reqp->pid, reqp->eid);
if (!res) {
......@@ -2680,7 +2673,7 @@ XML_COMMAND_PROTOTYPE(domounts)
* that have been granted access to share the nodes in that expt.
*/
#ifdef NOSHAREDEXPTS
res = mydb_query("select u.uid from users as u "
res = mydb_query(reqp, "select u.uid from users as u "
"left join group_membership as p on "
" p.uid_idx=u.uid_idx "
"where p.pid='%s' and p.gid='%s' and "
......@@ -2689,7 +2682,7 @@ XML_COMMAND_PROTOTYPE(domounts)
" p.trust!='none'",
1, reqp->pid, reqp->gid);
#else
res = mydb_query("select distinct u.uid from users as u "
res = mydb_query(reqp, "select distinct u.uid from users as u "
"left join exppid_access as a "
" on a.exp_pid='%s' and a.exp_eid='%s' "
"left join group_membership as p on "
......@@ -2720,7 +2713,7 @@ XML_COMMAND_PROTOTYPE(domounts)
add_format_key(node, "local", "%s/%s", USERDIR, row[0]);
nrows--;
if (verbose)
if (reqp->verbose)
info("MOUNTS: %s", buf);
}
mysql_free_result(res);
......@@ -2776,7 +2769,7 @@ XML_COMMAND_PROTOTYPE(dosfshostid)
char sfspath[BUFSIZ], dspath[BUFSIZ];
xmlNode *node;
if (!strlen(fshostid)) {
if (!strlen(reqp->fshostid)) {
/* SFS not being used */
info("dosfshostid: Called while SFS is not in use\n");
return 0;
......@@ -2824,13 +2817,13 @@ XML_COMMAND_PROTOTYPE(dosfshostid)
*/
mysql_escape_string(buf, nodehostid, strlen(nodehostid));
if (mydb_update("update node_hostkeys set sfshostid='%s' "
if (mydb_update(reqp, "update node_hostkeys set sfshostid='%s' "
"where node_id='%s'", buf, reqp->nodeid)) {
error("SFSHOSTID: %s: DB Error setting sfshostid!\n",
reqp->nodeid);
return 1;
}