Commit 15fc15b7 authored by Ryan Jackson's avatar Ryan Jackson

Fixed segfault in event/new_sched

Fixed a segfault in the new event scheduler

Cleaned up some code that dealt with converting
xmlrpc_c::value_strings to C string constants to avoid further memory
corruption issues.

Also converted AddAgent(), AddGroup(), AddUserEnv() to take 'const
char *' pointers instead of 'char *'s to silence GCC's warnings about
invalid conversions from 'const char *' to 'char *'.
parent 3a96cf99
......@@ -63,7 +63,7 @@ EmulabResponse::~EmulabResponse()
}
ServerProxy::ServerProxy(xmlrpc_c::clientXmlTransportPtr transport,
ServerProxy::ServerProxy(xmlrpc_c::clientXmlTransport *transport,
bool wbxml_mode,
const char *url)
{
......
......@@ -135,7 +135,7 @@ class ServerProxy
* @param wbxml_mode Indicate whether or not wbxml should be used.
* @param url The url to use.
*/
ServerProxy(xmlrpc_c::clientXmlTransportPtr transport,
ServerProxy(xmlrpc_c::clientXmlTransport *transport,
bool wbxml_mode = false,
const char *url = "");
......@@ -176,7 +176,7 @@ class ServerProxy
private:
xmlrpc_c::value call(xmlrpc_c::rpcPtr rpc);
xmlrpc_c::clientXmlTransportPtr transport;
xmlrpc_c::clientXmlTransport *transport;
std::string server_url;
};
......
......@@ -997,7 +997,7 @@ SetExpPath(const char *path)
}
int
AddUserEnv(char *name, char *path)
AddUserEnv(const char *name, const char *path)
{
int retval = 0;
FILE *file;
......@@ -1042,7 +1042,8 @@ AddUserEnv(char *name, char *path)
*/
int
AddAgent(event_handle_t handle,
char *vname, char *vnode, char *nodeid, char *ipaddr, char *type)
const char *vname, const char *vnode, const char *nodeid,
const char *ipaddr, const char *type)
{
struct agent *agentp;
......@@ -1173,7 +1174,7 @@ AddAgent(event_handle_t handle,
* Add an agent group to the list.
*/
int
AddGroup(event_handle_t handle, char *groupname, char *agentname)
AddGroup(event_handle_t handle, const char *groupname, const char *agentname)
{
struct agent *group = NULL, *agent;
int retval = 0;
......@@ -1238,8 +1239,9 @@ AddGroup(event_handle_t handle, char *groupname, char *agentname)
int
AddEvent(event_handle_t handle, address_tuple_t tuple,
char *exidx, char *ftime, char *objname, char *exargs,
char *objtype, char *evttype, char *parent, char *triggertype)
const char *exidx, const char *ftime, const char *objname,
const char *exargs, const char *objtype, const char *evttype,
const char *parent, const char *triggertype)
{
timeline_agent_t ta = NULL;
sched_event_t event;
......
......@@ -299,14 +299,15 @@ RPC_metadata(char *pid, char *eid)
int lpc;
for (lpc = 0; lpc < userenv.size(); lpc++) {
char *name, *value;
string name, value;
map<string, xmlrpc_c::value> ue;
ue = (xmlrpc_c::value_struct)userenv[lpc];
name = (char *)((string)(xmlrpc_c::value_string)ue["name"]).c_str();
value = (char *)((string)(xmlrpc_c::value_string)ue["value"]).c_str();
name = (xmlrpc_c::value_string)ue["name"];
value = (xmlrpc_c::value_string)ue["value"];
if ((retval = AddUserEnv(name, value)) != 0)
if ((retval = AddUserEnv(name.c_str(),
value.c_str())) != 0)
return retval;
}
}
......@@ -585,17 +586,18 @@ RPC_agentlist(event_handle_t handle, char *pid, char *eid)
((xmlrpc_c::value_array)er.getValue()).vectorValueValue();
for (i = 0; i < agents.size(); i++) {
char *vname, *vnode, *nodeid, *ipaddr, *type;
string vname, vnode, nodeid, ipaddr, type;
vector<xmlrpc_c::value>agent =
((xmlrpc_c::value_array)agents[i]).vectorValueValue();
vname = (char *)((string)(xmlrpc_c::value_string)agent[0]).c_str();
vnode = (char *)((string)(xmlrpc_c::value_string)agent[1]).c_str();
nodeid = (char *)((string)(xmlrpc_c::value_string)agent[2]).c_str();
ipaddr = (char *)((string)(xmlrpc_c::value_string)agent[3]).c_str();
type = (char *)((string)(xmlrpc_c::value_string)agent[4]).c_str();
info("D: adding agent %s\n", vname);
if (AddAgent(handle, vname, vnode, nodeid, ipaddr, type) < 0) {
vname = (xmlrpc_c::value_string)agent[0];
vnode = (xmlrpc_c::value_string)agent[1];
nodeid = (xmlrpc_c::value_string)agent[2];
ipaddr = (xmlrpc_c::value_string)agent[3];
type = (xmlrpc_c::value_string)agent[4];
info("D: adding agent %s\n", (char *)vname.c_str());
if (AddAgent(handle, vname.c_str(), vnode.c_str(),
nodeid.c_str(), ipaddr.c_str(), type.c_str()) < 0) {
return -1;
}
}
......@@ -616,16 +618,19 @@ RPC_grouplist(event_handle_t handle, char *pid, char *eid)
((xmlrpc_c::value_array)er.getValue()).vectorValueValue();
for (i = 0; i < groups.size(); i++) {
char *groupname, *agentname;
string groupname, agentname;
vector<xmlrpc_c::value> group =
((xmlrpc_c::value_array)groups[i]).vectorValueValue();
groupname = (char *)((string)(xmlrpc_c::value_string)group[0]).c_str();
info("D: \tIn GroupList() parsed name %s\n", groupname);
agentname = (char *)((string)(xmlrpc_c::value_string)group[1]).c_str();
info("D: \tIn GroupList() parsed agent %s\n", agentname);
groupname = (xmlrpc_c::value_string)group[0];
info("D: \tIn GroupList() parsed name %s\n",
(char *)groupname.c_str());
agentname = (xmlrpc_c::value_string)group[1];
info("D: \tIn GroupList() parsed agent %s\n",
(char *)agentname.c_str());
if (AddGroup(handle, groupname, agentname) != 0) {
if (AddGroup(handle, groupname.c_str(),
agentname.c_str()) != 0) {
return -1;
}
}
......@@ -656,25 +661,27 @@ RPC_eventlist(char *pid, char *eid,
// info("rpc.cc:RPC_eventlist(): Interating over invoke results\n");
// XXX
for (i = 0; i < events.size(); i++) {
char *exidx, *extime, *objname, *objtype, *evttype, *exargs;
char *parent, *triggertype;
string exidx, extime, objname, objtype, evttype, exargs;
string parent, triggertype;
vector<xmlrpc_c::value> event =
((xmlrpc_c::value_array)events[i]).vectorValueValue();
exidx = (char *)((string)(xmlrpc_c::value_string)event[0]).c_str();
extime = (char *)((string)(xmlrpc_c::value_string)event[1]).c_str();
objname = (char *)((string)(xmlrpc_c::value_string)event[2]).c_str();
objtype = (char *)((string)(xmlrpc_c::value_string)event[3]).c_str();
evttype = (char *)((string)(xmlrpc_c::value_string)event[4]).c_str();
exargs = (char *)((string)(xmlrpc_c::value_string)event[5]).c_str();
parent = (char *)((string)(xmlrpc_c::value_string)event[6]).c_str();
triggertype = (char *)((string)(xmlrpc_c::value_string)event[7]).c_str();
exidx = (xmlrpc_c::value_string)event[0];
extime = (xmlrpc_c::value_string)event[1];
objname = (xmlrpc_c::value_string)event[2];
objtype = (xmlrpc_c::value_string)event[3];
evttype = (xmlrpc_c::value_string)event[4];
exargs = (xmlrpc_c::value_string)event[5];
parent = (xmlrpc_c::value_string)event[6];
triggertype = (xmlrpc_c::value_string)event[7];
// XXX
// info("rpc.cc:RPC_eventlist(): Adding an event\n");
// XXX
if (AddEvent(handle, tuple, exidx,
extime, objname, exargs, objtype, evttype,
parent, triggertype) < 0) {
if (AddEvent(handle, tuple, exidx.c_str(),
extime.c_str(), objname.c_str(),
exargs.c_str(), objtype.c_str(),
evttype.c_str(), parent.c_str(),
triggertype.c_str()) < 0) {
return -1;
}
}
......
......@@ -67,17 +67,19 @@ int RPC_eventlist(char *pid, char *eid,
event_handle_t handle, address_tuple_t tuple);
extern int SetExpPath(const char *path);
extern int AddUserEnv(char *name, char *value);
extern int AddUserEnv(const char *name, const char *value);
extern int AddAgent(event_handle_t handle,
char *vname, char *vnode, char *nodeid,
char *ipaddr, char *type);
const char *vname, const char *vnode, const char *nodeid,
const char *ipaddr, const char *type);
extern int AddGroup(event_handle_t handle, char *groupname, char *agentname);
extern int AddGroup(event_handle_t handle, const char *groupname,
const char *agentname);
extern int AddEvent(event_handle_t handle, address_tuple_t tuple,
char *exidx, char *ftime, char *objname, char *exargs,
char *objtype, char *evttype, char *parent, char *triggertype);
const char *exidx, const char *ftime, const char *objname,
const char *exargs, const char *objtype, const char *evttype,
const char *parent, const char *triggertype);
extern int AddRobot(event_handle_t handle,
struct agent *agent,
......
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