sas             Fri Mar  2 12:32:42 2001 EDT

  Modified files:              
    /php4/ext/ircg      ircg.c 
  Log:
  Make use of the "zero-copy" write queue feature.
  
  
Index: php4/ext/ircg/ircg.c
diff -u php4/ext/ircg/ircg.c:1.40 php4/ext/ircg/ircg.c:1.41
--- php4/ext/ircg/ircg.c:1.40   Mon Feb 26 15:11:06 2001
+++ php4/ext/ircg/ircg.c        Fri Mar  2 12:32:42 2001
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: ircg.c,v 1.40 2001/02/26 23:11:06 sas Exp $ */
+/* $Id: ircg.c,v 1.41 2001/03/02 20:32:42 sas Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -164,13 +164,6 @@
        }
 }
 
-static void buffer_dtor(void *dummy)
-{
-       smart_str *msg = dummy;
-
-       smart_str_free_ex(msg, 1);
-}
-
 static void quit_handler(irconn_t *c, void *dummy)
 {
        php_irconn_t *conn = dummy;
@@ -272,14 +265,16 @@
        if (msg->c == 0) return;
 
        if (conn->fd != -1) {
+#if defined(IRCG_API_VERSION) && IRCG_API_VERSION >= 20010302
+               irc_write_buf_append_ex(&conn->wb, msg, 0);
+#else
                irc_write_buf_append(&conn->wb, msg);
+               smart_str_free_ex(msg, 1);
+#endif
        } else if (conn->fd == -2) {
                /* do nothing */
        } else {
-               smart_str msg2 = {0};
-
-               smart_str_append_ex(&msg2, msg, 1);
-               zend_llist_add_element(&conn->buffer, &msg2);
+               zend_llist_add_element(&conn->buffer, msg);
        }
 }
 
