Skip to content
Browse files

Fix compilation warning, indentation, and added EUCA_FREE()

EUCA-5285

Squashed commit of the following:

commit 17947a9ea924e04dcf9da74fb3a6f162953ebe53
Author: chuck <chuck@eucalyptus.com>
Date:   Fri Mar 1 13:00:34 2013 -0800

    Fix buffer overflow issue
    EUCA-5285

commit 29a5ec1eb5cc29e0682c1dc2b9c22a726e8480a9
Author: chuck <chuck@eucalyptus.com>
Date:   Fri Mar 1 12:44:39 2013 -0800

    Fix compilation warning, indentation, and added EUCA_FREE()
    EUCA-5285
  • Loading branch information...
1 parent 4bf2d4d commit 786194f5dda747ea75cbd803d8a6d2f6c8242461 @gelinasc gelinasc committed Mar 3, 2013
View
74 cluster/cc-client-policy.xml
@@ -1,74 +0,0 @@
-<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <wsp:ExactlyOne>
- <wsp:All>
- <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
- <wsp:Policy>
- <sp:InitiatorToken>
- <wsp:Policy>
- <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Always">
- <wsp:Policy>
- <sp:RequireEmbeddedTokenReference/>
- <sp:WssX509V3Token10/>
- </wsp:Policy>
- </sp:X509Token>
- </wsp:Policy>
- </sp:InitiatorToken>
- <sp:RecipientToken>
- <wsp:Policy>
- <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Always">
- <wsp:Policy>
- <sp:RequireEmbeddedTokenReference/>
- <sp:WssX509V3Token10/>
- </wsp:Policy>
- </sp:X509Token>
- </wsp:Policy>
- </sp:RecipientToken>
-
- <sp:AlgorithmSuite>
- <wsp:Policy>
- <sp:Basic256Rsa15/>
- </wsp:Policy>
- </sp:AlgorithmSuite>
-
- <sp:Layout>
- <wsp:Policy>
- <sp:Strict/>
- </wsp:Policy>
- </sp:Layout>
-
- <sp:IncludeTimestamp/>
- <sp:OnlySignEntireHeadersAndBody/>
- </wsp:Policy>
- </sp:AsymmetricBinding>
-
- <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
- <wsp:Policy>
- <sp:MustSupportRefKeyIdentifier/>
- <sp:MustSupportRefEmbeddedToken/>
- </wsp:Policy>
- </sp:Wss10>
-
- <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
- <sp:Body/>
- <sp:Header Namespace="http://www.w3.org/2005/08/addressing"/>
- </sp:SignedParts>
-
- <rampc:RampartConfig xmlns:rampc="http://ws.apache.org/rampart/c/policy">
- <rampc:ReceiverCertificate>/opt/eucalyptus/var/lib/eucalyptus/keys/cluster-cert.pem</rampc:ReceiverCertificate>
- <rampc:Certificate>/opt/eucalyptus/var/lib/eucalyptus/keys/cloud-cert.pem</rampc:Certificate>
- <rampc:PrivateKey>/opt/eucalyptus/var/lib/eucalyptus/keys/cloud-pk.pem</rampc:PrivateKey>
- <rampc:ClockSkewBuffer>20</rampc:ClockSkewBuffer>
- <!-- <rampc:TimeToLive>14400</rampc:TimeToLive> -->
- <!--
- <rampc:User>eucalyptus</rampc:User>
- <rampc:PasswordType>Digest</rampc:PasswordType>
- <rampc:PasswordCallbackClass>/opt/eucalyptus/var/lib/eucalyptus/keys/libpwcb.so</rampc:PasswordCallbackClass>
- <rampc:ReceiverCertificate>/opt/eucalyptus/var/lib/eucalyptus/keys/cluster-cert.pem</rampc:ReceiverCertificate>
- <rampc:Certificate>/opt/eucalyptus/var/lib/eucalyptus/keys/cloud-cert.pem</rampc:Certificate>
- <rampc:PrivateKey>/opt/eucalyptus/var/lib/eucalyptus/keys/cloud-pk.pem</rampc:PrivateKey>
- -->
- </rampc:RampartConfig>
- </wsp:All>
- </wsp:ExactlyOne>
-</wsp:Policy>
-
View
8 cluster/handlers-state.c
@@ -586,8 +586,7 @@ int clean_network_state(void)
if (rc && rc != 2) {
logprintfl(EUCAERROR, "running cmd '%s' failed: cannot remove ip %s\n", cmd, SP(ipstr));
}
- if (ipstr)
- free(ipstr);
+ EUCA_FREE(ipstr);
}
}
// logprintfl(EUCADEBUG, "clean_network_state(): finished clearing public IPs\n");
@@ -602,7 +601,7 @@ int clean_network_state(void)
if (rc) {
logprintfl(EUCAERROR, "could not terminate dhcpd (%s)\n", tmpvnetconfig->dhcpdaemon);
}
- free(pidstr);
+ EUCA_FREE(pidstr);
}
}
@@ -645,7 +644,6 @@ int clean_network_state(void)
}
*/
- if (tmpvnetconfig)
- free(tmpvnetconfig);
+ EUCA_FREE(tmpvnetconfig);
return (0);
}
View
340 cluster/handlers.c
@@ -239,7 +239,7 @@ int doBundleInstance(ncMetadata * ccMeta, char *instanceId, char *bucketName, ch
if (myInstance) {
start = myInstance->ncHostIdx;
stop = start + 1;
- free(myInstance);
+ EUCA_FREE(myInstance);
}
} else {
start = 0;
@@ -301,7 +301,7 @@ int doBundleRestartInstance(ncMetadata * ccMeta, char *instanceId)
if (myInstance) {
start = myInstance->ncHostIdx;
stop = start + 1;
- free(myInstance);
+ EUCA_FREE(myInstance);
myInstance = NULL;
}
} else {
@@ -359,7 +359,7 @@ int doCancelBundleTask(ncMetadata * ccMeta, char *instanceId)
if (myInstance) {
start = myInstance->ncHostIdx;
stop = start + 1;
- free(myInstance);
+ EUCA_FREE(myInstance);
}
} else {
start = 0;
@@ -661,8 +661,7 @@ int ncClientCall(ncMetadata * meta, int timeout, int ncLock, char *ncURL, char *
ret = 0;
}
close(filedes[1]);
- if (localmeta)
- free(localmeta);
+ EUCA_FREE(localmeta);
exit(ret);
} else {
// returns for each client call
@@ -1017,7 +1016,7 @@ int doAttachVolume(ncMetadata * ccMeta, char *volumeId, char *instanceId, char *
if (myInstance) {
start = myInstance->ncHostIdx;
stop = start + 1;
- free(myInstance);
+ EUCA_FREE(myInstance);
}
} else {
start = 0;
@@ -1078,7 +1077,7 @@ int doDetachVolume(ncMetadata * ccMeta, char *volumeId, char *instanceId, char *
if (myInstance) {
start = myInstance->ncHostIdx;
stop = start + 1;
- free(myInstance);
+ EUCA_FREE(myInstance);
}
} else {
start = 0;
@@ -1232,8 +1231,7 @@ int doAssignAddress(ncMetadata * ccMeta, char *uuid, char *src, char *dst)
}
sem_mypost(VNET);
- if (myInstance)
- free(myInstance);
+ EUCA_FREE(myInstance);
}
} else {
logprintfl(EUCADEBUG, "skipping %s->%s mapping, as this clusters does not own the instance (%s)\n", src, dst, dst);
@@ -1262,8 +1260,7 @@ int doAssignAddress(ncMetadata * ccMeta, char *uuid, char *src, char *dst)
} else {
ret = 0;
}
- if (myInstance)
- free(myInstance);
+ EUCA_FREE(myInstance);
}
}
}
@@ -1363,8 +1360,7 @@ int doUnassignAddress(ncMetadata * ccMeta, char *src, char *dst)
} else {
ret = 0;
}
- if (myInstance)
- free(myInstance);
+ EUCA_FREE(myInstance);
}
}
// refresh instance cache
@@ -1478,8 +1474,7 @@ int doStartNetwork(ncMetadata * ccMeta, char *accountId, char *uuid, char *netNa
brname = NULL;
rc = vnetStartNetwork(vnetconfig, vlan, uuid, accountId, netName, &brname);
- if (brname)
- free(brname);
+ EUCA_FREE(brname);
sem_mypost(VNET);
@@ -1537,10 +1532,8 @@ int doDescribeResources(ncMetadata * ccMeta, virtualMachine ** ccvms, int vmLen,
for (i = 0; i < vmLen; i++) {
if ((*ccvms)[i].mem <= 0 || (*ccvms)[i].cores <= 0 || (*ccvms)[i].disk <= 0) {
logprintfl(EUCAERROR, "input error\n");
- if (*outTypesAvail)
- free(*outTypesAvail);
- if (*outTypesMax)
- free(*outTypesMax);
+ EUCA_FREE(*outTypesAvail);
+ EUCA_FREE(*outTypesMax);
*outTypesLen = 0;
return (1);
}
@@ -1711,14 +1704,13 @@ int refresh_resources(ncMetadata * ccMeta, int timeout, int dolock)
rc = ip2mac(vnetconfig, resourceCacheStage->resources[i].ip, &mac);
if (!rc) {
safe_strncpy(resourceCacheStage->resources[i].mac, mac, 24);
- free(mac);
+ EUCA_FREE(mac);
logprintfl(EUCADEBUG, "discovered MAC '%s' for host %s(%s)\n", resourceCacheStage->resources[i].mac,
resourceCacheStage->resources[i].hostname, resourceCacheStage->resources[i].ip);
}
}
- if (ncResDst)
- free(ncResDst);
+ EUCA_FREE(ncResDst);
sem_mypost(REFRESHLOCK);
exit(0);
} else {
@@ -1753,9 +1745,7 @@ int refresh_resources(ncMetadata * ccMeta, int timeout, int dolock)
memcpy(resourceCache, resourceCacheStage, sizeof(ccResourceCache));
sem_mypost(RESCACHE);
- if (pids)
- free(pids);
-
+ EUCA_FREE(pids);
logprintfl(EUCATRACE, "done\n");
return (0);
}
@@ -1855,19 +1845,15 @@ int refresh_instances(ncMetadata * ccMeta, int timeout, int dolock)
}
}
- if (ip)
- free(ip);
- ip = NULL;
-
+ EUCA_FREE(ip);
if (!strcmp(myInstance->ccnet.privateIp, "0.0.0.0")) {
rc = mac2ip(vnetconfig, myInstance->ccnet.privateMac, &ip);
if (!rc) {
safe_strncpy(myInstance->ccnet.privateIp, ip, 24);
}
}
- if (ip)
- free(ip);
+ EUCA_FREE(ip);
}
//#if 0
@@ -1896,8 +1882,7 @@ int refresh_instances(ncMetadata * ccMeta, int timeout, int dolock)
myInstance->ccnet.publicIp, myInstance->ccnet.privateIp);
print_ccInstance("refresh_instances(): ", myInstance);
sensor_set_resource_alias(myInstance->instanceId, myInstance->ncnet.privateIp);
- if (myInstance)
- free(myInstance);
+ EUCA_FREE(myInstance);
}
}
@@ -1906,7 +1891,7 @@ int refresh_instances(ncMetadata * ccMeta, int timeout, int dolock)
for (j = 0; j < ncOutInstsLen; j++) {
free_instance(&(ncOutInsts[j]));
}
- free(ncOutInsts);
+ EUCA_FREE(ncOutInsts);
ncOutInsts = NULL;
}
}
@@ -1946,9 +1931,7 @@ int refresh_instances(ncMetadata * ccMeta, int timeout, int dolock)
memcpy(resourceCache, resourceCacheStage, sizeof(ccResourceCache));
sem_mypost(RESCACHE);
- if (pids)
- free(pids);
-
+ EUCA_FREE(pids);
logprintfl(EUCATRACE, "done\n");
return (0);
}
@@ -1999,9 +1982,9 @@ int refresh_sensors(ncMetadata * ccMeta, int timeout, int dolock)
if (srsLen > 0) {
for (int j = 0; j < srsLen; j++) {
- free(srs[j]);
+ EUCA_FREE(srs[j]);
}
- free(srs);
+ EUCA_FREE(srs);
}
}
}
@@ -2041,9 +2024,7 @@ int refresh_sensors(ncMetadata * ccMeta, int timeout, int dolock)
memcpy(resourceCache, resourceCacheStage, sizeof(ccResourceCache));
sem_mypost(RESCACHE);
- if (pids)
- free(pids);
-
+ EUCA_FREE(pids);
logprintfl(EUCATRACE, "done\n");
return (0);
}
@@ -2102,7 +2083,7 @@ int doDescribeInstances(ncMetadata * ccMeta, char **instIds, int instIdsLen, ccI
int powerUp(ccResource * res)
{
- int rc, ret, len, i;
+ int rc, ret = 1, len, i;
char cmd[MAX_PATH], *bc = NULL;
uint32_t *ips = NULL, *nms = NULL;
@@ -2146,8 +2127,7 @@ int powerUp(ccResource * res)
} else {
ret = rc = 1;
}
- if (bc)
- free(bc);
+ EUCA_FREE(bc);
if (!rc) {
logprintfl(EUCAINFO, "waking up powered off host %s(%s/%s): %s\n", res->hostname, res->ip, res->mac, cmd);
rc = system(cmd);
@@ -2162,10 +2142,8 @@ int powerUp(ccResource * res)
}
}
}
- if (ips)
- free(ips);
- if (nms)
- free(nms);
+ EUCA_FREE(ips);
+ EUCA_FREE(nms);
return (ret);
}
@@ -2771,7 +2749,7 @@ int doRunInstances(ncMetadata * ccMeta, char *amiId, char *kernelId, char *ramdi
int doGetConsoleOutput(ncMetadata * ccMeta, char *instId, char **outConsoleOutput)
{
- int i, rc, numInsts, start, stop, done, ret, timeout = 0;
+ int i, rc, numInsts, start, stop, done, ret = 1, timeout = 0;
ccInstance *myInstance;
time_t op_start;
ccResourceCache resourceCacheLocal;
@@ -2800,18 +2778,16 @@ int doGetConsoleOutput(ncMetadata * ccMeta, char *instId, char **outConsoleOutpu
// found the instance in the cache
start = myInstance->ncHostIdx;
stop = start + 1;
- free(myInstance);
+ EUCA_FREE(myInstance);
} else {
start = 0;
stop = resourceCacheLocal.numResources;
}
done = 0;
for (i = start; i < stop && !done; i++) {
- if (*outConsoleOutput) {
- free(*outConsoleOutput);
- *outConsoleOutput = NULL;
- }
+ EUCA_FREE(*outConsoleOutput);
+
// if not talking to Eucalyptus NC (but, e.g., a Broker)
if (!strstr(resourceCacheLocal.resources[i].ncURL, "EucalyptusNC")) {
char pwfile[MAX_PATH];
@@ -2826,7 +2802,7 @@ int doGetConsoleOutput(ncMetadata * ccMeta, char *instId, char **outConsoleOutpu
}
if (rawconsole) {
*outConsoleOutput = base64_enc((unsigned char *)rawconsole, strlen(rawconsole));
- free(rawconsole);
+ EUCA_FREE(rawconsole);
}
// set the return code accordingly
if (!*outConsoleOutput) {
@@ -2889,7 +2865,7 @@ int doRebootInstances(ncMetadata * ccMeta, char **instIds, int instIdsLen)
// found the instance in the cache
start = myInstance->ncHostIdx;
stop = start + 1;
- free(myInstance);
+ EUCA_FREE(myInstance);
} else {
start = 0;
stop = resourceCacheLocal.numResources;
@@ -2956,8 +2932,7 @@ int doTerminateInstances(ncMetadata * ccMeta, char **instIds, int instIdsLen, in
stop = 0;
(*outStatus)[i] = 0;
}
- if (myInstance)
- free(myInstance);
+ EUCA_FREE(myInstance);
} else {
// instance is not in cache, try all resources
@@ -3047,7 +3022,7 @@ int doCreateImage(ncMetadata * ccMeta, char *instanceId, char *volumeId, char *r
if (myInstance) {
start = myInstance->ncHostIdx;
stop = start + 1;
- free(myInstance);
+ EUCA_FREE(myInstance);
}
} else {
start = 0;
@@ -3429,7 +3404,7 @@ int ccCheckState(int clcTimer)
logprintfl(EUCADEBUG, "cannot ping arbitrator %s (ping rc=%d)\n", host, rc);
arbitratorFails++;
}
- free(host);
+ EUCA_FREE(host);
}
tok = strtok(NULL, " ");
count++;
@@ -3738,7 +3713,7 @@ void *monitor_thread(void *in)
logprintfl(EUCAERROR, "could not start proxy cache\n");
}
}
- free(pidstr);
+ EUCA_FREE(pidstr);
} else {
rc = image_cache_proxykick(resourceCache->resources, &(resourceCache->numResources));
if (rc) {
@@ -3872,14 +3847,14 @@ int init_log(void)
if (log_prefix && strlen(log_prefix) > 0) {
safe_strncpy(config->log_prefix, log_prefix, sizeof(config->log_prefix));
}
- free(log_prefix);
+ EUCA_FREE(log_prefix);
char *log_facility = configFileValue("LOGFACILITY");
if (log_facility) {
if (strlen(log_facility) > 0) {
safe_strncpy(config->log_facility, log_facility, sizeof(config->log_facility));
}
- free(log_facility);
+ EUCA_FREE(log_facility);
}
// set the log file path (levels and size limits are set below)
log_file_set(logFile);
@@ -4009,14 +3984,14 @@ int update_config(void)
if (log_prefix && strlen(log_prefix) > 0) {
safe_strncpy(config->log_prefix, log_prefix, sizeof(config->log_prefix));
}
- free(log_prefix);
+ EUCA_FREE(log_prefix);
char *log_facility = configFileValue("LOGFACILITY");
if (log_facility) {
if (strlen(log_facility) > 0) {
safe_strncpy(config->log_facility, log_facility, sizeof(config->log_facility));
}
- free(log_facility);
+ EUCA_FREE(log_facility);
}
// reconfigure the logging subsystem to use the new values, if any
log_params_set(config->log_level, (int)config->log_roll_number, config->log_max_size_bytes);
@@ -4048,14 +4023,13 @@ int update_config(void)
memcpy(resourceCache->resources, res, sizeof(ccResource) * numHosts);
sem_mypost(RESCACHE);
}
- if (res)
- free(res);
+ EUCA_FREE(res);
// CC Arbitrators
tmpstr = configFileValue("CC_ARBITRATORS");
if (tmpstr) {
snprintf(config->arbitrators, 255, "%s", tmpstr);
- free(tmpstr);
+ EUCA_FREE(tmpstr);
} else {
bzero(config->arbitrators, 256);
}
@@ -4070,7 +4044,7 @@ int update_config(void)
} else {
config->clcPollingFrequency = 6;
}
- free(tmpstr);
+ EUCA_FREE(tmpstr);
} else {
config->clcPollingFrequency = 6;
}
@@ -4083,7 +4057,7 @@ int update_config(void)
} else {
config->ncPollingFrequency = 6;
}
- free(tmpstr);
+ EUCA_FREE(tmpstr);
} else {
config->ncPollingFrequency = 6;
}
@@ -4196,8 +4170,7 @@ int init_config(void)
unsigned int a = 0, b = 0;
if (sscanf(macPrefix, "%02X:%02X", &a, &b) != 2 || (a > 0xFF || b > 0xFF)) {
logprintfl(EUCAWARN, "VNET_MACPREFIX is not defined, defaulting to 'd0:0d'\n");
- if (macPrefix)
- free(macPrefix);
+ EUCA_FREE(macPrefix);
macPrefix = strdup("d0:0d");
}
}
@@ -4233,24 +4206,21 @@ int init_config(void)
logprintfl(EUCAWARN,
"VNET_INTERFACE is deprecated, please use VNET_PUBINTERFACE and VNET_PRIVINTERFACE instead. Will set both to value of VNET_INTERFACE (%s) for now.\n",
tmpstr);
- if (pubInterface)
- free(pubInterface);
+ EUCA_FREE(pubInterface);
pubInterface = strdup(tmpstr);
if (!pubInterface) {
logprintfl(EUCAFATAL, "out of memory!\n");
unlock_exit(1);
}
- if (privInterface)
- free(privInterface);
+ EUCA_FREE(privInterface);
privInterface = strdup(tmpstr);
if (!privInterface) {
logprintfl(EUCAFATAL, "out of memory!\n");
unlock_exit(1);
}
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
}
if (pubmode && (!strcmp(pubmode, "STATIC") || !strcmp(pubmode, "STATIC-DYNMAC"))) {
@@ -4293,38 +4263,22 @@ int init_config(void)
if (initFail) {
logprintfl(EUCAFATAL, "bad network parameters, must fix before system will work\n");
- if (pubSubnet)
- free(pubSubnet);
- if (pubSubnetMask)
- free(pubSubnetMask);
- if (pubBroadcastAddress)
- free(pubBroadcastAddress);
- if (pubRouter)
- free(pubRouter);
- if (pubDomainname)
- free(pubDomainname);
- if (pubDNS)
- free(pubDNS);
- if (pubmacmap)
- free(pubmacmap);
- if (numaddrs)
- free(numaddrs);
- if (pubips)
- free(pubips);
- if (localIp)
- free(localIp);
- if (pubInterface)
- free(pubInterface);
- if (privInterface)
- free(privInterface);
- if (dhcpuser)
- free(dhcpuser);
- if (daemon)
- free(daemon);
- if (pubmode)
- free(pubmode);
- if (macPrefix)
- free(macPrefix);
+ EUCA_FREE(pubSubnet);
+ EUCA_FREE(pubSubnetMask);
+ EUCA_FREE(pubBroadcastAddress);
+ EUCA_FREE(pubRouter);
+ EUCA_FREE(pubDomainname);
+ EUCA_FREE(pubDNS);
+ EUCA_FREE(pubmacmap);
+ EUCA_FREE(numaddrs);
+ EUCA_FREE(pubips);
+ EUCA_FREE(localIp);
+ EUCA_FREE(pubInterface);
+ EUCA_FREE(privInterface);
+ EUCA_FREE(dhcpuser);
+ EUCA_FREE(daemon);
+ EUCA_FREE(pubmode);
+ EUCA_FREE(macPrefix);
sem_mypost(INIT);
return (1);
}
@@ -4334,34 +4288,20 @@ int init_config(void)
int ret = vnetInit(vnetconfig, pubmode, eucahome, netPath, CLC, pubInterface, privInterface, numaddrs, pubSubnet, pubSubnetMask,
pubBroadcastAddress, pubDNS, pubDomainname, pubRouter, daemon,
dhcpuser, NULL, localIp, macPrefix);
- if (pubSubnet)
- free(pubSubnet);
- if (pubSubnetMask)
- free(pubSubnetMask);
- if (pubBroadcastAddress)
- free(pubBroadcastAddress);
- if (pubDomainname)
- free(pubDomainname);
- if (pubDNS)
- free(pubDNS);
- if (pubRouter)
- free(pubRouter);
- if (numaddrs)
- free(numaddrs);
- if (pubmode)
- free(pubmode);
- if (dhcpuser)
- free(dhcpuser);
- if (daemon)
- free(daemon);
- if (privInterface)
- free(privInterface);
- if (pubInterface)
- free(pubInterface);
- if (macPrefix)
- free(macPrefix);
- if (localIp)
- free(localIp);
+ EUCA_FREE(pubSubnet);
+ EUCA_FREE(pubSubnetMask);
+ EUCA_FREE(pubBroadcastAddress);
+ EUCA_FREE(pubDomainname);
+ EUCA_FREE(pubDNS);
+ EUCA_FREE(pubRouter);
+ EUCA_FREE(numaddrs);
+ EUCA_FREE(pubmode);
+ EUCA_FREE(dhcpuser);
+ EUCA_FREE(daemon);
+ EUCA_FREE(privInterface);
+ EUCA_FREE(pubInterface);
+ EUCA_FREE(macPrefix);
+ EUCA_FREE(localIp);
if (ret > 0) {
sem_mypost(VNET);
@@ -4384,7 +4324,7 @@ int init_config(void)
toka = strtok_r(NULL, " ", &ptra);
}
vnetKickDHCP(vnetconfig);
- free(pubmacmap);
+ EUCA_FREE(pubmacmap);
} else if (pubips) {
char *ip, *ptra, *toka;
toka = strtok_r(pubips, " ", &ptra);
@@ -4410,20 +4350,16 @@ int init_config(void)
if (vnetCheckPublicIP(vnetconfig, theip)) {
vnetAddLocalIP(vnetconfig, ips[i]);
}
- if (theip)
- free(theip);
+ EUCA_FREE(theip);
}
}
- if (ips)
- free(ips);
- if (nms)
- free(nms);
+ EUCA_FREE(ips);
+ EUCA_FREE(nms);
}
//free(pubips);
}
- if (pubips)
- free(pubips);
+ EUCA_FREE(pubips);
sem_mypost(VNET);
}
@@ -4443,8 +4379,7 @@ int init_config(void)
else
schedPolicy = SCHEDGREEDY;
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
// powersave options
tmpstr = configFileValue("POWER_IDLETHRESH");
@@ -4460,8 +4395,7 @@ int init_config(void)
idleThresh = 300;
}
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
tmpstr = configFileValue("POWER_WAKETHRESH");
if (!tmpstr) {
@@ -4476,8 +4410,7 @@ int init_config(void)
wakeThresh = 300;
}
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
// some administrative options
tmpstr = configFileValue("NC_POLLING_FREQUENCY");
@@ -4491,8 +4424,7 @@ int init_config(void)
ncPollingFrequency = 6;
}
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
tmpstr = configFileValue("CLC_POLLING_FREQUENCY");
if (!tmpstr) {
@@ -4505,14 +4437,13 @@ int init_config(void)
clcPollingFrequency = 6;
}
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
// CC Arbitrators
tmpstr = configFileValue("CC_ARBITRATORS");
if (tmpstr) {
snprintf(arbitrators, 255, "%s", tmpstr);
- free(tmpstr);
+ EUCA_FREE(tmpstr);
} else {
bzero(arbitrators, 256);
}
@@ -4528,8 +4459,7 @@ int init_config(void)
ncFanout = 1;
}
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
tmpstr = configFileValue("INSTANCE_TIMEOUT");
if (!tmpstr) {
@@ -4542,8 +4472,7 @@ int init_config(void)
instanceTimeout = 30;
}
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
// WS-Security
use_wssec = 0;
@@ -4558,8 +4487,7 @@ int init_config(void)
use_wssec = 1;
}
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
// Multi-cluster tunneling
use_tunnels = 1;
@@ -4569,8 +4497,7 @@ int init_config(void)
use_tunnels = 0;
}
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
// CC Image Caching
proxyIp = NULL;
@@ -4584,8 +4511,7 @@ int init_config(void)
}
use_proxy = 1;
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
proxy_max_cache_size = 32768;
tmpstr = configFileValue("CC_IMAGE_PROXY_CACHE_SIZE");
@@ -4596,15 +4522,14 @@ int init_config(void)
use_proxy = 0; /* Disable proxy if zero-sized. */
}
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
tmpstr = configFileValue("CC_IMAGE_PROXY_PATH");
if (tmpstr)
tmpstr = replace_string(&tmpstr, "$EUCALYPTUS", eucahome);
if (tmpstr) {
snprintf(proxyPath, MAX_PATH, "%s", tmpstr);
- free(tmpstr);
+ EUCA_FREE(tmpstr);
} else {
snprintf(proxyPath, MAX_PATH, EUCALYPTUS_STATE_DIR "/dynserv", eucahome);
}
@@ -4623,8 +4548,7 @@ int init_config(void)
if (use_proxy) {
snprintf(config->proxyIp, 32, "%s", proxyIp);
}
- if (proxyIp)
- free(proxyIp);
+ EUCA_FREE(proxyIp);
config->use_wssec = use_wssec;
config->use_tunnels = use_tunnels;
@@ -4654,7 +4578,7 @@ int init_config(void)
snprintf(config->ccStatus.serviceId.uris[config->ccStatus.serviceId.urisLen], 512, "http://%s:8774/axis2/services/EucalyptusCC",
host);
config->ccStatus.serviceId.urisLen++;
- free(host);
+ EUCA_FREE(host);
}
}
}
@@ -4682,8 +4606,7 @@ int init_config(void)
if (numHosts) {
memcpy(resourceCache->resources, res, sizeof(ccResource) * numHosts);
}
- if (res)
- free(res);
+ EUCA_FREE(res);
resourceCache->lastResourceUpdate = 0;
sem_mypost(RESCACHE);
@@ -4759,8 +4682,8 @@ int checkActiveNetworks()
} else {
logprintfl(EUCADEBUG, "checkActiveNetworks(): address active and found for instance (%s, %s, %d, %d\n", myInstance->instanceId, ip, i, j);
}
- if (myInstance) free(myInstance);
- if (ip) free(ip);
+ EUCA_FREE(myInstance);
+ EUCA_FREE(ip);
}
}
}
@@ -4788,8 +4711,8 @@ int maintainNetworkState()
char *cloudIp1 = hex2dot(config->cloudIp);
char *cloudIp2 = hex2dot(vnetconfig->cloudIp);
logprintfl(EUCADEBUG, "maintainNetworkState(): CCcloudIp=%s VNETcloudIp=%s\n", cloudIp1, cloudIp2);
- free(cloudIp1);
- free(cloudIp2);
+ EUCA_FREE(cloudIp1);
+ EUCA_FREE(cloudIp2);
if (config->cloudIp && (config->cloudIp != vnetconfig->cloudIp)) {
rc = vnetUnsetMetadataRedirect(vnetconfig);
@@ -4882,9 +4805,7 @@ int maintainNetworkState()
}
sem_mypost(CONFIG);
- if (pidstr)
- free(pidstr);
-
+ EUCA_FREE(pidstr);
return (ret);
}
@@ -4930,8 +4851,7 @@ int restoreNetworkState()
if (rc) {
logprintfl(EUCADEBUG, "restoreNetworkState(): failed to reactivate network: %d", i);
}
- if (brname)
- free(brname);
+ EUCA_FREE(brname);
}
}
@@ -4983,8 +4903,7 @@ int reconfigureNetworkFromCLC()
fd = safe_mkstemp(clcnetfile);
if (fd < 0) {
logprintfl(EUCAERROR, "cannot open clcnetfile '%s'\n", clcnetfile);
- if (cloudIp)
- free(cloudIp);
+ EUCA_FREE(cloudIp);
return (1);
}
chmod(clcnetfile, 0644);
@@ -4993,8 +4912,7 @@ int reconfigureNetworkFromCLC()
fd = safe_mkstemp(chainmapfile);
if (fd < 0) {
logprintfl(EUCAERROR, "cannot open chainmapfile '%s'\n", chainmapfile);
- if (cloudIp)
- free(cloudIp);
+ EUCA_FREE(cloudIp);
unlink(clcnetfile);
return (1);
}
@@ -5004,8 +4922,7 @@ int reconfigureNetworkFromCLC()
// clcnet populate
snprintf(url, MAX_PATH, "http://%s:8773/latest/network-topology", cloudIp);
rc = http_get_timeout(url, clcnetfile, 0, 0, 10, 15);
- if (cloudIp)
- free(cloudIp);
+ EUCA_FREE(cloudIp);
if (rc) {
logprintfl(EUCAWARN, "cannot get latest network topology from cloud controller\n");
unlink(clcnetfile);
@@ -5027,16 +4944,14 @@ int reconfigureNetworkFromCLC()
} else {
for (i = 0; i < usernetlen; i++) {
fprintf(FH, "%s %s\n", users[i], nets[i]);
- free(users[i]);
- free(nets[i]);
+ EUCA_FREE(users[i]);
+ EUCA_FREE(nets[i]);
}
}
fclose(FH);
- if (users)
- free(users);
- if (nets)
- free(nets);
+ EUCA_FREE(users);
+ EUCA_FREE(nets);
snprintf(cmd, MAX_PATH, EUCALYPTUS_ROOTWRAP " " EUCALYPTUS_HELPER_DIR "/euca_ipt filter %s %s", vnetconfig->eucahome, vnetconfig->eucahome,
clcnetfile, chainmapfile);
@@ -5075,9 +4990,7 @@ int refreshNodes(ccConfig * config, ccResource ** res, int *numHosts)
}
}
- if (tmpstr)
- free(tmpstr);
-
+ EUCA_FREE(tmpstr);
tmpstr = configFileValue(CONFIG_NC_PORT);
if (!tmpstr) {
// error
@@ -5087,9 +5000,8 @@ int refreshNodes(ccConfig * config, ccResource ** res, int *numHosts)
if (tmpstr)
ncport = atoi(tmpstr);
}
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
tmpstr = configFileValue(CONFIG_NODES);
if (!tmpstr) {
// error
@@ -5099,8 +5011,7 @@ int refreshNodes(ccConfig * config, ccResource ** res, int *numHosts)
hosts = from_var_to_char_list(tmpstr);
if (hosts == NULL) {
logprintfl(EUCAWARN, "NODES list is empty in config files(%s,%s)\n", config->configFiles[1], config->configFiles[0]);
- if (tmpstr)
- free(tmpstr);
+ EUCA_FREE(tmpstr);
return (0);
}
@@ -5117,8 +5028,7 @@ int refreshNodes(ccConfig * config, ccResource ** res, int *numHosts)
if (ipbuf) {
snprintf((*res)[*numHosts - 1].ip, 24, "%s", ipbuf);
}
- if (ipbuf)
- free(ipbuf);
+ EUCA_FREE(ipbuf);
(*res)[*numHosts - 1].ncPort = ncport;
snprintf((*res)[*numHosts - 1].ncService, 128, "%s", ncservice);
@@ -5127,7 +5037,7 @@ int refreshNodes(ccConfig * config, ccResource ** res, int *numHosts)
(*res)[*numHosts - 1].lastState = RESDOWN;
(*res)[*numHosts - 1].lockidx = NCCALL0 + lockmod;
lockmod = (lockmod + 1) % 32;
- free(hosts[i]);
+ EUCA_FREE(hosts[i]);
i++;
}
}
@@ -5139,11 +5049,8 @@ int refreshNodes(ccConfig * config, ccResource ** res, int *numHosts)
}
}
- if (hosts)
- free(hosts);
- if (tmpstr)
- free(tmpstr);
-
+ EUCA_FREE(hosts);
+ EUCA_FREE(tmpstr);
return (0);
}
@@ -5445,8 +5352,8 @@ void print_ccInstance(char *tag, ccInstance * in)
in->ncHostIdx, in->serviceTag, in->userData, in->launchIndex, in->platform, in->bundleTaskStateName, in->volumesSize, volbuf,
groupbuf);
- free(volbuf);
- free(groupbuf);
+ EUCA_FREE(volbuf);
+ EUCA_FREE(groupbuf);
}
void set_clean_instanceCache(void)
@@ -5962,7 +5869,6 @@ int image_cache_proxykick(ccResource * res, int *numHosts)
logprintfl(EUCADEBUG, "running cmd '%s'\n", cmd);
rc = system(cmd);
- if (nodestr)
- free(nodestr);
+ EUCA_FREE(nodestr);
return (rc);
}
View
6 cluster/server-marshal-state.c
@@ -125,10 +125,8 @@ adb_DescribeServicesResponse_t *DescribeServicesMarshal(adb_DescribeServices_t *
adb_describeServicesResponseType_add_serviceStatuses(adbresp, env, stt);
}
- if (outStatuses)
- free(outStatuses);
- if (serviceIds)
- free(serviceIds);
+ EUCA_FREE(outStatuses);
+ EUCA_FREE(serviceIds);
adb_describeServicesResponseType_set_return(adbresp, env, status);
if (status == AXIS2_FALSE) {
View
104 cluster/server-marshal.c
@@ -363,17 +363,15 @@ adb_DescribeSensorsResponse_t *DescribeSensorsMarshal(adb_DescribeSensors_t * de
sensorResource **outResources;
int outResourcesLen;
- int error =
- doDescribeSensors(&meta, historySize, collectionIntervalTimeMs, instIds, instIdsLen, sensorIds, sensorIdsLen, &outResources,
- &outResourcesLen);
+ int error = doDescribeSensors(&meta, historySize, collectionIntervalTimeMs, instIds, instIdsLen, sensorIds, sensorIdsLen, &outResources,
+ &outResourcesLen);
if (error) {
logprintfl(EUCAERROR, "doDescribeSensors() failed error=%d\n", error);
if (outResourcesLen > 0 && outResources != NULL) {
for (int i = 0; i < outResourcesLen; i++) {
- if (outResources[i])
- free(outResources[i]);
+ EUCA_FREE(outResources[i]);
}
- free(outResources);
+ EUCA_FREE(outResources);
}
} else {
logprintfl(EUCATRACE, "marshalling results outResourcesLen=%d\n", outResourcesLen);
@@ -385,22 +383,20 @@ adb_DescribeSensorsResponse_t *DescribeSensorsMarshal(adb_DescribeSensors_t * de
// set operation-specific fields in output
for (int i = 0; i < outResourcesLen; i++) {
adb_sensorsResourceType_t *resource = copy_sensor_resource_to_adb(env, outResources[i], historySize);
- if (outResources[i])
- free(outResources[i]);
+ EUCA_FREE(outResources[i]);
adb_describeSensorsResponseType_add_sensorsResources(output, env, resource);
}
- if (outResourcesLen > 0 && outResources != NULL)
- free(outResources);
+ EUCA_FREE(outResources);
result = OK; // success
}
}
- free(sensorIds);
+ EUCA_FREE(sensorIds);
reply:
- free(instIds);
+ EUCA_FREE(instIds);
if (result == ERROR) {
adb_describeSensorsResponseType_set_return(output, env, AXIS2_FALSE);
@@ -522,13 +518,13 @@ adb_DescribeNetworksResponse_t *DescribeNetworksMarshal(adb_DescribeNetworks_t *
vnetSubnet = hex2dot(outvnetConfig->nw);
if (vnetSubnet) {
adb_describeNetworksResponseType_set_vnetSubnet(snrt, env, vnetSubnet);
- free(vnetSubnet);
+ EUCA_FREE(vnetSubnet);
}
vnetNetmask = hex2dot(outvnetConfig->nm);
if (vnetNetmask) {
adb_describeNetworksResponseType_set_vnetNetmask(snrt, env, vnetNetmask);
- free(vnetNetmask);
+ EUCA_FREE(vnetNetmask);
}
adb_describeNetworksResponseType_set_vlanMin(snrt, env, 2);
adb_describeNetworksResponseType_set_vlanMax(snrt, env, outvnetConfig->max_vlan);
@@ -554,11 +550,9 @@ adb_DescribeNetworksResponse_t *DescribeNetworksMarshal(adb_DescribeNetworks_t *
}
}
for (i = 0; i < clusterControllersLen; i++) {
- if (clusterControllers[i])
- free(clusterControllers[i]);
+ EUCA_FREE(clusterControllers[i]);
}
- if (clusterControllers)
- free(clusterControllers);
+ EUCA_FREE(clusterControllers);
adb_describeNetworksResponseType_set_return(snrt, env, status);
if (status == AXIS2_FALSE) {
@@ -571,8 +565,7 @@ adb_DescribeNetworksResponse_t *DescribeNetworksMarshal(adb_DescribeNetworks_t *
ret = adb_DescribeNetworksResponse_create(env);
adb_DescribeNetworksResponse_set_DescribeNetworksResponse(ret, env, snrt);
- if (outvnetConfig)
- free(outvnetConfig);
+ EUCA_FREE(outvnetConfig);
return (ret);
}
@@ -622,14 +615,12 @@ adb_DescribePublicAddressesResponse_t *DescribePublicAddressesMarshal(adb_Descri
ipstr = hex2dot(outAddresses[i].ip);
adb_publicAddressType_set_sourceAddress(addr, env, ipstr);
- if (ipstr)
- free(ipstr);
+ EUCA_FREE(ipstr);
if (outAddresses[i].dstip) {
ipstr = hex2dot(outAddresses[i].dstip);
adb_publicAddressType_set_destAddress(addr, env, ipstr);
- if (ipstr)
- free(ipstr);
+ EUCA_FREE(ipstr);
} else {
adb_publicAddressType_set_destAddress(addr, env, "0.0.0.0");
}
@@ -788,8 +779,7 @@ adb_ConfigureNetworkResponse_t *ConfigureNetworkMarshal(adb_ConfigureNetwork_t *
if (strcmp(destName, destNameLast)) {
doFlushNetwork(&ccMeta, accountId, destName);
}
- if (destNameLast)
- free(destNameLast);
+ EUCA_FREE(destNameLast);
destNameLast = strdup(destName);
if (!destNameLast) {
logprintf("ERROR: out of memory\n");
@@ -839,19 +829,15 @@ adb_ConfigureNetworkResponse_t *ConfigureNetworkMarshal(adb_ConfigureNetwork_t *
minPort, maxPort);
}
- if (userNames)
- free(userNames);
- if (sourceNames)
- free(sourceNames);
- if (sourceNets)
- free(sourceNets);
+ EUCA_FREE(userNames);
+ EUCA_FREE(sourceNames);
+ EUCA_FREE(sourceNets);
if (rc) {
done++;
}
}
- if (destNameLast)
- free(destNameLast);
+ EUCA_FREE(destNameLast);
if (done) {
logprintf("ERROR: doConfigureNetwork() returned fail %d\n", rc);
@@ -911,8 +897,7 @@ adb_GetConsoleOutputResponse_t *GetConsoleOutputMarshal(adb_GetConsoleOutput_t *
}
}
}
- if (output)
- free(output);
+ EUCA_FREE(output);
adb_getConsoleOutputResponseType_set_correlationId(gcort, env, ccMeta.correlationId);
adb_getConsoleOutputResponseType_set_userId(gcort, env, ccMeta.userId);
@@ -976,11 +961,9 @@ adb_StartNetworkResponse_t *StartNetworkMarshal(adb_StartNetwork_t * startNetwor
}
for (i = 0; i < clusterControllersLen; i++) {
- if (clusterControllers[i])
- free(clusterControllers[i]);
+ EUCA_FREE(clusterControllers[i]);
}
- if (clusterControllers)
- free(clusterControllers);
+ EUCA_FREE(clusterControllers);
adb_startNetworkResponseType_set_return(snrt, env, status);
if (status == AXIS2_FALSE) {
@@ -1051,8 +1034,7 @@ adb_DescribeResourcesResponse_t *DescribeResourcesMarshal(adb_DescribeResources_
adb_describeResourcesResponseType_add_nodes(drrt, env, nt);
}
- if (outNodes)
- free(outNodes);
+ EUCA_FREE(outNodes);
for (i = 0; i < outTypesLen; i++) {
adb_ccResourceType_t *rt = NULL;
@@ -1065,14 +1047,11 @@ adb_DescribeResourcesResponse_t *DescribeResourcesMarshal(adb_DescribeResources_
adb_ccResourceType_set_availableInstances(rt, env, outTypesAvail[i]);
adb_describeResourcesResponseType_add_resources(drrt, env, rt);
}
- if (outTypesMax)
- free(outTypesMax);
- if (outTypesAvail)
- free(outTypesAvail);
+ EUCA_FREE(outTypesMax);
+ EUCA_FREE(outTypesAvail);
}
- if (vms)
- free(vms);
+ EUCA_FREE(vms);
adb_describeResourcesResponseType_set_correlationId(drrt, env, ccMeta.correlationId);
adb_describeResourcesResponseType_set_userId(drrt, env, ccMeta.userId);
@@ -1122,8 +1101,7 @@ adb_DescribeInstancesResponse_t *DescribeInstancesMarshal(adb_DescribeInstances_
rc = doDescribeInstances(&ccMeta, instIds, instIdsLen, &outInsts, &outInstsLen);
}
- if (instIds)
- free(instIds);
+ EUCA_FREE(instIds);
if (rc) {
logprintf("ERROR: doDescribeInstances() failed %d\n", rc);
status = AXIS2_FALSE;
@@ -1139,8 +1117,7 @@ adb_DescribeInstancesResponse_t *DescribeInstancesMarshal(adb_DescribeInstances_
rc = ccInstanceUnmarshal(it, myInstance, env);
adb_describeInstancesResponseType_add_instances(dirt, env, it);
}
- if (outInsts)
- free(outInsts);
+ EUCA_FREE(outInsts);
}
adb_describeInstancesResponseType_set_correlationId(dirt, env, ccMeta.correlationId);
@@ -1367,13 +1344,13 @@ adb_RunInstancesResponse_t *RunInstancesMarshal(adb_RunInstances_t * runInstance
ret = adb_RunInstancesResponse_create(env);
adb_RunInstancesResponse_set_RunInstancesResponse(ret, env, rirt);
- free(networkIndexList);
- free(macAddrs);
- free(netNames);
- free(instIds);
- free(userData);
- free(uuids);
- free(outInsts);
+ EUCA_FREE(networkIndexList);
+ EUCA_FREE(macAddrs);
+ EUCA_FREE(netNames);
+ EUCA_FREE(instIds);
+ EUCA_FREE(userData);
+ EUCA_FREE(uuids);
+ EUCA_FREE(outInsts);
return (ret);
}
@@ -1406,8 +1383,7 @@ adb_RebootInstancesResponse_t *RebootInstancesMarshal(adb_RebootInstances_t * re
rc = doRebootInstances(&ccMeta, instIds, instIdsLen);
}
- if (instIds)
- free(instIds);
+ EUCA_FREE(instIds);
rirt = adb_rebootInstancesResponseType_create(env);
if (rc) {
@@ -1470,8 +1446,7 @@ adb_TerminateInstancesResponse_t *TerminateInstancesMarshal(adb_TerminateInstanc
rc = doTerminateInstances(&ccMeta, instIds, instIdsLen, force, &outStatus);
}
- if (instIds)
- free(instIds);
+ EUCA_FREE(instIds);
tirt = adb_terminateInstancesResponseType_create(env);
if (rc) {
@@ -1487,8 +1462,7 @@ adb_TerminateInstancesResponse_t *TerminateInstancesMarshal(adb_TerminateInstanc
}
}
}
- if (outStatus)
- free(outStatus);
+ EUCA_FREE(outStatus);
adb_terminateInstancesResponseType_set_correlationId(tirt, env, ccMeta.correlationId);
adb_terminateInstancesResponseType_set_userId(tirt, env, ccMeta.userId);
View
240 gatherlog/handlers.c
@@ -103,7 +103,7 @@ int doGetLogs(char *service, char **outCCLog, char **outNCLog, char **outHTTPDLo
}
if (!home) {
printf("Out of memory!\n");
- free(buf);
+ EUCA_FREE(buf);
return 1;
}
@@ -166,90 +166,88 @@ int doGetLogs(char *service, char **outCCLog, char **outNCLog, char **outHTTPDLo
} else {
*outAxis2Log = NULL;
}
- if (home)
- free(home);
+ EUCA_FREE(home);
} else {
int pid, filedes[2], status;
- pipe(filedes);
- pid = fork();
- if (pid == 0) {
- axutil_env_t *env = NULL;
- axis2_char_t *client_home = NULL;
- axis2_stub_t *stub = NULL;
- char *clog, *hlog, *alog, *nlog;
-
- close(filedes[0]);
-
- // env = axutil_env_create_all("/tmp/GLclient.log", AXIS2_LOG_LEVEL_TRACE);
- env = axutil_env_create_all(NULL, 0);
- client_home = AXIS2_GETENV("AXIS2C_HOME");
- if (!client_home) {
- exit(1);
- } else {
- stub = axis2_stub_create_EucalyptusGL(env, client_home, service);
- clog = nlog = hlog = alog = NULL;
- rc = gl_getLogs("self", &clog, &nlog, &hlog, &alog, env, stub);
- if (rc) {
+ if(pipe(filedes) == 0) {
+ pid = fork();
+ if (pid == 0) {
+ axutil_env_t *env = NULL;
+ axis2_char_t *client_home = NULL;
+ axis2_stub_t *stub = NULL;
+ char *clog, *hlog, *alog, *nlog;
+
+ close(filedes[0]);
+
+ // env = axutil_env_create_all("/tmp/GLclient.log", AXIS2_LOG_LEVEL_TRACE);
+ env = axutil_env_create_all(NULL, 0);
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home) {
+ exit(1);
} else {
- bzero(buf, bufsize);
- if (clog)
- snprintf(buf, bufsize, "%s", clog);
- rc = write(filedes[1], buf, bufsize);
-
- bzero(buf, bufsize);
- if (nlog)
- snprintf(buf, bufsize, "%s", nlog);
- rc = write(filedes[1], buf, bufsize);
-
- bzero(buf, bufsize);
- if (hlog)
- snprintf(buf, bufsize, "%s", hlog);
- rc = write(filedes[1], buf, bufsize);
-
- bzero(buf, bufsize);
- if (alog)
- snprintf(buf, bufsize, "%s", alog);
- rc = write(filedes[1], buf, bufsize);
+ stub = axis2_stub_create_EucalyptusGL(env, client_home, service);
+ clog = nlog = hlog = alog = NULL;
+ rc = gl_getLogs("self", &clog, &nlog, &hlog, &alog, env, stub);
+ if (rc) {
+ } else {
+ bzero(buf, bufsize);
+ if (clog)
+ snprintf(buf, bufsize, "%s", clog);
+ rc = write(filedes[1], buf, bufsize);
+
+ bzero(buf, bufsize);
+ if (nlog)
+ snprintf(buf, bufsize, "%s", nlog);
+ rc = write(filedes[1], buf, bufsize);
+
+ bzero(buf, bufsize);
+ if (hlog)
+ snprintf(buf, bufsize, "%s", hlog);
+ rc = write(filedes[1], buf, bufsize);
+
+ bzero(buf, bufsize);
+ if (alog)
+ snprintf(buf, bufsize, "%s", alog);
+ rc = write(filedes[1], buf, bufsize);
+ }
}
- }
- close(filedes[1]);
- exit(0);
+ close(filedes[1]);
+ exit(0);
- } else {
- close(filedes[1]);
+ } else {
+ close(filedes[1]);
- bzero(buf, bufsize);
- rc = read(filedes[0], buf, bufsize - 1);
- if (rc && buf[0] != '\0') {
- *outCCLog = strdup(buf);
- }
+ bzero(buf, bufsize);
+ rc = read(filedes[0], buf, bufsize - 1);
+ if (rc && buf[0] != '\0') {
+ *outCCLog = strdup(buf);
+ }
- bzero(buf, bufsize);
- rc = read(filedes[0], buf, bufsize - 1);
- if (rc && buf[0] != '\0') {
- *outNCLog = strdup(buf);
- }
+ bzero(buf, bufsize);
+ rc = read(filedes[0], buf, bufsize - 1);
+ if (rc && buf[0] != '\0') {
+ *outNCLog = strdup(buf);
+ }
- bzero(buf, bufsize);
- rc = read(filedes[0], buf, bufsize - 1);
- if (rc && buf[0] != '\0') {
- *outHTTPDLog = strdup(buf);
- }
+ bzero(buf, bufsize);
+ rc = read(filedes[0], buf, bufsize - 1);
+ if (rc && buf[0] != '\0') {
+ *outHTTPDLog = strdup(buf);
+ }
- bzero(buf, bufsize);
- rc = read(filedes[0], buf, bufsize - 1);
- if (rc && buf[0] != '\0') {
- *outAxis2Log = strdup(buf);
+ bzero(buf, bufsize);
+ rc = read(filedes[0], buf, bufsize - 1);
+ if (rc && buf[0] != '\0') {
+ *outAxis2Log = strdup(buf);
+ }
+ close(filedes[0]);
+ wait(&status);
}
- close(filedes[0]);
- wait(&status);
}
}
- if (buf)
- free(buf);
-
+ EUCA_FREE(buf);
return (0);
}
@@ -280,7 +278,7 @@ int doGetKeys(char *service, char **outCCCert, char **outNCCert)
}
if (!home) {
printf("Out of memory!\n");
- free(buf);
+ EUCA_FREE(buf);
return 1;
}
@@ -314,67 +312,65 @@ int doGetKeys(char *service, char **outCCCert, char **outNCCert)
*outNCCert = NULL;
}
- if (home)
- free(home);
+ EUCA_FREE(home);
} else {
int pid, filedes[2], status;
- pipe(filedes);
- pid = fork();
- if (pid == 0) {
- axutil_env_t *env = NULL;
- axis2_char_t *client_home = NULL;
- axis2_stub_t *stub = NULL;
- char *ccert, *ncert;
-
- close(filedes[0]);
-
- // env = axutil_env_create_all("/tmp/GLclient.log", AXIS2_LOG_LEVEL_TRACE);
- env = axutil_env_create_all(NULL, 0);
- client_home = AXIS2_GETENV("AXIS2C_HOME");
- if (!client_home) {
- exit(1);
- } else {
- stub = axis2_stub_create_EucalyptusGL(env, client_home, service);
- ccert = ncert = NULL;
- rc = gl_getKeys("self", &ccert, &ncert, env, stub);
- if (rc) {
+ if(pipe(filedes) == 0) {
+ pid = fork();
+ if (pid == 0) {
+ axutil_env_t *env = NULL;
+ axis2_char_t *client_home = NULL;
+ axis2_stub_t *stub = NULL;
+ char *ccert, *ncert;
+
+ close(filedes[0]);
+
+ // env = axutil_env_create_all("/tmp/GLclient.log", AXIS2_LOG_LEVEL_TRACE);
+ env = axutil_env_create_all(NULL, 0);
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home) {
+ exit(1);
} else {
- bzero(buf, bufsize);
- if (ccert)
- snprintf(buf, bufsize, "%s", ccert);
- rc = write(filedes[1], buf, bufsize);
-
- bzero(buf, bufsize);
- if (ncert)
- snprintf(buf, bufsize, "%s", ncert);
- rc = write(filedes[1], buf, bufsize);
+ stub = axis2_stub_create_EucalyptusGL(env, client_home, service);
+ ccert = ncert = NULL;
+ rc = gl_getKeys("self", &ccert, &ncert, env, stub);
+ if (rc) {
+ } else {
+ bzero(buf, bufsize);
+ if (ccert)
+ snprintf(buf, bufsize, "%s", ccert);
+ rc = write(filedes[1], buf, bufsize);
+
+ bzero(buf, bufsize);
+ if (ncert)
+ snprintf(buf, bufsize, "%s", ncert);
+ rc = write(filedes[1], buf, bufsize);
+ }
}
- }
- close(filedes[1]);
- exit(0);
+ close(filedes[1]);
+ exit(0);
- } else {
- close(filedes[1]);
- bzero(buf, bufsize);
+ } else {
+ close(filedes[1]);
+ bzero(buf, bufsize);
- rc = read(filedes[0], buf, bufsize - 1);
- if (rc) {
- *outCCCert = strdup(buf);
- }
+ rc = read(filedes[0], buf, bufsize - 1);
+ if (rc) {
+ *outCCCert = strdup(buf);
+ }
- rc = read(filedes[0], buf, bufsize - 1);
- if (rc) {
- *outNCCert = strdup(buf);
- }
+ rc = read(filedes[0], buf, bufsize - 1);
+ if (rc) {
+ *outNCCert = strdup(buf);
+ }
- close(filedes[0]);
- wait(&status);
+ close(filedes[0]);
+ wait(&status);
+ }
}
}
- if (buf)
- free(buf);
-
+ EUCA_FREE(buf);
return (0);
}
View
15 gatherlog/server-marshal.c
@@ -64,7 +64,8 @@
#include <stdlib.h>
#include <string.h>
-#include <server-marshal.h>
+#include <eucalyptus.h>
+#include "server-marshal.h"
adb_GetLogsResponse_t *GetLogsMarshal(adb_GetLogs_t * getLogs, const axutil_env_t * env)
{
@@ -95,19 +96,19 @@ adb_GetLogsResponse_t *GetLogsMarshal(adb_GetLogs_t * getLogs, const axutil_env_
if (outCCLog) {
adb_getLogsResponseType_set_CCLog(response, env, outCCLog);
- free(outCCLog);
+ EUCA_FREE(outCCLog);
}
if (outNCLog) {
adb_getLogsResponseType_set_NCLog(response, env, outNCLog);
- free(outNCLog);
+ EUCA_FREE(outNCLog);
}
if (outHTTPDLog) {
adb_getLogsResponseType_set_httpdLog(response, env, outHTTPDLog);
- free(outHTTPDLog);
+ EUCA_FREE(outHTTPDLog);
}
if (outAxis2Log) {
adb_getLogsResponseType_set_axis2Log(response, env, outAxis2Log);
- free(outAxis2Log);
+ EUCA_FREE(outAxis2Log);
}
}
adb_getLogsResponseType_set_serviceTag(response, env, service);
@@ -153,11 +154,11 @@ adb_GetKeysResponse_t *GetKeysMarshal(adb_GetKeys_t * getKeys, const axutil_env_
} else {
if (outCCCert) {
adb_getKeysResponseType_set_CCcert(response, env, outCCCert);
- free(outCCCert);
+ EUCA_FREE(outCCCert);
}
if (outNCCert) {
adb_getKeysResponseType_set_NCcert(response, env, outNCCert);
- free(outNCCert);
+ EUCA_FREE(outNCCert);
}
}
View
63 net/vnetwork.c
@@ -2609,7 +2609,7 @@ int vnetAddPublicIP(vnetConfig * vnetconfig, char *inip)
int vnetAssignAddress(vnetConfig * vnetconfig, char *src, char *dst)
{
- int rc = 0, slashnet, ret = 0, pid=0;
+ int rc = 0, slashnet, ret = 0, pid = 0;
char cmd[MAX_PATH], *network;
if ((vnetconfig->role == CC || vnetconfig->role == CLC) && (!strcmp(vnetconfig->mode, "MANAGED") || !strcmp(vnetconfig->mode, "MANAGED-NOVLAN"))) {
@@ -2622,25 +2622,25 @@ int vnetAssignAddress(vnetConfig * vnetconfig, char *src, char *dst)
logprintfl(EUCAERROR, "failed to assign IP address '%s'\n", cmd);
ret = 1;
} else {
- snprintf(cmd, MAX_PATH, EUCALYPTUS_ROOTWRAP " arping -c 2 -U -I %s %s", vnetconfig->eucahome, vnetconfig->pubInterface, src);
- logprintfl(EUCADEBUG, "sending unsolicited ARP to flush caches with cmd '%s'\n", cmd);
- pid = fork();
- if (!pid) {
- pid = fork();
- if (!pid) {
- rc = system(cmd);
- rc = rc >> 8;
- logprintfl(EUCADEBUG, "return from cmd '%s' = %d\n", cmd, rc);
- exit(rc);
- }
- exit(0);
- } else {
-
- // wait here? or continue to let arpings complete and let 'shawn()' clean up defunct processes. If there are many assigns to do, it could take a long time to complete.
- int status;
- timewait(pid, &status, 5);
- }
- }
+ snprintf(cmd, MAX_PATH, EUCALYPTUS_ROOTWRAP " arping -c 2 -U -I %s %s", vnetconfig->eucahome, vnetconfig->pubInterface, src);
+ logprintfl(EUCADEBUG, "sending unsolicited ARP to flush caches with cmd '%s'\n", cmd);
+ pid = fork();
+ if (!pid) {
+ pid = fork();
+ if (!pid) {
+ rc = system(cmd);
+ rc = rc >> 8;
+ logprintfl(EUCADEBUG, "return from cmd '%s' = %d\n", cmd, rc);
+ exit(rc);
+ }
+ exit(0);
+ } else {
+
+ // wait here? or continue to let arpings complete and let 'shawn()' clean up defunct processes. If there are many assigns to do, it could take a long time to complete.
+ int status;
+ timewait(pid, &status, 5);
+ }
+ }
snprintf(cmd, MAX_PATH, "-A PREROUTING -d %s -j DNAT --to-destination %s", src, dst);
rc = vnetApplySingleTableRule(vnetconfig, "nat", cmd);
@@ -3149,7 +3149,6 @@ int vnetLoadIPTables(vnetConfig * vnetconfig)
int rc = 0, ret;
char newpath[MAX_PATH];
-
ret = 0;
snprintf(newpath, MAX_PATH, EUCALYPTUS_CONF_DIR "/%s", vnetconfig->eucahome, "iptables-preload");
if (stat(newpath, &statbuf) != 0) {
@@ -3159,28 +3158,22 @@ int vnetLoadIPTables(vnetConfig * vnetconfig)
rc = system(cmd);
ret = WEXITSTATUS(rc);
if (stat(newpath, &statbuf) == 0) {
- logprintfl(EUCAINFO ,"copied %s to %s (err %x)\n",oldfile,
- newpath,rc);
- }else {
- logprintfl(EUCAINFO ,"copied %s to %s (err %x) failed\n",
- oldfile, newpath,rc);
- snprintf(cmd, MAX_PATH,
- EUCALYPTUS_ROOTWRAP " iptables-restore < %s",
- vnetconfig->eucahome, oldfile);
+ logprintfl(EUCAINFO, "copied %s to %s (err %x)\n", oldfile, newpath, rc);
+ } else {
+ logprintfl(EUCAINFO, "copied %s to %s (err %x) failed\n", oldfile, newpath, rc);
+ snprintf(cmd, MAX_PATH, EUCALYPTUS_ROOTWRAP " iptables-restore < %s", vnetconfig->eucahome, oldfile);
rc = system(cmd);
ret = WEXITSTATUS(rc);
return (ret);
}
}
- }
+ }
if (stat(newpath, &statbuf) == 0) {
- snprintf(cmd, MAX_PATH,
- EUCALYPTUS_ROOTWRAP " iptables-restore < %s",
- vnetconfig->eucahome, newpath);
+ snprintf(cmd, MAX_PATH, EUCALYPTUS_ROOTWRAP " iptables-restore < %s", vnetconfig->eucahome, newpath);
rc = system(cmd);
ret = WEXITSTATUS(rc);
- if (ret) {
- logprintfl(EUCADEBUG ," %s returned %x \n",cmd,rc);
+ if (ret) {
+ logprintfl(EUCADEBUG, " %s returned %x \n", cmd, rc);
}
}
return (ret);
View
6 node/NCclient.c
@@ -180,12 +180,12 @@ int add_vbr(const char *spec_str, virtualMachine * vm_type)
}
safe_strncpy(vbr->resourceLocation, spec_str + (loc_spec - spec_copy), sizeof(vbr->resourceLocation));
- free(spec_copy);
+ EUCA_FREE(spec_copy);
return 0;
out_error:
vm_type->virtualBootRecordLen--;
- free(spec_copy);
+ EUCA_FREE(spec_copy);
return 1;
}
@@ -580,7 +580,7 @@ int main(int argc, char **argv)
free_instance(&(outInsts[i]));
}
}
- /* TODO: fix free(outInsts); */
+ /* TODO: fix EUCA_FREE(outInsts); */
/***********************************************************/
} else if (!strcmp(command, "describeResource")) {
View
13 node/client-marshal-adb.c
@@ -152,19 +152,16 @@ ncStub *ncStubCreate(char *endpoint_uri, char *logfile, char *homedir)
logprintfl(EUCAERROR, "failed to create a stub for EucalyptusNC service (stub=%p env=%p client_home=%s)\n", stub, env, client_home);
}
- free(node_name);
+ EUCA_FREE(node_name);
return st;
}
int ncStubDestroy(ncStub * st)
{
- if (st->client_home)
- free(st->client_home);
- if (st->endpoint_uri)
- free(st->endpoint_uri);
- if (st->node_name)
- free(st->node_name);
- free(st);
+ EUCA_FREE(st->client_home);
+ EUCA_FREE(st->endpoint_uri);
+ EUCA_FREE(st->node_name);
+ EUCA_FREE(st);
return 0;
}
View
6 node/client-marshal-fake.c
@@ -270,13 +270,13 @@ ncStub *ncStubCreate(char *endpoint_uri, char *logfile, char *homedir)
logprintfl(EUCAWARN, "fakeNC: WARNING: out of memory");
}
- free(node_name);
+ EUCA_FREE(node_name);
return st;
}
int ncStubDestroy(ncStub * st)
{
- free(st);
+ EUCA_FREE(st);
return (0);
}
@@ -461,7 +461,7 @@ int ncDescribeResourceStub(ncStub * st, ncMetadata * meta, char *resourceType, n
ret = 1;
} else {
memcpy(&(myconfig->res), res, sizeof(ncResource));
- free(res);
+ EUCA_FREE(res);
}
}
View
2 node/client-marshal-local.c
@@ -81,7 +81,7 @@ ncStub *ncStubCreate(char *endpoint_uri, char *logfile, char *homedir)
int ncStubDestroy(ncStub * st)
{
- free(st);
+ EUCA_FREE(st);
return (0);
}
View
74 node/handlers.c
@@ -274,9 +274,9 @@ int update_disk_aliases(ncInstance * instance)
if (volumeId) {
sensor_set_volume(instance->instanceId, volumeId, devs[i]);
}
- free(devs[i]);
+ EUCA_FREE(devs[i]);
}
- free(devs);
+ EUCA_FREE(devs);
}
if (!saw_root) {
logprintfl(EUCAWARN, "[%s] failed to find 'dev' entry for root\n", instance->instanceId);
@@ -298,9 +298,9 @@ int update_disk_aliases(ncInstance * instance)
logprintfl(EUCAWARN, "[%s] failed to find 'dev' entry in %s\n", lpath, instance->instanceId);
}
for (int j = 0; devs[j]; j++) {
- free(devs[j]);
+ EUCA_FREE(devs[j]);
}
- free(devs);
+ EUCA_FREE(devs);
} else {
sensor_set_volume(instance->instanceId, volume->volumeId, NULL);
}
@@ -606,7 +606,7 @@ static void refresh_instance_info(struct nc_state_t *nc, ncInstance * instance)
if (!rc && ip) {
logprintfl(EUCAINFO, "[%s] discovered public IP %s for instance\n", instance->instanceId, ip);
safe_strncpy(instance->ncnet.publicIp, ip, 24);
- free(ip);
+ EUCA_FREE(ip);
}
}
}
@@ -615,7 +615,7 @@ static void refresh_instance_info(struct nc_state_t *nc, ncInstance * instance)
if (!rc && ip) {
logprintfl(EUCAINFO, "[%s] discovered private IP %s for instance\n", instance->instanceId, ip);
safe_strncpy(instance->ncnet.privateIp, ip, 24);
- free(ip);
+ EUCA_FREE(ip);
}
}
}
@@ -631,8 +631,8 @@ void copy_instances(void)
bunchOfInstances *container = head;
ncInstance *instance = head->instance;
head = head->next;
- free(instance);
- free(container);
+ EUCA_FREE(instance);
+ EUCA_FREE(container);
}
global_instances_copy = NULL;
@@ -660,15 +660,14 @@ static void update_log_params(void)
// reconfigure the logging subsystem to use the new values, if any
log_params_set(log_level, log_roll_number, log_max_size_bytes);
log_prefix_set(log_prefix);
- if (log_prefix)
- free(log_prefix);
+ EUCA_FREE(log_prefix);
char *log_facility = configFileValue("LOGFACILITY");
if (log_facility) {
if (strlen(log_facility) > 0) {
log_facility_set(log_facility, "nc");
}
- free(log_facility);
+ EUCA_FREE(log_facility);
}
}
@@ -882,7 +881,7 @@ void *startup_thread(void *arg)
logprintfl(EUCAWARN, "[%s] can't determine the host's bitness (%s, assuming 64)\n", instance->instanceId, s);
instance->hypervisorBitness = 64;
}
- free(s);
+ EUCA_FREE(s);
} else {
logprintfl(EUCAWARN, "[%s] can't determine the host's bitness (assuming 64)\n", instance->instanceId);
instance->hypervisorBitness = 64;
@@ -1020,10 +1019,8 @@ void *startup_thread(void *arg)
change_state(instance, SHUTOFF);
free:
- if (xml)
- free(xml);
- if (brname)
- free(brname);
+ EUCA_FREE(xml);
+ EUCA_FREE(brname);
return NULL;
}
@@ -1156,10 +1153,8 @@ void *restart_thread(void *arg)
change_state(instance, SHUTOFF);
done:
- if (xml)
- free(xml);
- if (brname)
- free(brname);
+ EUCA_FREE(xml);
+ EUCA_FREE(brname);
return (NULL);
}
@@ -1438,7 +1433,7 @@ static int init(void)
}
if (nc_state.H == NULL) {
logprintfl(EUCAFATAL, "requested hypervisor type (%s) is not available\n", hypervisor);
- free(hypervisor);
+ EUCA_FREE(hypervisor);
return ERROR_FATAL;
}
// only load virtio config for kvm
@@ -1447,7 +1442,7 @@ static int init(void)
GET_VAR_INT(nc_state.config_use_virtio_disk, CONFIG_USE_VIRTIO_DISK, 0);
GET_VAR_INT(nc_state.config_use_virtio_root, CONFIG_USE_VIRTIO_ROOT, 0);
}
- free(hypervisor);
+ EUCA_FREE(hypervisor);
if (sensor_init(NULL, NULL, MAX_SENSOR_RESOURCES, FALSE, NULL) != OK) {
logprintfl(EUCAERROR, "failed to initialize sensor subsystem in this process\n");
@@ -1533,13 +1528,13 @@ static int init(void)
char cache_path[MAX_PATH];
snprintf(cache_path, sizeof(cache_path), "%s/cache", instances_path);
if (ensure_directories_exist(cache_path, 0, NULL, NULL, BACKING_DIRECTORY_PERM) == -1) {
- free(instances_path);
+ EUCA_FREE(instances_path);
return ERROR;
}
char work_path[MAX_PATH];
snprintf(work_path, sizeof(work_path), "%s/work", instances_path);
if (ensure_directories_exist(work_path, 0, NULL, NULL, BACKING_DIRECTORY_PERM) == -1) {
- free(instances_path);
+ EUCA_FREE(instances_path);
return ERROR;
}
// determine how much is used/available in work and cache areas on the backing store
@@ -1559,7 +1554,7 @@ static int init(void)
// sanity check
if (work_fs_avail_mb < MIN_BLOBSTORE_SIZE_MB) {
logprintfl(EUCAERROR, "insufficient available work space (%lld MB) under %s/work\n", work_fs_avail_mb, instances_path);
- free(instances_path);
+ EUCA_FREE(instances_path);
return ERROR_FATAL;
}