]> mj.ucw.cz Git - eval.git/commitdiff
Use setproctitle() to display status.
authorMartin Mares <mj@ucw.cz>
Mon, 4 Jun 2007 07:52:15 +0000 (09:52 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 4 Jun 2007 07:52:15 +0000 (09:52 +0200)
submit/commands.c
submit/submitd.c
submit/submitd.h

index dc71e3039e61a700f299130bbcd5e404437613fe..49440993d73b8975accfa299899b3c8b65a8b1f6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  The Submit Daemon: Processing of Commands
+ *  The Submit Daemon: High-Level Part of the Protocol
  *
  *  (c) 2007 Martin Mares <mj@ucw.cz>
  */
@@ -136,6 +136,7 @@ execute_init(struct conn *c)
       return;
     }
   obj_set_attr(c->reply, '+', "OK");
+  c->user = xstrdup(user);
 }
 
 int
index 22be143b6aad69f635c0dec767fc7306fa5493d1..211cc1b12a4b5ba104dbd2531e61b1c933112efc 100644 (file)
@@ -105,6 +105,8 @@ conn_new(void)
 static void
 conn_free(struct conn *c)
 {
+  xfree(c->ip_string);
+  xfree(c->cert_name);
   clist_remove(&c->n);
   num_conn--;
   xfree(c);
@@ -249,9 +251,9 @@ tls_log_params(struct conn *c)
     proto, kx, cert, comp, cipher, mac);
 }
 
-/*** SOCKET FASTBUFS ***/
+/*** FASTBUFS OVER SOCKETS AND TLS ***/
 
-void NONRET
+void NONRET                            // Fatal protocol violation
 client_error(char *msg, ...)
 {
   va_list args;
@@ -353,6 +355,7 @@ sigalrm_handler(int sig UNUSED)
 static void
 client_loop(struct conn *c)
 {
+  setproctitle("submitd: client %s", c->ip_string);
   log_pid = c->id;
   init_sk_fastbufs(c);
 
@@ -387,12 +390,15 @@ client_loop(struct conn *c)
   if (!process_init(c))
     log(L_ERROR, "Protocol handshake failed");
   else
-    for (;;)
-      {
-       alarm(session_timeout);
-       if (!process_command(c))
-         break;
-      }
+    {
+      setproctitle("submitd: client %s (%s)", c->ip_string, c->user);
+      for (;;)
+       {
+         alarm(session_timeout);
+         if (!process_command(c))
+           break;
+       }
+    }
 
   if (c->tls)
     gnutls_bye(c->tls, GNUTLS_SHUT_WR);
@@ -493,6 +499,7 @@ sk_accept(void)
        (rule->plain_text ? "plain-text" : "TLS"),
        (rule->allow_admin ? "admin" : "user"));
   c->ip = addr;
+  c->ip_string = xstrdup(ipbuf);
   c->sk = sk;
   c->rule = rule;
 
@@ -551,6 +558,7 @@ int main(int argc, char **argv)
 
   for (;;)
     {
+      setproctitle("submitd: %d connections", num_conn);
       int status;
       pid_t pid = waitpid(-1, &status, WNOHANG);
       if (pid > 0)
index 7e0d4345378b656efc1cdbccb5f7c5d167b67b52..c780f53a058d7f1bf1c0a7adaf1db15ce619c9a3 100644 (file)
@@ -26,11 +26,12 @@ struct conn {
   // Set up by the master process
   cnode n;
   u32 ip;
+  byte *ip_string;                     // (xmalloced)
   pid_t pid;
   uns id;
   struct access_rule *rule;            // Rule matched by this connection
   int sk;                              // Client socket
-  byte *cert_name;                     // Client name from the certificate (NULL if no TLS)
+  byte *cert_name;                     // Client name from the certificate (NULL if no TLS) (xmalloced)
 
   // Used by the child process
   gnutls_session_t tls;                        // TLS session