Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/proxy.c

    r242f280 rdbca297  
    8787}
    8888
    89 /* calls phb->func safely by ensuring that the phb struct doesn't exist in the
    90  * case that proxy_disconnect() is called down there */
    91 static gboolean phb_connected(struct PHB *phb, gint source)
    92 {
    93         /* save func and data here */
    94         b_event_handler func = phb->func;
    95         gpointer data = phb->data;
    96 
    97         /* free the struct so that it can't be freed by the callback */
    98         phb_free(phb, TRUE);
    99 
    100         /* if any proxy_disconnect() call happens here, it will use the
    101          * fd (still open), look it up in the hash table, get NULL, and
    102          * proceed to close the fd and do nothing else */
    103         func(data, source, B_EV_IO_READ);
    104 
    105         return FALSE;
    106 }
    107 
    10889static gboolean proxy_connected(gpointer data, gint source, b_input_condition cond)
    10990{
     
    144125                phb->proxy_func(phb->proxy_data, source, B_EV_IO_READ);
    145126        } else {
    146                 phb_connected(phb, source);
     127                phb->func(phb->data, source, B_EV_IO_READ);
     128                phb_free(phb, TRUE);
    147129        }
    148130
     
    240222        if ((memcmp(HTTP_GOODSTRING, inputline, strlen(HTTP_GOODSTRING)) == 0) ||
    241223            (memcmp(HTTP_GOODSTRING2, inputline, strlen(HTTP_GOODSTRING2)) == 0)) {
    242                 return phb_connected(phb, source);
     224                phb->func(phb->data, source, B_EV_IO_READ);
     225                return phb_free(phb, TRUE);
    243226        }
    244227
     
    312295        memset(packet, 0, sizeof(packet));
    313296        if (read(source, packet, 9) >= 4 && packet[1] == 90) {
    314                 return phb_connected(phb, source);
     297                phb->func(phb->data, source, B_EV_IO_READ);
     298                return phb_free(phb, TRUE);
    315299        }
    316300
     
    400384        }
    401385
    402         return phb_connected(phb, source);
     386        phb->func(phb->data, source, B_EV_IO_READ);
     387        return phb_free(phb, TRUE);
    403388}
    404389
Note: See TracChangeset for help on using the changeset viewer.