]> andersk Git - moira.git/commitdiff
Add keepalive feature.
authorwesommer <wesommer>
Wed, 29 Jul 1987 16:04:54 +0000 (16:04 +0000)
committerwesommer <wesommer>
Wed, 29 Jul 1987 16:04:54 +0000 (16:04 +0000)
server/mr_main.c

index 2eed9b409c857daa1360622dd474076259bb081e..261fbcce9a9f5ee02cc86b6f394b558acb25f660 100644 (file)
  *     Let the reader beware.
  * 
  *     $Log$
- *     Revision 1.10  1987-06-30 20:02:26  wesommer
- *     Added returned tuple chain to client structure.
- *     Added local realm global variable.
+ *     Revision 1.11  1987-07-29 16:04:54  wesommer
+ *     Add keepalive feature.
  *
+ * Revision 1.10  87/06/30  20:02:26  wesommer
+ * Added returned tuple chain to client structure.
+ * Added local realm global variable.
+ * 
  * Revision 1.9  87/06/21  16:39:54  wesommer
  * Performance work, rearrangement of include files.
  * 
@@ -82,6 +85,8 @@ void clist_append();
 void oplist_append();
 extern u_short ntohs();
 
+extern time_t now;
+
 /*
  * Main SMS server loop.
  *
@@ -96,6 +101,7 @@ main(argc, argv)
        char **argv;
 {
        int status;
+       time_t tardy;
        
        whoami = argv[0];
        /*
@@ -187,19 +193,26 @@ main(argc, argv)
                        continue;
                }
                if (takedown) break;
+               time(&now);
 #ifdef notdef
                fprintf(stderr, "    tick\n");
 #endif notdef
                /*
                 * Handle any existing connections.
                 */
+               tardy = now - 30*60;
+               
                for (i=0; i<nclients; i++) {
+                       cur_client = clients[i];
                        if (OP_DONE(clients[i]->pending_op)) {
-                               cur_client = clients[i];
+                               cur_client->last_time_used = now;
                                do_client(cur_client);
-                               cur_client = NULL;
-                               if (takedown) break;
+                       } else if (clients[i]->last_time_used < tardy) {
+                               com_err(whoami, 0, "Shutting down connection due to inactivity");
+                               shutdown(cur_client->con->in.fd, 0);
                        }
+                       cur_client = NULL;
+                       if (takedown) break;
                }
                /*
                 * Handle any new connections.
@@ -281,7 +294,7 @@ new_connection()
        cp->reply.sms_argv = NULL;
        cp->first = NULL;
        cp->last = NULL;
-       
+       cp->last_time_used = now;
        newconn = NULL;
        
        cp->pending_op = create_operation();
This page took 0.118752 seconds and 5 git commands to generate.