cvs: php4 /ext/ircg ircg.c
| From: | Sascha Schumann | Date: | Sun, 29 Jul 2001 01:59:49 +0000 |
| Subject: | cvs: php4 /ext/ircg ircg.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-6385@lists.php.net to get a copy of this message | ||
sas Sat Jul 28 21:59:49 2001 EDT
Modified files:
/php4/ext/ircg ircg.c
Log:
Eliminate a check from the tokenizer and add support for detecting
dead fds before setting them up as persistent HTTP connections.
Index: php4/ext/ircg/ircg.c
diff -u php4/ext/ircg/ircg.c:1.86 php4/ext/ircg/ircg.c:1.87
--- php4/ext/ircg/ircg.c:1.86 Wed Jul 25 12:23:03 2001
+++ php4/ext/ircg/ircg.c Sat Jul 28 21:59:49 2001
@@ -16,10 +16,12 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ircg.c,v 1.86 2001/07/25 16:23:03 sas Exp $ */
+/* $Id: ircg.c,v 1.87 2001/07/29 01:59:49 sas Exp $ */
#include <time.h>
+#include <fcntl.h>
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -400,7 +402,7 @@
static void token_compiler(const char *fmt, format_msg_t *f)
{
const char *p, *pe;
- char *q;
+ const char *q;
token_t *t = NULL;
int n = 0;
char mode;
@@ -419,7 +421,14 @@
do {
q = p;
- while (*q != '%') if (++q >= pe) break;
+ while (*q != '%')
+ if (++q >= pe) {
+ s = malloc(sizeof *s);
+ s->c = 0;
+ smart_str_appendl_ex(s, p, pe - p, 1);
+ NEW_TOKEN(C_STRING, ptr) = s;
+ goto leave_loop;
+ }
len = q - p;
if (len > 0) {
@@ -451,13 +460,8 @@
p = q + 1; /* skip last format character */
} while (p < pe);
- if (p < pe) {
- s = malloc(sizeof *s);
- s->c = 0;
- smart_str_appendl_ex(s, p, pe - p, 1);
- NEW_TOKEN(C_STRING, ptr) = s;
- }
-
+leave_loop:
+
f->ntoken = n;
f->t = t;
}
@@ -885,6 +889,10 @@
thttpd_register_on_close(http_closed_connection);
thttpd_set_dont_close();
conn->fd = thttpd_get_fd();
+ if (fcntl(conn->fd, F_GETFL) == -1) {
+ zend_hash_index_del(&h_irconn, Z_LVAL_PP(p1));
+ RETURN_FALSE;
+ }
zend_hash_index_update(&h_fd2irconn, conn->fd, &Z_LVAL_PP(p1), sizeof(int), NULL);
irc_write_buf_add(&conn->wb, conn->fd);
msg_http_start(conn);