forked from Mirrors/privacore-open-source-search-engine
Remove unreachable code
This commit is contained in:
125
Process.cpp
125
Process.cpp
@ -789,133 +789,8 @@ void *hdtempStartWrapper_r ( void *state , ThreadEntry *t ) {
|
||||
// run the df -ka cmd
|
||||
g_process.m_diskUsage = getDiskUsage( &g_process.m_diskAvail );
|
||||
|
||||
|
||||
// ignore temps now. ssds don't have it
|
||||
return NULL;
|
||||
|
||||
|
||||
static char *s_parm = "ata";
|
||||
// make a system call to /usr/sbin/hddtemp /dev/sda,b,c,d
|
||||
//char *cmd =
|
||||
// "/usr/sbin/hddtemp /dev/sda > /tmp/hdtemp ;"
|
||||
// "/usr/sbin/hddtemp /dev/sdb >> /tmp/hdtemp ;"
|
||||
// "/usr/sbin/hddtemp /dev/sdc >> /tmp/hdtemp ;"
|
||||
// "/usr/sbin/hddtemp /dev/sdd >> /tmp/hdtemp ";
|
||||
retry:
|
||||
// linux 2.4 does not seem to like hddtemp
|
||||
char *path = g_hostdb.m_dir;
|
||||
//char *path = "/usr/sbin/";
|
||||
char cmd[10048];
|
||||
sprintf ( cmd ,
|
||||
"%ssmartctl -Ad %s /dev/sda | grep Temp | awk '{print $10}' > /tmp/hdtemp2;"
|
||||
"%ssmartctl -Ad %s /dev/sdb | grep Temp | awk '{print $10}' >> /tmp/hdtemp2;"
|
||||
"%ssmartctl -Ad %s /dev/sdc | grep Temp | awk '{print $10}' >> /tmp/hdtemp2;"
|
||||
"%ssmartctl -Ad %s /dev/sdd | grep Temp | awk '{print $10}' >> /tmp/hdtemp2" ,
|
||||
path,s_parm ,
|
||||
path,s_parm ,
|
||||
path,s_parm ,
|
||||
path,s_parm );
|
||||
// the output
|
||||
char *out = "/tmp/hdtemp2";
|
||||
// timeout of 5 seconds
|
||||
//int err = my_system_r ( cmd , 5 );
|
||||
int err = system ( cmd );
|
||||
//logf(LOG_DEBUG,"proc: system \"%s\"",cmd);
|
||||
if ( err == 127 ) {
|
||||
//m_errno = EBADENGINEER;
|
||||
log("build: /bin/sh does not exist.");
|
||||
return NULL;
|
||||
}
|
||||
// this will happen if you don't upgrade glibc to 2.2.4-32 or above
|
||||
if ( err != 0 ) {
|
||||
//m_errno = EBADENGINEER;
|
||||
log("build: Call to system(\"%s\") had error.",cmd);
|
||||
//s_flag = 1;
|
||||
// wait 5 minutes
|
||||
s_nextTime = getTime() + 300; // 3600;
|
||||
return NULL;
|
||||
}
|
||||
// read in temperatures from file
|
||||
int fd = open ( "/tmp/hdtemp2" , O_RDONLY );
|
||||
if ( fd < 0 ) {
|
||||
//m_errno = errno;
|
||||
log("build: Could not open %s for reading: %s.",
|
||||
out,mstrerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
char buf[2000];
|
||||
int32_t r = read ( fd , buf , 2000 );
|
||||
// maybe try the marvell option?
|
||||
if ( r == 0 && s_parm[0]!='m' ) {
|
||||
log("gb: smartctl did not work. Trying marvell option.");
|
||||
s_parm = "marvell";
|
||||
goto retry;
|
||||
}
|
||||
else if ( r == 0 ) {
|
||||
log("gb: Please run apt-get install smartmontools to install "
|
||||
"smartctl and then chown root:root %ssmartctl ; "
|
||||
"chmod +s %ssmartctl. cmd=%s",path,path,cmd);
|
||||
// wait 5 mins
|
||||
s_nextTime = getTime() + 300;
|
||||
}
|
||||
// did we get an error
|
||||
if ( r < 0 ) {
|
||||
//m_errno = errno;
|
||||
log("build: Error reading %s: %s.",out,mstrerror(errno));
|
||||
close ( fd );
|
||||
return NULL;
|
||||
}
|
||||
// clean up shop
|
||||
close ( fd );
|
||||
// . typical file from hddtemp:
|
||||
// /dev/sda: ST3400620AS: 39 C
|
||||
// /dev/sdb: ST3400620AS: 39 C
|
||||
// /dev/sdc: ST3400620AS: 39 C
|
||||
// /dev/sdd: ST3400620AS: 39 C
|
||||
// . typical file from smartctl
|
||||
// 39\n37\n37\n37\n
|
||||
char *p = buf;
|
||||
// end
|
||||
char *pend = buf + gbstrlen(buf);
|
||||
// store the temps here
|
||||
int16_t *temp = g_hostdb.m_myHost->m_pingInfo.m_hdtemps;
|
||||
// there are 4
|
||||
int16_t *tempEnd = temp + 4;
|
||||
|
||||
//
|
||||
// parse output from smartctl
|
||||
//
|
||||
while ( temp < tempEnd ) {
|
||||
// get temp
|
||||
*temp++ = atoi(p);
|
||||
// skip til after \n
|
||||
while ( p < pend && *p != '\n' ) p++;
|
||||
// skip \n
|
||||
p++;
|
||||
// done? strange.
|
||||
if ( p >= pend ) return NULL;
|
||||
}
|
||||
// done
|
||||
return NULL;
|
||||
|
||||
//
|
||||
// parse output from hddtemp
|
||||
//
|
||||
|
||||
// get all 4
|
||||
while ( temp < tempEnd ) {
|
||||
// skip till after 2nd colon
|
||||
while ( p < pend && *p!=':' ) p++;
|
||||
// skip over colon
|
||||
p++;
|
||||
// skip until we hit 2nd colon
|
||||
while ( p < pend && *p!=':' ) p++;
|
||||
// skip colon and space
|
||||
p += 2;
|
||||
// get temp
|
||||
*temp++ = atoi(p);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Process::callHeartbeat () {
|
||||
|
21
main.cpp
21
main.cpp
@ -1210,7 +1210,6 @@ int main2 ( int argc , char *argv[] ) {
|
||||
if ( strcmp ( cmd , "proxy" ) == 0 ) {
|
||||
if (argc < 3){
|
||||
goto printHelp;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int32_t proxyId = -1;
|
||||
@ -1248,7 +1247,6 @@ int main2 ( int argc , char *argv[] ) {
|
||||
|
||||
else if ( proxyId == -1 || strcmp ( argv[cmdarg+1] , "load" ) != 0 ) {
|
||||
goto printHelp;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Host *h = g_hostdb.getProxy( proxyId );
|
||||
@ -1304,7 +1302,6 @@ int main2 ( int argc , char *argv[] ) {
|
||||
if ( ! hashinit() ) {
|
||||
log("db: Failed to init hashtable." ); return 1; }
|
||||
|
||||
tryagain:
|
||||
if ( ! g_proxy.initHttpServer( httpPort, httpsPort ) ) {
|
||||
log("db: HttpServer init failed. Another gb "
|
||||
"already running? If not, try editing "
|
||||
@ -1315,11 +1312,6 @@ int main2 ( int argc , char *argv[] ) {
|
||||
, (int32_t)httpPort );
|
||||
// this is dangerous!!! do not do the shutdown thing
|
||||
return 1;
|
||||
// just open a socket to port X and send
|
||||
// GET /master?save=1
|
||||
if ( shutdownOldGB(httpPort) ) goto tryagain;
|
||||
log("db: Shutdown failed.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
//we should save gb.conf right ?
|
||||
@ -10547,9 +10539,6 @@ int injectFile ( char *filename , char *ips ,
|
||||
log("cmd: done injecting archives for split %i",split);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool isDelete = false;
|
||||
int64_t startDocId = 0LL;
|
||||
int64_t endDocId = MAX_DOCID;
|
||||
@ -12283,16 +12272,6 @@ bool memTest() {
|
||||
g_mem.m_used,g_conf.m_maxMem);
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
fprintf(stderr, "memtest: Dumping core to test max core file size.\n");
|
||||
char *xx = NULL;
|
||||
*xx = 0;
|
||||
for (i=0;i<numPtrs;i++){
|
||||
mfree(ptrs[i], 1024*1024, "memtest");
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user