示例#1
0
static void on_ssh_read(__unused evutil_socket_t fd, __unused short what, void *arg)
{
	struct tmate_ssh_client *client = arg;
	ssh_execute_message_callbacks(client->session);

	if (!ssh_is_connected(client->session)) {
		tmate_warn("SSH Disconnected");

		event_del(&client->ev_ssh);

		/* For graceful tmux client termination */
		request_server_termination();
	}
}
示例#2
0
/**
 * @brief  Poll all the sockets and sessions associated through an event object.
 *         If any of the events are set after the poll, the
 *         call back functions of the sessions or sockets will be called.
 *         This function should be called once within the programs main loop.
 *
 * @param  event        The ssh_event object to poll.
 * @param  timeout      An upper limit on the time for which the poll will
 *                      block, in milliseconds. Specifying a negative value
 *                      means an infinite timeout. This parameter is passed to
 *                      the poll() function.
 * @returns SSH_OK      No error.
 *          SSH_ERROR   Error happened during the poll.
 */
int ssh_event_dopoll(ssh_event event, int timeout) {
    int rc;
#ifdef WITH_SERVER
    ssh_session session;
    struct ssh_iterator *iterator;
#endif

    if(event == NULL || event->ctx == NULL) {
        return SSH_ERROR;
    }
    rc = ssh_poll_ctx_dopoll(event->ctx, timeout);
#ifdef WITH_SERVER
    if(rc == SSH_OK) {
        iterator = ssh_list_get_iterator(event->sessions);
        while(iterator != NULL) {
            session = (ssh_session)iterator->data;
            ssh_execute_message_callbacks(session);
            iterator = iterator->next;
        }
    }
#endif
    return rc;
}