cvs: php4 /ext/ircg ircg.c

From: Date: Tue, 16 Jan 2001 06:53:30 +0000
Subject: cvs: php4 /ext/ircg ircg.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-3648@lists.php.net to get a copy of this message
sas Mon Jan 15 22:53:30 2001 EDT Modified files: /php4/ext/ircg ircg.c Log: Use the write buffer subsystem to accumulate network writes and to increase the overall through-put. Index: php4/ext/ircg/ircg.c diff -u php4/ext/ircg/ircg.c:1.21 php4/ext/ircg/ircg.c:1.22 --- php4/ext/ircg/ircg.c:1.21 Fri Jan 12 08:42:09 2001 +++ php4/ext/ircg/ircg.c Mon Jan 15 22:53:30 2001 @@ -67,6 +67,7 @@ }; #include "if_irc.h" +#include "irc_write_buffer.h" typedef struct { char *fmt_msgs[NO_FMTS]; @@ -78,6 +79,7 @@ int fd; int irconn_id; php_fmt_msgs_t *fmt_msgs; + irc_write_buf wb; } php_irconn_t; static char *fmt_msgs_default[] = { @@ -142,10 +144,11 @@ static void quit_handler(irconn_t *c, void *dummy) { php_irconn_t *conn = dummy; - int i; - if (conn->fd > -1) + if (conn->fd > -1) { zend_hash_index_del(&h_fd2irconn, conn->fd); + irc_write_buf_del(&conn->wb); + } conn->fd = -2; zend_hash_index_del(&h_irconn, conn->irconn_id); @@ -318,18 +321,12 @@ static void http_closed_connection(int fd); -static void msg_send(php_irconn_t *conn, smart_str *msg) +static void msg_accum_send(php_irconn_t *conn, smart_str *msg) { if (msg->c == 0) return; if (conn->fd != -1) { - int n; - - n = send(conn->fd, msg->c, msg->len, 0); - - if ((n == -1 && errno == EPIPE) || n == 0) { - http_closed_connection(conn->fd); - } + irc_write_buf_append(&conn->wb, msg); } else if (conn->fd == -2) { /* do nothing */ } else { @@ -340,9 +337,16 @@ } } +static void msg_send(php_irconn_t *conn, smart_str *msg) +{ + msg_accum_send(conn, msg); + if (conn->fd != -1) + irc_write_buf_flush(&conn->wb); +} + static void msg_send_apply(void *data, void *arg) { - msg_send(arg, data); + msg_accum_send(arg, data); } static void msg_replay_buffer(php_irconn_t *conn) @@ -470,8 +474,10 @@ thttpd_set_dont_close(); conn->fd = thttpd_get_fd(); 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); msg_replay_buffer(conn); + irc_write_buf_flush(&conn->wb); msg_empty_buffer(conn); RETURN_TRUE;

« previous php.cvs (#3648) next »