コード例 #1
0
ファイル: load_balancer.c プロジェクト: lemenkov/opensips
int lb_update_from_replication( unsigned int group, str *uri,
														unsigned int flags)
{
	struct lb_dst *dst;

	lock_start_read( ref_lock );

	for( dst=(*curr_data)->dsts; dst; dst=dst->next ) {
		if ( (dst->group == group) &&
		(strncmp(dst->uri.s, uri->s, dst->uri.len) == 0)) {
			if ((dst->flags&LB_DST_STAT_MASK) != flags) {
				/* import the status flags */
				dst->flags = ((~LB_DST_STAT_MASK)&dst->flags)|
					(LB_DST_STAT_MASK&flags);
				/* raise event of status change */
				lb_raise_event(dst);
				lock_stop_read( ref_lock );
				return 0;
			}
		}
	}

	lock_stop_read( ref_lock );

	return -1;
}
コード例 #2
0
ファイル: lb_data.c プロジェクト: Danfx/opensips
int do_lb_disable_dst(struct sip_msg *req, struct lb_data *data, unsigned int verbose)
{
	struct usr_avp *id_avp;
	int_str id_val;

	struct lb_dst *dst;
	int old_flags;

	id_avp = search_first_avp( 0, id_avp_name, &id_val, NULL);
	if( id_avp && (is_avp_str_val(id_avp) == 0) ) {
		for( dst=data->dsts ; dst ; dst=dst->next ) {
			if( dst->id == id_val.n ) {
				old_flags = dst->flags;
				dst->flags |= LB_DST_STAT_DSBL_FLAG;

				if( dst->flags != old_flags ) {
					lb_raise_event(dst);
					if( verbose )
						LM_INFO("manually disable destination %d <%.*s> "
							"from script\n",dst->id, dst->uri.len, dst->uri.s);
				}
				return 0;
			}
		}
	} else
		LM_DBG("no AVP ID -> nothing to disable\n");

	return -1;
}
コード例 #3
0
ファイル: lb_replication.c プロジェクト: NormB/opensips
int replicate_lb_status_update(bin_packet_t *packet, struct lb_data *data)
{
	struct lb_dst *dst;
	unsigned int group, flags;
	str uri;
	bin_pop_int(packet, &group);
	bin_pop_str(packet, &uri);
	bin_pop_int(packet, &flags);

	for( dst=data->dsts; dst; dst=dst->next ) {
		if ( (dst->group == group) &&
		(strncmp(dst->uri.s, uri.s, dst->uri.len) == 0)) {
			if ((dst->flags&LB_DST_STAT_MASK) != flags) {
				/* import the status flags */
				dst->flags = ((~LB_DST_STAT_MASK)&dst->flags)|
					(LB_DST_STAT_MASK&flags);
				/* raise event of status change */
				lb_raise_event(dst);
				return 0;
			}
		}
	}

	return -1;
}