thermferm/server.c

changeset 235
885ad8d52126
parent 223
14700edd2a67
child 237
51a294d683cd
--- a/thermferm/server.c	Wed Aug 13 21:21:55 2014 +0200
+++ b/thermferm/server.c	Wed Aug 13 21:41:10 2014 +0200
@@ -74,12 +74,12 @@
     }
 
     if (send(s, out, strlen(out), 0) != strlen(out)) {
-	syslog(LOG_NOTICE, "srv_send failed");
+	syslog(LOG_WARNING, "srv_send failed");
 	return -1;
     }
     
     if (send(s, (char *)"\r\n", 2, 0) != 2) {
-	syslog(LOG_NOTICE, "srv_send failed");
+	syslog(LOG_WARNING, "srv_send failed");
 	return -1;
     }
 
@@ -329,7 +329,7 @@
 		    fromlen = sizeof(peeraddr_in);
 		    rlen = recvfrom(s, ibuf, sizeof(ibuf) -1, 0, (struct sockaddr *)&peeraddr_in, &fromlen);
 		    if (rlen == -1) {
-			syslog(LOG_NOTICE, "recvfrom(): %s", strerror(errno));
+			syslog(LOG_WARNING, "recvfrom(): %s", strerror(errno));
 			srv_send((char *)"518 recfrom(): %s", strerror(errno));
 			return 1;
 		    }
@@ -471,7 +471,7 @@
 	    fromlen = sizeof(peeraddr_in);
 	    rlen = recvfrom(s, ibuf, sizeof(ibuf) -1, 0, (struct sockaddr *)&peeraddr_in, &fromlen);
 	    if (rlen == -1) {
-		syslog(LOG_NOTICE, "recvfrom(): %s", strerror(errno));
+		syslog(LOG_WARNING, "recvfrom(): %s", strerror(errno));
 		srv_send((char *)"518 recfrom(): %s", strerror(errno));
 		return 1;
 	    }
@@ -736,7 +736,7 @@
 		    fromlen = sizeof(peeraddr_in);
 		    rlen = recvfrom(s, ibuf, sizeof(ibuf) -1, 0, (struct sockaddr *)&peeraddr_in, &fromlen);
 		    if (rlen == -1) {
-			syslog(LOG_NOTICE, "recvfrom(): %s", strerror(errno));
+			syslog(LOG_WARNING, "recvfrom(): %s", strerror(errno));
 			srv_send((char *)"518 recfrom(): %s", strerror(errno));
 			return 1;
 		    }
@@ -814,7 +814,7 @@
             	    fromlen = sizeof(peeraddr_in);
 	    	    rlen = recvfrom(s, ibuf, sizeof(ibuf) -1, 0, (struct sockaddr *)&peeraddr_in, &fromlen);
 	    	    if (rlen == -1) {
-	    	    	syslog(LOG_NOTICE, "recvfrom(): %s", strerror(errno));
+	    	    	syslog(LOG_WARNING, "recvfrom(): %s", strerror(errno));
 		    	srv_send((char *)"518 recfrom(): %s", strerror(errno));
 		    	return 1;
 	    	    } else {
@@ -1094,7 +1094,7 @@
 		    fromlen = sizeof(peeraddr_in);
 		    rlen = recvfrom(s, ibuf, sizeof(ibuf) -1, 0, (struct sockaddr *)&peeraddr_in, &fromlen);
 		    if (rlen == -1) {
-			syslog(LOG_NOTICE, "recvfrom(): %s", strerror(errno));
+			syslog(LOG_WARNING, "recvfrom(): %s", strerror(errno));
 			srv_send((char *)"518 recfrom(): %s", strerror(errno));
 			return 1;
 		    }
@@ -1333,7 +1333,7 @@
     fromlen = sizeof(peeraddr_in);
     rlen = recvfrom(s, buf, sizeof(buf) -1, 0, (struct sockaddr *)&peeraddr_in, &fromlen);
     if (rlen == -1) {
-	syslog(LOG_NOTICE, "recvfrom(): %s", strerror(errno));
+	syslog(LOG_WARNING, "recvfrom(): %s", strerror(errno));
     } else {		    
 	for (i = 0; i < strlen(buf); i++) {
 	    if (buf[i] == '\n')
@@ -1430,38 +1430,36 @@
 
     ls = socket(AF_INET, SOCK_STREAM, 0);
     if (ls == -1) {
-	syslog(LOG_NOTICE, "Can't create listen socket: %s", strerror(errno));
+	syslog(LOG_WARNING, "Can't create listen socket: %s", strerror(errno));
 	fprintf(stderr, "Can't create listen socket: %s\n", strerror(errno));
 	return 0;
     }
 
     if (setsockopt(ls, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) == -1) {
-	syslog(LOG_NOTICE, "Can't setsockopt SO_KEEPALIVE socket: %s", strerror(errno));
+	syslog(LOG_WARNING, "Can't setsockopt SO_KEEPALIVE socket: %s", strerror(errno));
 	close(ls);
 	return 0;
     }
 
     if (setsockopt(ls, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) == -1) {
-	syslog(LOG_NOTICE, "Can't setsockopt SO_REUSEADDR socket: %s", strerror(errno));
+	syslog(LOG_WARNING, "Can't setsockopt SO_REUSEADDR socket: %s", strerror(errno));
 	close(ls);
 	return 0;
     }
 
     if (bind(ls, (struct sockaddr *)&myaddr_in, sizeof(struct sockaddr_in)) == -1) {
-	syslog(LOG_NOTICE, "Can't bind to listen socket: %s", strerror(errno));
+	syslog(LOG_WARNING, "Can't bind to listen socket: %s", strerror(errno));
 	close(ls);
 	return 0;
     }
 
     if (listen(ls, 5) == -1) {
-	syslog(LOG_NOTICE, "Can't listen on listen socket: %s", strerror(errno));
+	syslog(LOG_WARNING, "Can't listen on listen socket: %s", strerror(errno));
 	close(ls);
 	return 0;
     }
 
     syslog(LOG_NOTICE, "listen socket created %d", ls);
-    if (debug)
-	fprintf(stdout, "listen socket created %d\n", ls);
 
 
     /*
@@ -1478,7 +1476,7 @@
 	 */
 	s = accept(ls, (struct sockaddr *)&peeraddr_in, &addrlen);
 	if (s == -1) {
-	    syslog(LOG_NOTICE, "my_server_loop accept failed %s", strerror(errno));
+	    syslog(LOG_WARNING, "my_server_loop accept failed %s", strerror(errno));
 	    if (debug)
 		fprintf(stdout, "my_server_loop accept failed %s\n", strerror(errno));
 	    return 0;

mercurial