cvs: php4 /ext/ircg ircg.c
| From: | Sascha Schumann | Date: | Mon, 30 Jul 2001 06:35:57 +0000 |
| Subject: | cvs: php4 /ext/ircg ircg.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-6402@lists.php.net to get a copy of this message | ||
sas Mon Jul 30 02:35:57 2001 EDT
Modified files:
/php4/ext/ircg ircg.c
Log:
Fix leak and let error_msg gc run every fifty logins by default.
Also save a syscall per login.
Index: php4/ext/ircg/ircg.c
diff -u php4/ext/ircg/ircg.c:1.91 php4/ext/ircg/ircg.c:1.92
--- php4/ext/ircg/ircg.c:1.91 Mon Jul 30 02:17:55 2001
+++ php4/ext/ircg/ircg.c Mon Jul 30 02:35:57 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ircg.c,v 1.91 2001/07/30 06:17:55 zeev Exp $ */
+/* $Id: ircg.c,v 1.92 2001/07/30 06:35:57 sas Exp $ */
#include <time.h>
@@ -35,6 +35,8 @@
#include "ext/standard/info.h"
#include "ext/standard/basic_functions.h"
+#define IRCG_ERROR_MSG_GC_INTERVAL 50
+
/* This module is not intended for thread-safe use */
static HashTable h_fd2irconn; /* fd's to Integer IDs */
@@ -230,7 +232,10 @@
while (f->ntoken-- > 0) {
switch (f->t[i].code) {
- case C_STRING: smart_str_free_ex(f->t[i].para.ptr, 1); free(f->t[i].para.ptr); break;
+ case C_STRING:
+ smart_str_free_ex(f->t[i].para.ptr, 1);
+ free(f->t[i].para.ptr);
+ break;
}
i++;
}
@@ -563,6 +568,7 @@
return;
}
smart_str_append_ex(&conn->buffer, msg, 1);
+ smart_str_free_ex(msg, 1);
break;
default:
#if defined(IRCG_API_VERSION) && IRCG_API_VERSION >= 20010302
@@ -745,7 +751,7 @@
struct errormsg *m, *prev = NULL, *next;
int lim;
- lim = irconn_id - 1000;
+ lim = irconn_id - IRCG_ERROR_MSG_GC_INTERVAL;
for (m = errormsgs; m; prev = m, m = m->next) {
if (m->id < lim) {
@@ -1535,13 +1541,17 @@
}
conn->password = conn->ident = NULL;
irconn_id++;
- if ((irconn_id % 1000) == 0)
+ if ((irconn_id % IRCG_ERROR_MSG_GC_INTERVAL) == 0)
error_msg_gc();
conn->irconn_id = irconn_id;
zend_hash_index_update(&h_irconn, irconn_id, &conn, sizeof(conn), NULL);
conn->buffer.c = NULL;
conn->buffer_count = 0;
+#if IRCG_API_VERSION >= 20010601
+ conn->login = ircg_now_time_t;
+#else
time(&conn->login);
+#endif
RETVAL_LONG(irconn_id);
}