sas             Wed Jan 10 05:50:26 2001 EDT

  Modified files:              
    /php4/ext/ircg      ircg.c 
  Log:
  Remove unused channel element from the php_irconn structure.
  
  Remove unnecessary check when freeing custom format messages.
  
  Improve handling, if send(2) fails.
  
  
Index: php4/ext/ircg/ircg.c
diff -u php4/ext/ircg/ircg.c:1.10 php4/ext/ircg/ircg.c:1.11
--- php4/ext/ircg/ircg.c:1.10   Tue Jan  9 00:00:23 2001
+++ php4/ext/ircg/ircg.c        Wed Jan 10 05:50:25 2001
@@ -65,7 +65,6 @@
 typedef struct {
        irconn_t conn;
        const char *username;
-       const char *channel;
        zend_llist buffer;
        int fd;
        int irconn_id;
@@ -89,7 +88,7 @@
 
 php_irconn_t *lookup_irconn(int id)
 {
-       php_irconn_t **ret = NULL;
+       php_irconn_t **ret;
 
        if (zend_hash_index_find(&h_irconn, id, (void **) &ret) == FAILURE)
                return NULL;
@@ -109,17 +108,19 @@
 
        smart_str_free_ex(msg, 1);
 }
+
 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);
+       conn->fd = -2;
        zend_hash_index_del(&h_irconn, conn->irconn_id);
        
        for (i = 0; i < NO_FMTS; i++) {
-               if (conn->fmt_msgs[i] && conn->fmt_msgs[i] != fmt_msgs_default[i]) 
free(conn->fmt_msgs[i]);
+               if (conn->fmt_msgs[i]) free(conn->fmt_msgs[i]);
        }
        free((char *) conn->username);
 
@@ -282,11 +283,21 @@
 {
        zend_llist_clean(&conn->buffer);
 }
+                       
+static void http_closed_connection(int fd);
 
 static void msg_send(php_irconn_t *conn, smart_str *msg)
 {
        if (conn->fd != -1) {
-               send(conn->fd, msg->c, msg->len, 0);
+               int n;
+
+               n = send(conn->fd, msg->c, msg->len, 0);
+
+               if ((n == -1 && errno == EPIPE) || n == 0) { 
+                       http_closed_connection(conn->fd);
+               }
+       } else if (conn->fd == -2) {
+               /* do nothing */
        } else {
                smart_str msg2 = {0};
 
@@ -519,7 +530,6 @@
         */
        conn = malloc(sizeof(*conn));
        conn->username = strdup(username);
-       conn->channel = NULL,
        conn->fd = -1;
        if (p4) {
                HashTable *h;



-- 
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