fixed bugs

This commit is contained in:
Edward Emelianov 2023-11-28 11:19:23 +03:00
parent 0c8908b52b
commit e6fb720604
4 changed files with 11 additions and 12 deletions

View File

@ -1,7 +0,0 @@
[MSG] 2023/06/01-17:54:37 hello, start
[DBG] 2023/06/01-17:54:37 SQLite version: 3.42.0
[MSG] 2023/06/01-17:54:37 Started
[MSG] 2023/06/01-17:54:37 Created child with pid 10010
[MSG] 2023/06/01-17:54:37 SEND to fd 3: statsimple60
[WARN] 2023/06/01-17:54:49 Child killed with sig=2
[ERR] 2023/06/01-17:54:49 Received signal 2, die

View File

@ -80,8 +80,6 @@ int main(int argc, char **argv){
if(G.logfile) OPENLOG(G.logfile, lvl, 1);
LOGMSG("hello, start");
LOGDBG("SQLite version: %s", sqlite3_libversion());
int sock = open_socket(G.server, G.port);
if(sock < 0) ERRX("Can't open socket to %s:%s", G.server, G.port);
check4running(self, G.pidfile);
// signal reactions:
signal(SIGTERM, signals); // kill (-15) - quit
@ -110,6 +108,8 @@ int main(int argc, char **argv){
}
#endif
if(!opendb(G.dbname)) return 1;
int sock = open_socket(G.server, G.port);
if(sock < 0) ERRX("Can't open socket to %s:%s", G.server, G.port);
run_socket(sock);
LOGERR("Unreachable code reached");
signals(1);

View File

@ -69,7 +69,12 @@ static void sendmessage(int fd, const char *msg, int l){
char *tmpbuf = MALLOC(char, l+1);
memcpy(tmpbuf, msg, l);
if(msg[l-1] != '\n') tmpbuf[l++] = '\n';
if(l != send(fd, tmpbuf, l, MSG_NOSIGNAL)){
ssize_t s = send(fd, tmpbuf, l, MSG_NOSIGNAL);
if(l != s){
if(s < 0){
LOGERR("Server disconnected!");
ERR("Disconnected");
}
LOGWARN("write()");
WARN("write()");
}else{

View File

@ -120,10 +120,11 @@ static int parseans(char *str, weather_t *w){
str += el->parlen;
char *endptr;
*el->weatherpar = strtod(str, &endptr);
//DBG("found par: %s, val=%g", el->parname, *el->weatherpar);
DBG("found par: %s, val=%g", el->parname, *el->weatherpar);
if(endptr == str){
DBG("Wrong double value");
return FALSE;
*el->weatherpar = 0.;
//return FALSE;
}
break;
}