cvs: php4 /ext/ircg ircg.c
| From: | Sascha Schumann | Date: | Sat, 28 Apr 2001 14:06:41 +0000 |
| Subject: | cvs: php4 /ext/ircg ircg.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-5346@lists.php.net to get a copy of this message | ||
sas Sat Apr 28 07:06:41 2001 EDT
Modified files:
/php4/ext/ircg ircg.c
Log:
Add some logic that deconnects a client, when it has been connected to
the IRC server for longer than 20 seconds and if more than 50 messages
have been queued up.
Index: php4/ext/ircg/ircg.c
diff -u php4/ext/ircg/ircg.c:1.66 php4/ext/ircg/ircg.c:1.67
--- php4/ext/ircg/ircg.c:1.66 Sat Apr 28 05:57:56 2001
+++ php4/ext/ircg/ircg.c Sat Apr 28 07:06:41 2001
@@ -16,8 +16,10 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ircg.c,v 1.66 2001/04/28 12:57:56 sas Exp $ */
+/* $Id: ircg.c,v 1.67 2001/04/28 14:06:41 sas Exp $ */
+#include <time.h>
+
#include "php.h"
#include "php_ini.h"
#include "php_ircg.h"
@@ -109,6 +111,8 @@
typedef struct {
irconn_t conn;
zend_llist buffer;
+ time_t login;
+ int buffer_count;
int fd;
int irconn_id;
php_fmt_msgs_t *fmt_msgs;
@@ -467,7 +471,7 @@
{
zend_llist_clean(&conn->buffer);
}
-
+
static void http_closed_connection(int fd);
static void msg_accum_send(php_irconn_t *conn, smart_str *msg)
@@ -484,6 +488,13 @@
} else if (conn->fd == -2) {
/* do nothing */
} else {
+ if (conn->buffer_count++ > 50) {
+ time_t now = time(NULL);
+
+ if ((now - conn->login) > 20)
+ irc_disconnect(&conn->conn, "Timed out waiting for window");
+ return;
+ }
zend_llist_add_element(&conn->buffer, msg);
}
}
@@ -1278,6 +1289,8 @@
conn->irconn_id = irconn_id;
zend_hash_index_update(&h_irconn, irconn_id, &conn, sizeof(conn), NULL);
zend_llist_init(&conn->buffer, sizeof(smart_str), NULL, 1);
+ conn->buffer_count = 0;
+ time(&conn->login);
RETVAL_LONG(irconn_id);
}