Set non-blocking mode on incoming TCP connections.
authorKen Raeburn <raeburn@mit.edu>
Fri, 18 Jul 2008 06:50:34 +0000 (06:50 +0000)
committerKen Raeburn <raeburn@mit.edu>
Fri, 18 Jul 2008 06:50:34 +0000 (06:50 +0000)
Don't log EINTR error in select loop.
Log when shutdown signal has been received and acted on.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20541 dc483132-0cff-0310-8789-dd5450dbe970

src/kdc/network.c

index f471a3a70985d135f547050a45b264186bdb906c..f3b87a17653a3682bda511ce243111ab0ed048c1 100644 (file)
@@ -386,12 +386,19 @@ delete_fd (struct connection *xconn)
     free(xconn);
 }
 
+static const int one = 1;
+
 static int
 setnbio(int sock)
 {
-    static const int one = 1;
     return ioctlsocket(sock, FIONBIO, (const void *)&one);
 }
+
+static int
+setkeepalive(int sock)
+{
+    return setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof(one));
+}
 \f
 static int
 setnolinger(int s)
@@ -1251,7 +1258,7 @@ static void accept_tcp_connection(struct connection *conn, const char *prog,
        close(s);
        return;
     }
-    setnbio(s), setnolinger(s);
+    setnbio(s), setnolinger(s), setkeepalive(s);
 
     sockdata.prog = prog;
     sockdata.retval = 0;
@@ -1570,7 +1577,8 @@ listen_and_process(const char *prog)
 
        err = krb5int_cm_call_select(&sstate, &sout, &sret);
        if (err) {
-           com_err(prog, err, "while selecting for network input(1)");
+           if (err != EINTR)
+               com_err(prog, err, "while selecting for network input(1)");
            continue;
        }
        if (sret == 0 && netchanged) {
@@ -1601,6 +1609,7 @@ listen_and_process(const char *prog)
                service_conn(conns[i], prog, sflags);
        }
     }
+    krb5_klog_syslog(LOG_INFO, "shutdown signal received");
     return 0;
 }