Exemplo n.º 1
0
void
rb_audioscrobbler_account_authenticate (RBAudioscrobblerAccount *account)
{
    /* begin the web services authentication process */
    if (account->priv->login_status != RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_LOGGED_OUT) {
        rb_debug ("logging out before starting auth process");
        rb_audioscrobbler_account_logout (account);
    }

    /* request an authentication token */
    request_token (account);
}
Exemplo n.º 2
0
Arquivo: cmd.c Projeto: gdahlm/sanlock
static void cmd_request(struct task *task, struct cmd_args *ca)
{
	struct token *token;
	struct sanlk_resource res;
	uint64_t owner_id;
	uint32_t force_mode;
	int token_len, disks_len;
	int j, fd, rv, error, result;

	fd = client[ca->ci_in].fd;

	force_mode = ca->header.data;

	/* receiving and setting up token copied from cmd_acquire */

	rv = recv(fd, &res, sizeof(struct sanlk_resource), MSG_WAITALL);
	if (rv != sizeof(struct sanlk_resource)) {
		log_error("cmd_request %d,%d recv %d %d",
			   ca->ci_in, fd, rv, errno);
		result = -ENOTCONN;
		goto reply;
	}

	if (!res.num_disks || res.num_disks > SANLK_MAX_DISKS) {
		result = -ERANGE;
		goto reply;
	}

	disks_len = res.num_disks * sizeof(struct sync_disk);
	token_len = sizeof(struct token) + disks_len;

	token = malloc(token_len);
	if (!token) {
		result = -ENOMEM;
		goto reply;
	}

	memset(token, 0, token_len);
	token->disks = (struct sync_disk *)&token->r.disks[0]; /* shorthand */
	token->r.num_disks = res.num_disks;
	memcpy(token->r.lockspace_name, res.lockspace_name, SANLK_NAME_LEN);
	memcpy(token->r.name, res.name, SANLK_NAME_LEN);

	token->acquire_lver = res.lver;
	token->acquire_data64 = res.data64;
	token->acquire_data32 = res.data32;
	token->acquire_flags = res.flags;

	/*
	 * receive sanlk_disk's / sync_disk's
	 *
	 * WARNING: as a shortcut, this requires that sync_disk and
	 * sanlk_disk match; this is the reason for the pad fields
	 * in sanlk_disk (TODO: let these differ?)
	 */

	rv = recv(fd, token->disks, disks_len, MSG_WAITALL);
	if (rv != disks_len) {
		result = -ENOTCONN;
		goto reply_free;
	}

	/* zero out pad1 and pad2, see WARNING above */
	for (j = 0; j < token->r.num_disks; j++) {
		token->disks[j].sector_size = 0;
		token->disks[j].fd = -1;
	}

	log_debug("cmd_request %d,%d force_mode %u %.48s:%.48s:%.256s:%llu",
		  ca->ci_in, fd, force_mode,
		  token->r.lockspace_name,
		  token->r.name,
		  token->disks[0].path,
		  (unsigned long long)token->r.disks[0].offset);

	error = request_token(task, token, force_mode, &owner_id);
	if (error < 0) {
		result = error;
		goto reply_free;
	}

	result = 0;

	if (!token->acquire_lver && !force_mode)
		goto reply_free;

	if (owner_id)
		host_status_set_bit(token->r.lockspace_name, owner_id);
 reply_free:
	free(token);
 reply:
	log_debug("cmd_request %d,%d done %d", ca->ci_in, fd, result);

	send_result(fd, &ca->header, result);
	client_resume(ca->ci_in);
}