[dovecot-cvs] dovecot/src/auth auth-worker-client.c,1.10,1.11
cras at dovecot.org
cras at dovecot.org
Sat May 28 15:51:50 EEST 2005
Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv8321
Modified Files:
auth-worker-client.c
Log Message:
If worker process has been idle for 10 minutes, make it kill itself.
Index: auth-worker-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-worker-client.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- auth-worker-client.c 26 Apr 2005 11:43:36 -0000 1.10
+++ auth-worker-client.c 28 May 2005 12:51:43 -0000 1.11
@@ -11,6 +11,9 @@
#include <stdlib.h>
+/* If no requests have come within this time, kill ourself */
+#define AUTH_WORKER_MAX_IDLE (60*10)
+
#define OUTBUF_THROTTLE_SIZE (1024*10)
struct auth_worker_client {
@@ -21,6 +24,9 @@
struct io *io;
struct istream *input;
struct ostream *output;
+
+ time_t last_request;
+ struct timeout *to;
};
static void auth_worker_client_unref(struct auth_worker_client *client);
@@ -306,6 +312,8 @@
return;
}
+ client->last_request = ioloop_time;
+
client->refcount++;
while ((line = i_stream_next_line(client->input)) != NULL) {
t_push();
@@ -338,6 +346,14 @@
return 1;
}
+static void auth_worker_client_timeout(void *context)
+{
+ struct auth_worker_client *client = context;
+
+ if (client->last_request + AUTH_WORKER_MAX_IDLE <= ioloop_time)
+ auth_worker_client_destroy(client);
+}
+
struct auth_worker_client *
auth_worker_client_create(struct auth *auth, int fd)
{
@@ -356,6 +372,9 @@
o_stream_set_flush_callback(client->output, auth_worker_output, client);
client->io = io_add(fd, IO_READ, auth_worker_input, client);
+ client->last_request = ioloop_time;
+ client->to = timeout_add(1000*60, auth_worker_client_timeout, client);
+
return client;
}
@@ -364,6 +383,8 @@
if (client->fd == -1)
return;
+ timeout_remove(client->to);
+
i_stream_close(client->input);
o_stream_close(client->output);
More information about the dovecot-cvs
mailing list