Exemplo n.º 1
0
static void localproxy_select_result(int fd, int event)
{
    Local_Proxy_Socket s;
    char buf[20480];
    int ret;

    if (!(s = find234(localproxy_by_fromfd, &fd, localproxy_fromfd_find)) &&
	!(s = find234(localproxy_by_fromfd, &fd, localproxy_errfd_find)) &&
	!(s = find234(localproxy_by_tofd, &fd, localproxy_tofd_find)) )
	return;		       /* boggle */

    if (event == 1) {
        if (fd == s->cmd_err) {
            ret = read(fd, buf, sizeof(buf));
            if (ret > 0)
                log_proxy_stderr(s->plug, &s->pending_error_data, buf, ret);
        } else {
            assert(fd == s->from_cmd);
            ret = read(fd, buf, sizeof(buf));
            if (ret < 0) {
                plug_closing(s->plug, strerror(errno), errno, 0);
            } else if (ret == 0) {
                plug_closing(s->plug, NULL, 0, 0);
            } else {
                plug_receive(s->plug, 0, buf, ret);
            }
        }
    } else if (event == 2) {
	assert(fd == s->to_cmd);
	if (localproxy_try_send(s))
	    plug_sent(s->plug, bufchain_size(&s->pending_output_data));
    }
}
Exemplo n.º 2
0
static int handle_stderr(struct handle *h, void *data, int len)
{
    Handle_Socket ps = (Handle_Socket) handle_get_privdata(h);

    if (len > 0)
        log_proxy_stderr(ps->plug, &ps->stderrdata, data, len);

    return 0;
}