@@ -336,9 +331,8 @@
                smart_str *msg, void *conn_data, void *chan_data)
 {
        php_irconn_t *conn = conn_data;
-       static smart_str m;
+       smart_str m = {0};
 
-       m.len = 0;
        if (msg->c[0] == '\001') {
                handle_ctcp(conn, chan, from, msg, &m);
        } else if (chan) {
@@ -356,9 +350,8 @@
                void *dummy)
 {
        php_irconn_t *conn = dummy;
-       static smart_str m;
+       smart_str m = {0};
 
-       m.len = 0;
        format_msg(MSG(conn, FMT_MSG_NICK), NULL, newnick->c, oldnick->c, NULL,
                        &m);
        msg_send(conn, &m);
@@ -368,9 +361,8 @@
                smart_str *host, smart_str *real_name, void *dummy)
 {
        php_irconn_t *conn = dummy;
-       static smart_str m;
+       smart_str m = {0};
 
-       m.len = 0;
        format_msg(MSG(conn, FMT_MSG_WHOIS_USER), host->c, user->c, nick->c,
                        real_name->c, &m);
        msg_send(conn, &m);
@@ -381,9 +373,8 @@
                smart_str *server, smart_str *server_info, void *dummy)
 {
        php_irconn_t *conn = dummy;
-       static smart_str m;
+       smart_str m = {0};
 
-       m.len = 0;
        format_msg(MSG(conn, FMT_MSG_WHOIS_SERVER), server->c, NULL, nick->c,
                        server_info->c, &m);
        msg_send(conn, &m);
@@ -394,9 +385,8 @@
                smart_str *idletime, void *dummy)
 {
        php_irconn_t *conn = dummy;
-       static smart_str m;
+       smart_str m = {0};
 
-       m.len = 0;
        format_msg(MSG(conn, FMT_MSG_WHOIS_IDLE), NULL, NULL, nick->c,
                        idletime->c, &m);
        msg_send(conn, &m);
@@ -405,9 +395,8 @@
 static void end_of_whois_handler(irconn_t *c, smart_str *nick, void *dummy)
 {
        php_irconn_t *conn = dummy;
-       static smart_str m;
+       smart_str m = {0};
 
-       m.len = 0;
        format_msg(MSG(conn, FMT_MSG_WHOIS_END), NULL, NULL, nick->c, NULL, &m);
        msg_send(conn, &m);
 }
@@ -417,11 +406,9 @@
                smart_str *channels, int nr, void *dummy)
 {
        php_irconn_t *conn = dummy;
-       static smart_str m;
+       smart_str m = {0};
        int i;
        
-       m.len = 0;
-
        for (i = 0; i < nr; i++) {
                format_msg(MSG(conn, FMT_MSG_WHOIS_CHANNEL), channels[i].c, NULL, 
                                nick->c, NULL, &m);
@@ -433,9 +420,8 @@
 static void error_handler(irconn_t *ircc, int id, int fatal, smart_str *msg, void 
*conn_data)
 {
        php_irconn_t *conn = conn_data;
-       static smart_str m;
+       smart_str m = {0};
 
-       m.len = 0;      
        format_msg(MSG(conn, fatal ? FMT_MSG_FATAL_ERROR : FMT_MSG_ERROR), NULL, 
                        ircc->username, "IRC SERVER", msg->c, &m);
        
@@ -447,11 +433,9 @@
 {
        php_irconn_t *conn = dummy;
        int i;
-       static smart_str m;
+       smart_str m = {0};
 
        if (nr > 1) {
-               m.len = 0;
-               
                format_msg(MSG(conn, FMT_MSG_MASS_JOIN_BEGIN), channel, NULL, NULL,
                                "", &m);
                for (i = 0; i < nr; i++) {
@@ -462,7 +446,6 @@
                format_msg(MSG(conn, FMT_MSG_MASS_JOIN_END), channel, NULL, NULL,
                                "", &m);
        } else {
-               m.len = 0;
                format_msg(MSG(conn, FMT_MSG_JOIN), channel, NULL, users[0].c,
                                "", &m);
                format_msg(MSG(conn, FMT_MSG_JOIN_LIST_END), channel, NULL, NULL,
@@ -478,15 +461,13 @@
 
        format_msg(MSG(conn, FMT_MSG_TOPIC), channel, NULL, who->c, topic->c, &m);
        msg_send(conn, &m);
-       smart_str_free_ex(&m, 1);
 }
 
 static void part_handler(irconn_t *ircc, const char *channel, void *dummy)
 {
        php_irconn_t *conn = dummy;
-       static smart_str m;
+       smart_str m = {0};
 
-       m.len = 0;
        format_msg(MSG(conn, FMT_MSG_SELF_PART), channel, NULL, conn->conn.username, 
"", &m);
        msg_send(conn, &m);
 }
@@ -498,7 +479,6 @@
 
        format_msg(MSG(conn, FMT_MSG_LEAVE), channel, NULL, user->c, "", &m);
        msg_send(conn, &m);
-       smart_str_free_ex(&m, 1);
 }
 
 static void user_quit(irconn_t *ircc, smart_str *user, smart_str *msg, void *dummy)
@@ -508,7 +488,6 @@
 
        format_msg(MSG(conn, FMT_MSG_QUIT), NULL, NULL, user->c, msg->c, &m);
        msg_send(conn, &m);
-       smart_str_free_ex(&m, 1);
 }
 
 static void user_kick(irconn_t *ircc, const char *channel, smart_str *who, smart_str 
*kicked_by, smart_str *reason, void *dummy)
@@ -518,7 +497,6 @@
 
        format_msg(MSG(conn, FMT_MSG_KICK), channel, who->c, kicked_by->c, 
reason?reason->c:"", &m);
        msg_send(conn, &m);
-       smart_str_free_ex(&m, 1);
 }
 
 static void http_closed_connection(int fd)
@@ -884,7 +862,7 @@
        irconn_id++;
        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), buffer_dtor, 1);
+       zend_llist_init(&conn->buffer, sizeof(smart_str), NULL, 1);
 
        RETVAL_LONG(irconn_id);
 }
@@ -967,7 +945,6 @@
        }
 
        msg_send(conn, &m);
-       smart_str_free_ex(&m, 1);
 
        RETURN_TRUE;
 }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to