コード例 #1
0
ファイル: refs.c プロジェクト: 136357477/git
int ref_transaction_update(struct ref_transaction *transaction,
			   const char *refname,
			   const unsigned char *new_sha1,
			   const unsigned char *old_sha1,
			   unsigned int flags, const char *msg,
			   struct strbuf *err)
{
	struct ref_update *update;

	assert(err);

	if (transaction->state != REF_TRANSACTION_OPEN)
		die("BUG: update called for transaction that is not open");

	if (new_sha1 && !is_null_sha1(new_sha1) &&
	    check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
		strbuf_addf(err, "refusing to update ref with bad name %s",
			    refname);
		return -1;
	}

	update = add_update(transaction, refname);
	if (new_sha1) {
		hashcpy(update->new_sha1, new_sha1);
		flags |= REF_HAVE_NEW;
	}
	if (old_sha1) {
		hashcpy(update->old_sha1, old_sha1);
		flags |= REF_HAVE_OLD;
	}
	update->flags = flags;
	if (msg)
		update->msg = xstrdup(msg);
	return 0;
}
コード例 #2
0
ファイル: db.cpp プロジェクト: kiransj/todo
bool SqlDB::change_state(const char *pr_number, PrState new_state)
{
    PrInfo pr;
    PrState old_state;
    bool flag = false;
    char query_state_change[512];   
    snprintf(query_state_change, 512, "UPDATE TODOLIST SET PR_STATE=%d WHERE PR_NUMBER='%s';", new_state, pr_number);        
    if(status == false)
    {
        snprintf(last_error_msg, 1024, "First open the database before any query");
        return false;
    }
    
    if(get_pr(pr_number, &pr) == false)
    {
        snprintf(last_error_msg, 1024, "Pr '%s' does not exists", pr_number);
        return false;
    }

    old_state = pr.pr_state;
    if(old_state == new_state)
    {
        snprintf(last_error_msg, 1024, "new and old state are the same");
        return false;   
    }       

    flag = execute_stmt(query_state_change);
    if(flag == true)
    {
        char msg[1024];
        snprintf(msg, 1024, "change state from %s to %s", PrState_string[old_state], PrState_string[new_state]);
        flag = add_update(pr_number, msg);
    }
    return flag;
}
コード例 #3
0
ファイル: local_sa.c プロジェクト: edgar-pek/PerspicuOS
static void refresh_port_db(struct sa_db_port *port)
{
	if (port->state == SA_DB_DESTROY)
		return;

	if (port->state == SA_DB_REFRESH) {
		clean_update_list(port);
		ib_cancel_mad(port->agent, port->msg);
	}

	add_update(port, NULL, SA_UPDATE_FULL);
}
コード例 #4
0
ファイル: local_sa.c プロジェクト: edgar-pek/PerspicuOS
static int notice_handler(int status, struct ib_inform_info *info,
			  struct ib_sa_notice *notice)
{
	struct sa_db_port *port = info->context;
	struct ib_sa_notice_data_gid *gid_data;
	struct ib_inform_info **pinfo;
	enum sa_update_type type;

	if (info->trap_number == IB_SA_SM_TRAP_GID_IN_SERVICE) {
		pinfo = &port->in_info;
		type = SA_UPDATE_ADD;
	} else {
		pinfo = &port->out_info;
		type = SA_UPDATE_REMOVE;
	}

	mutex_lock(&lock);
	if (port->state == SA_DB_DESTROY || !*pinfo) {
		mutex_unlock(&lock);
		return 0;
	}

	if (notice) {
		gid_data = (struct ib_sa_notice_data_gid *)
			   &notice->data_details;
		add_update(port, gid_data->gid, type);
		mutex_unlock(&lock);
	} else if (status == -ENETRESET) {
		*pinfo = NULL;
		mutex_unlock(&lock);
	} else {
		if (status)
			*pinfo = ERR_PTR(-EINVAL);
		port->state = SA_DB_IDLE;
		clean_update_list(port);
		mutex_unlock(&lock);
		queue_work(sa_wq, &port->work);
	}

	return status;
}