Exemple #1
0
static size_t serial_gotdata(
    struct handle *h, const void *data, size_t len, int err)
{
    Serial *serial = (Serial *)handle_get_privdata(h);
    if (err || len == 0) {
	const char *error_msg;

	/*
	 * Currently, len==0 should never happen because we're
	 * ignoring EOFs. However, it seems not totally impossible
	 * that this same back end might be usable to talk to named
	 * pipes or some other non-serial device, in which case EOF
	 * may become meaningful here.
	 */
        if (!err)
	    error_msg = "End of file reading from serial device";
	else
	    error_msg = "Error reading from serial device";

	serial_terminate(serial);

	seat_notify_remote_exit(serial->seat);

        logevent(serial->logctx, error_msg);

	seat_connection_fatal(serial->seat, "%s", error_msg);

	return 0;
    } else {
	return seat_stdout(serial->seat, data, len);
    }
}
Exemple #2
0
static int handle_gotdata(struct handle *h, void *data, int len)
{
    Handle_Socket ps = (Handle_Socket) handle_get_privdata(h);

    if (len < 0) {
	return plug_closing(ps->plug, "Read error from handle",
			    0, 0);
    } else if (len == 0) {
	return plug_closing(ps->plug, NULL, 0, 0);
    } else {
        assert(ps->frozen != FREEZING && ps->frozen != THAWING);
        if (ps->frozen == FREEZING) {
            /*
             * If we've received data while this socket is supposed to
             * be frozen (because the read winhandl.c started before
             * sk_set_frozen was called has now returned) then buffer
             * the data for when we unfreeze.
             */
            bufchain_add(&ps->inputdata, data, len);

            /*
             * And return a very large backlog, to prevent further
             * data arriving from winhandl until we unfreeze.
             */
            return INT_MAX;
        } else {
            return plug_receive(ps->plug, 0, data, len);
        }
    }
}
Exemple #3
0
static int serial_gotdata(struct handle *h, void *data, int len)
{
    Serial serial = (Serial)handle_get_privdata(h);
    if (len <= 0) {
	const char *error_msg;

	/*
	 * Currently, len==0 should never happen because we're
	 * ignoring EOFs. However, it seems not totally impossible
	 * that this same back end might be usable to talk to named
	 * pipes or some other non-serial device, in which case EOF
	 * may become meaningful here.
	 */
	if (len == 0)
	    error_msg = "End of file reading from serial device";
	else
	    error_msg = "Error reading from serial device";

	serial_terminate(serial);

	notify_remote_exit(serial->frontend);

	logevent(serial->frontend, error_msg);

	connection_fatal(serial->frontend, "%s", error_msg);

	return 0;		       /* placate optimiser */
    } else {
	return from_backend(serial->frontend, 0, data, len);
    }
}
Exemple #4
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;
}
Exemple #5
0
int localproxy_gotdata(struct handle *h, void *data, int len) {
	Local_Proxy_Socket ps = (Local_Proxy_Socket) handle_get_privdata(h);

	if (len < 0) {
		return plug_closing(ps->plug, "Read error from local proxy command", 0,
				0);
	} else if (len == 0) {
		return plug_closing(ps->plug, NULL, 0, 0);
	} else {
		return plug_receive(ps->plug, 1, data, len);
	}
}
Exemple #6
0
static void handle_sentdata(struct handle *h, int new_backlog)
{
    Handle_Socket ps = (Handle_Socket) handle_get_privdata(h);

    if (new_backlog < 0) {
        /* Special case: this is actually reporting an error writing
         * to the underlying handle, and our input value is the error
         * code itself, negated. */
        plug_closing(ps->plug, win_strerror(-new_backlog), -new_backlog, 0);
        return;
    }

    plug_sent(ps->plug, new_backlog);
}
Exemple #7
0
static void serial_sentdata(struct handle *h, size_t new_backlog, int err)
{
    Serial *serial = (Serial *)handle_get_privdata(h);
    if (err) {
	const char *error_msg = "Error writing to serial device";

	serial_terminate(serial);

	seat_notify_remote_exit(serial->seat);

        logevent(serial->logctx, error_msg);

	seat_connection_fatal(serial->seat, "%s", error_msg);
    } else {
	serial->bufsize = new_backlog;
    }
}
Exemple #8
0
static void serial_sentdata(struct handle *h, int new_backlog)
{
    Serial serial = (Serial)handle_get_privdata(h);
    if (new_backlog < 0) {
	const char *error_msg = "Error writing to serial device";

	serial_terminate(serial);

	notify_remote_exit(serial->frontend);

	logevent(serial->frontend, error_msg);

	connection_fatal(serial->frontend, "%s", error_msg);
    } else {
	serial->bufsize = new_backlog;
    }
}
Exemple #9
0
void localproxy_sentdata(struct handle *h, int new_backlog)
{
    Local_Proxy_Socket ps = (Local_Proxy_Socket) handle_get_privdata(h);
    
    plug_sent(ps->plug, new_backlog);
}
Exemple #10
0
static void handle_sentdata(struct handle *h, int new_backlog)
{
    Handle_Socket ps = (Handle_Socket) handle_get_privdata(h);
    
    plug_sent(ps->plug, new_backlog);
}