本文整理汇总了C++中set_state函数的典型用法代码示例。如果您正苦于以下问题:C++ set_state函数的具体用法?C++ set_state怎么用?C++ set_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_state函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: discover_task
static void discover_task ()
{
uint8_t periods_in_idle = discover_period_s / DISCOVER_TASK_PERIOD_S;
nrk_time_t now, elapsed;
int8_t rc;
while (1) {
switch (discover_state) {
case DISCOVER_IDLE:
if (auto_discover) {
if (periods_in_idle < periods_in_idle)
break;
set_state(DISCOVER_SCHEDULED);
}
break;
case DISCOVER_SCHEDULED:
#if ENABLE_LED
pulse_led(led_discover);
#endif
set_state(DISCOVER_PENDING);
nrk_event_signal(discover_signal);
break;
case DISCOVER_IN_PROGRESS:
nrk_time_get(&now);
nrk_time_sub(&elapsed, now, last_activity);
if (time_cmp(&elapsed, &discover_time_out) < 0) {
LOG("silent for ");
LOGP("%lu ms\r\n", TIME_TO_MS(elapsed));
break;
}
LOG("finished, distrib routes: seq ");
LOGP("%d\r\n", outstanding_seq);
print_graph(&network);
rc = calc_routes(&network, &routes);
if (rc == NRK_OK) {
print_routes(&routes);
rc = broadcast_routes(&routes, outstanding_seq);
if (rc != NRK_OK)
LOG("WARN: failed to bcast routes\r\n");
} else {
LOG("WARN: failed to calc routes\r\n");
}
set_state(DISCOVER_COMPLETED);
nrk_event_signal(discover_signal);
break;
case DISCOVER_PENDING:
case DISCOVER_COMPLETED:
/* the router failed to do its part in one task period */
set_state(DISCOVER_IDLE);
break;
default:
ABORT("unexpected state\r\n");
}
periods_in_state++;
nrk_wait_until_next_period();
}
ABORT("discover task exited\r\n");
}
示例2: pa__init
int pa__init(pa_module*m) {
struct userdata *u;
pa_modargs *ma;
pa_sink_new_data data;
int backend_state;
int ret;
char strbuf[100];
pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments.");
goto fail;
}
ss = m->core->default_sample_spec;
map = m->core->default_channel_map;
/* user arguments override these */
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_DEFAULT) < 0) {
pa_log("Invalid sample format specification or channel map");
return 1;
}
/* Xen Basic init */
xsh = xs_domain_open();
if (xsh==NULL) {
pa_log("xs_domain_open failed");
goto fail;
}
set_state(XenbusStateUnknown);
xch = xc_interface_open(NULL, NULL, 0);
if (xch==0) {
pa_log("xc_interface_open failed");
goto fail;
}
xce = xc_evtchn_open(NULL, 0);
if (xce==0) {
pa_log("xc_evtchn_open failed");
goto fail;
}
/* use only dom0 as the backend for now */
xen_evtchn_port = xc_evtchn_bind_unbound_port(xce, 0);
if (xen_evtchn_port == 0) {
pa_log("xc_evtchn_bind_unbound_port failed");
}
/* get grant reference & map locally */
if (alloc_gref(&gref, (void**)&ioring)) {
pa_log("alloc_gref failed");
};
device_id = 0; /* hardcoded for now */
if (register_backend_state_watch()) {
pa_log("Xen sink: register xenstore watch failed");
};
publish_param_int("event-channel", xen_evtchn_port);
publish_param_int("ring-ref", gref.gref_ids[0]);
/* let's ask for something absurd and deal with rejection */
ss.rate = 192000;
publish_spec(&ss);
ret=0;
while (!ret) {
backend_state = wait_for_backend_state_change();
if (backend_state == STATE_UNDEFINED) {
pa_log("Xen Backend is taking long to respond, still waiting...");
continue;
} else if (backend_state == -1) {
pa_log("Error while waiting for backend: %s", strerror(errno));
break;
goto fail;
}
ret = state_callbacks[backend_state]();
}
if (ret!=NEGOTIATION_OK) {
pa_log("Negotiation with Xen backend failed!");
return 1;
}
pa_sample_spec_snprint(strbuf, 100, &ss);
pa_log_debug("Negotiation ended, the result was: %s", strbuf);
/* End of Phase 2, begin playback cycle */
u = pa_xnew0(struct userdata, 1);
u->core = m->core;
u->module = m;
m->userdata = u;
pa_memchunk_reset(&u->memchunk);
u->rtpoll = pa_rtpoll_new();
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
u->write_type = 0;
//.........这里部分代码省略.........
示例3: main
/*
* MAIN
*
* assumes the existance of getopt() to clean up the command
* line handling
*/
int
main (int ac, char **av)
{
DSS_HUGE i;
table = (1 << CUST) |
(1 << SUPP) |
(1 << NATION) |
(1 << REGION) |
(1 << PART_PSUPP) |
(1 << ORDER_LINE);
force = 0;
insert_segments=0;
delete_segments=0;
insert_orders_segment=0;
insert_lineitem_segment=0;
delete_segment=0;
verbose = 0;
set_seeds = 0;
scale = 1;
flt_scale = 1.0;
updates = 0;
step = -1;
partition = -1;
tdefs[ORDER].base *=
ORDERS_PER_CUST; /* have to do this after init */
tdefs[LINE].base *=
ORDERS_PER_CUST; /* have to do this after init */
tdefs[ORDER_LINE].base *=
ORDERS_PER_CUST; /* have to do this after init */
children = 1;
d_path = NULL;
#ifdef NO_SUPPORT
signal (SIGINT, exit);
#endif /* NO_SUPPORT */
process_options (ac, av);
validate_options();
#if (defined(WIN32)&&!defined(_POSIX_))
for (i = 0; i < ac; i++)
{
spawn_args[i] = malloc (((int)strlen (av[i]) + 1) * sizeof (char));
MALLOC_CHECK (spawn_args[i]);
strcpy (spawn_args[i], av[i]);
}
spawn_args[ac] = NULL;
#endif
if (verbose >= 0)
{
fprintf (stderr,
"%s Population Generator (Version %d.%d.%d)\n",
NAME, VERSION, RELEASE, PATCH);
fprintf (stderr, "Copyright %s %s\n", TPC, C_DATES);
}
load_dists ();
#ifdef RNG_TEST
for (i=0; i <= MAX_STREAM; i++)
Seed[i].nCalls = 0;
#endif
/* have to do this after init */
tdefs[NATION].base = nations.count;
tdefs[REGION].base = regions.count;
/*
* updates are never parallelized
*/
if (updates)
{
/*
* set RNG to start generating rows beyond SF=scale
*/
set_state (ORDER, scale, 100, 101, &i);
rowcnt = (int)(tdefs[ORDER_LINE].base / 10000 * scale * UPD_PCT);
if (step > 0)
{
/*
* adjust RNG for any prior update generation
*/
for (i=1; i < step; i++)
{
sd_order(0, rowcnt);
sd_line(0, rowcnt);
}
upd_num = step - 1;
}
else
upd_num = 0;
while (upd_num < updates)
{
if (verbose > 0)
fprintf (stderr,
//.........这里部分代码省略.........
示例4: state_unknown_cb
/* negotiation callbacks */
static int state_unknown_cb() {
pa_log_debug("Xen audio sink: Backend state was XenbusStateUnknown\n");
set_state(XenbusStateInitialising);
return 0;
}
示例5: state_initialised_cb
static int state_initialised_cb() {
pa_log_debug("Xen audio sink: Backend state was XenbusStateInitialised\n");
/*Remind the backend we are ready*/
set_state(XenbusStateInitialised);
return 0;
}
示例6: kcs_bmc_handle_data
static void kcs_bmc_handle_data(struct kcs_bmc *kcs_bmc)
{
u8 data;
switch (kcs_bmc->phase) {
case KCS_PHASE_WRITE_START:
kcs_bmc->phase = KCS_PHASE_WRITE_DATA;
/* fall through */
case KCS_PHASE_WRITE_DATA:
if (kcs_bmc->data_in_idx < KCS_MSG_BUFSIZ) {
set_state(kcs_bmc, WRITE_STATE);
write_data(kcs_bmc, KCS_ZERO_DATA);
kcs_bmc->data_in[kcs_bmc->data_in_idx++] =
read_data(kcs_bmc);
} else {
kcs_force_abort(kcs_bmc);
kcs_bmc->error = KCS_LENGTH_ERROR;
}
break;
case KCS_PHASE_WRITE_END_CMD:
if (kcs_bmc->data_in_idx < KCS_MSG_BUFSIZ) {
set_state(kcs_bmc, READ_STATE);
kcs_bmc->data_in[kcs_bmc->data_in_idx++] =
read_data(kcs_bmc);
kcs_bmc->phase = KCS_PHASE_WRITE_DONE;
kcs_bmc->data_in_avail = true;
wake_up_interruptible(&kcs_bmc->queue);
} else {
kcs_force_abort(kcs_bmc);
kcs_bmc->error = KCS_LENGTH_ERROR;
}
break;
case KCS_PHASE_READ:
if (kcs_bmc->data_out_idx == kcs_bmc->data_out_len)
set_state(kcs_bmc, IDLE_STATE);
data = read_data(kcs_bmc);
if (data != KCS_CMD_READ_BYTE) {
set_state(kcs_bmc, ERROR_STATE);
write_data(kcs_bmc, KCS_ZERO_DATA);
break;
}
if (kcs_bmc->data_out_idx == kcs_bmc->data_out_len) {
write_data(kcs_bmc, KCS_ZERO_DATA);
kcs_bmc->phase = KCS_PHASE_IDLE;
break;
}
write_data(kcs_bmc,
kcs_bmc->data_out[kcs_bmc->data_out_idx++]);
break;
case KCS_PHASE_ABORT_ERROR1:
set_state(kcs_bmc, READ_STATE);
read_data(kcs_bmc);
write_data(kcs_bmc, kcs_bmc->error);
kcs_bmc->phase = KCS_PHASE_ABORT_ERROR2;
break;
case KCS_PHASE_ABORT_ERROR2:
set_state(kcs_bmc, IDLE_STATE);
read_data(kcs_bmc);
write_data(kcs_bmc, KCS_ZERO_DATA);
kcs_bmc->phase = KCS_PHASE_IDLE;
break;
default:
kcs_force_abort(kcs_bmc);
break;
}
}
示例7: controller_run
void controller_run(void) {
//Declare variables
//Store sensors readings
uint8_t ir_frontleft, ir_frontright, ir_backleft, ir_backright, dis_front;
//Speeds to be managed by the control logic, without taking into account speed adaption
int speed_left = 0, speed_right = 0;
//Speeds applied to the motors after adaptive speed calculation
uint16_t speed_l, speed_r;
//Speed offset, to make sure initially heading slightly to the right and finally slightly to the left
int offset = 10;
//Directions of the wheels
char direction_left = 0, direction_right = 0;
//main loop
while(1) {
//Read sensor values
dis_front = sensor_read(SENSOR_FRONT, SENSOR_DISTANCE);
ir_frontleft = (sensor_read(SENSOR_FRONTLEFT, SENSOR_IR));
ir_frontright = (sensor_read(SENSOR_FRONTRIGHT, SENSOR_IR));
ir_backleft = sensor_read(SENSOR_BACKLEFT, SENSOR_IR);
ir_backright = sensor_read(SENSOR_BACKRIGHT, SENSOR_IR);
// Remove noise
if (ir_frontleft < NOISE_LEVEL)
ir_frontleft = 0;
if (ir_frontright < NOISE_LEVEL)
ir_frontright = 0;
if (ir_backleft < NOISE_LEVEL)
ir_backleft = 0;
if (ir_backright < NOISE_LEVEL)
ir_backright = 0;
switch (get_state())
{
case STATE_BRAITENBERG:
{
// State 0: Avoid obstacles
LED_OFF(LED_PLAY);
LED_OFF(LED_AUX);
if (ir_frontright < DISTANCE_TO_TURN) { //no obstacle close
direction_left = MOTOR_CCW; // Going forward
speed_left = 255; //At full speed
}
else { //close to an obstacle
direction_left = MOTOR_CW; //Going backwards
speed_left = ir_frontright; //speed proportional to obstacle distance (proximity)
}
// Going forward
if (ir_frontleft < DISTANCE_TO_TURN) { //same as above for the other wheel
direction_right = MOTOR_CW;
speed_right = 255;
}
else {
direction_right = MOTOR_CCW;
speed_right = ir_frontleft;
}
if (offset > 0) //apply speed offset to left/right wheel (before/after wall mode)
speed_right -= offset;
else
speed_left -= offset;
if (WALL_MODE) //If wall follow mode is activated
{
if(ir_backleft > 80) //If close to wall
{
set_state(STATE_FOLLOW); //Go to wall-follow state
}
}
break;
}
case STATE_FOLLOW: // State: Follow the left wall
{
LED_ON(LED_AUX);
if (ir_frontleft < 20)
{ //too far
speed_left = 255-40; //Head towards the wall
speed_right = 255;
}
else
{ //too close
speed_left = 255; //head away from the wall
speed_right = 255-40;
}
// Go forward
direction_left = MOTOR_CCW;
direction_right = MOTOR_CW;
if (ir_frontleft == 0) { //If arrived to the end of the wall
set_state(STATE_BRAITENBERG); //Return to Obstacle avoidance state
offset = -offset; //Invert speed offset (always head slightly to the left)
}
break;
}
default:
//.........这里部分代码省略.........
示例8: switch
bool densoecu::listen_denso02_bootloader()
{
unsigned char rsp;
unsigned int datalen = 1;
int checksum = 0;
dc->set_default_timeout(3000);
if (!dc->read_serial_bytes(&rsp,&datalen))
return false;
checksum += rsp;
int addr,len;
switch(rsp)
{
case denso02_bootloader_cmd_start:
l->print(log_densoecu,"denso02_bootloader_cmd_start\n");
datalen = 1;
if (!dc->read_serial_bytes(&rsp,&datalen))
return false;
checksum += rsp;
// verify checksum
datalen = 1;
if (!dc->read_serial_bytes(&rsp,&datalen))
return false;
if (rsp != 0x100-(checksum & 0xFF))
{
l->print(log_densoecu,"bad checksum.\n");
return false;
}
rxbuf[0] = 0x00;
if (state == bootloader_auth)
{
if (!dc->write_denso02_cmd(denso02_bootloader_cmd_start,rxbuf,1))
return false;
set_state(bootloader);
}
break;
case denso02_bootloader_cmd_write_kernel_ram:
// read address and length
datalen = 5;
if (!dc->read_serial_bytes(rxbuf,&datalen))
{
l->print(log_densoecu,"denso write kernel area timeout!");
return false;
}
checksum += dc->checksum(rxbuf,datalen);
addr = byte_to_int24(rxbuf);
len = byte_to_int16(rxbuf+3);
l->print(log_densoecu,"denso write kernel area addr:%06X len:%02X\n",addr,len);
if (addr < locrambase || addr+len > locrambase + 0x1800)
{
l->print(log_densoecu,"bad address range.\n");
rsp = denso02_bootloader_rsp_bad_address;
if (!dc->write_raw(&rsp,1))
return false;
}
/*
// todo: verify kernel length, return 0x22 if overrun
if (len > datalen - 5)
{
if (!dc->write_raw(densocomm::denso02_bootloader_rsp_data_overrun,1))
return false;
}
*/
// now read data block
datalen = len;
if (!dc->read_serial_bytes(rxbuf,&datalen))
return false;
checksum += dc->checksum(rxbuf,datalen);
// verify checksum
datalen = 1;
if (!dc->read_serial_bytes(&rsp,&datalen))
return false;
if (rsp != 0x100-(checksum & 0xFF))
{
l->print(log_densoecu,"bad checksum.\n");
// todo: send 0x03
rsp = denso02_bootloader_rsp_bad_checksum;
if (!dc->write_raw(&rsp,1))
return false;
return false;
}
transform_kernel_block02(rxbuf,len,0,false);
memcpy(rom+addr,rxbuf,len);
// verify valid kernel
if (byte_to_int16(rom+locrambase+2) != denso_magic_number)
{
// invalid_kernel magic number
l->print(log_densoecu,"invalid magic number.\n");
rsp = denso02_bootloader_rsp_bad_magic_number;
if (!dc->write_raw(&rsp,1))
return false;
}
l->print(log_densoecu,"valid kernel loaded.\n");
delay(100);
set_state(oecukernel);
break;
//.........这里部分代码省略.........
示例9: set_state
void densoecu::set_model(ecumodel _model)
{
model = _model;
set_state(normal);
}
示例10: ProcessQuery
//.........这里部分代码省略.........
//also reset the state
table_name_list.clear();
current_state = NONE;
previous_state = NONE;
}
//also push back this token
pushback_token_to_stream(&next_token, &index);
continue;
}
if (current_token == ")") {
//now time to pop back what we stored in stack
if (query_state_stack.empty()) {
continue;
}
if (query_state_stack.top().select_triggered_query_state_change
== true) {
/*
* if the state saved at stack was triggered by SELECT then only
* do a state save and pop
* pop and save state into current variables
*/
table_name_list = (query_state_stack.top().table_name_list);
current_state = (query_state_stack.top()).current_state;
previous_state = (query_state_stack.top()).previous_state;
//pop the top
query_state_stack.pop();
}
continue;
}
// see if this token triggers a state change
if (set_state(current_token, ¤t_state, &previous_state) == true) {
continue;
}
/*
* if a state reset needed because keyword SELECT/UNION has been
* encountered in the input stream, then perform a state reset. After
* resetting table_name_list toggle state_reset_needed flag.
*/
if (state_reset_needed) {
table_name_list.clear();
toggle_state_reset();
}
/*
* when being in a state, if a reserved token is encountered and
* if code at that position can not handle it then it must do
* a pushback followed a continue. We will handle reserved keywords
* or unhandled tokens here.
* Right now we are not handling most of the reserved tokens or operators
* in this block. so continue
*/
if (is_token_reserved(current_token)
or is_token_operator(current_token)) {
// deal with token
continue;
}
if (current_token == "," or current_token == ";") {
continue;
}
//process state SELECT
if (current_state == SELECT) {
示例11: handle_transport_layer_packet
/*
* *******************************************
* Function: handle_transport_layer_packet
*
* Description:
*
* handle a transport layer
* packet. Core transport layer handling
* function , all the other funcitons
* were written to support this big guy
*
* Parameters:
* buffer - packet buffer
* src_id - Source id
* dest_id - Destination id
*
* *******************************************
*/
void handle_transport_layer_packet( void * buffer , int src_id , int dest_id )
{
int packet_type;
int requested_mtu;
int seq_no;
int connect_id;
void *realloc_buffer;
int win_size ;
void *packet_data;
int cid_seq_no;
int current_sender_id;
int current_cid_state;
int sender_id ;
char *realloc_buf_ptr;
int max_connections_permitted = get_state(&__max_connections);
packet_type = get_packet_type(buffer);
switch(packet_type)
{
case CONTROL_CONNECT:
requested_mtu = get_requested_mtu(buffer);
connect_id =allocate_sender(max_connections_permitted);
sender_id = get_sender_id(buffer);
if ( connect_id < max_connections_permitted)
{
init_state(&__session_tab.cid_info[connect_id].curr_state);
set_state(&__session_tab.cid_info[connect_id].curr_state ,STATE_CONNECTED);
__session_tab.cid_info[connect_id].sequence_number = 0;
__session_tab.cid_info[connect_id].buf_len = 0;
send_connect_ack(src_id , requested_mtu , connect_id,sender_id);
}
else
{
fprintf(stderr ,"%s", "\n Connection not possilbe all slots full \n");
}
break;
case CONTROL_ACK:
seq_no = get_sequence_number(buffer);
current_sender_id = get_sender_id(buffer);
connect_id = get_cid(buffer);
sender_buffer[current_sender_id].seq_no = seq_no;
sender_buffer[current_sender_id].response_code = CONTROL_ACK;
sender_buffer[current_sender_id].connection_id = connect_id;
break;
case CONTROL_DATA:
{
fprintf(stderr,"DATA packet received ... ");
connect_id = get_cid(buffer);
seq_no = get_sequence_number(buffer);
sender_id = get_sender_id(buffer);
cid_seq_no = __session_tab.cid_info[connect_id].sequence_number;
current_cid_state = get_state(&__session_tab.cid_info[connect_id].curr_state);
fprintf(stderr,"\n seq no = %d cid seq no = %d window size = %d CID = %d" , seq_no , cid_seq_no , get_window_size(buffer) , connect_id);
/* are we getting the next sequnce number & we are connected */
if( ( seq_no == cid_seq_no + 1 ) )
{
win_size = get_window_size(buffer);
realloc_buffer = malloc(win_size + __session_tab.cid_info[connect_id].buf_len);
if ( __session_tab.cid_info[connect_id].buf_len > 0 && ( current_cid_state != STATE_CLOSE))
{
memcpy(realloc_buffer,__session_tab.cid_info[connect_id].data_buf,__session_tab.cid_info[connect_id].buf_len);
realloc_buf_ptr = (char *) realloc_buffer + __session_tab.cid_info[connect_id].buf_len ;
packet_data = (char *) buffer + TRASPORT_LAYER_SIZE ;
memcpy(realloc_buf_ptr,packet_data , win_size);
__session_tab.cid_info[connect_id].buf_len += win_size;
free( __session_tab.cid_info[connect_id].data_buf);
__session_tab.cid_info[connect_id].data_buf = realloc_buffer;
__session_tab.cid_info[connect_id].sequence_number++;
send_ack_request(src_id,seq_no,sender_id) ;
}
else
{
packet_data = (char *) buffer + TRASPORT_LAYER_SIZE ;
memcpy(realloc_buffer,packet_data , win_size);
//.........这里部分代码省略.........
示例12: process_alps_status
//.........这里部分代码省略.........
free_hash(rsv_ht);
free(current_node_id);
return(PBSE_NONE);
}
if ((current = find_node_in_allnodes(&parent->alps_subnodes, current_node_id)) == NULL)
{
/* current node disappeared, this shouldn't be possible either */
unlock_node(parent, __func__, NULL, LOGLEVEL);
snprintf(log_buf, sizeof(log_buf), "Current node '%s' disappeared while recording a reservation",
current_node_id);
log_err(PBSE_UNKNODE, __func__, log_buf);
free_arst(&temp);
free_all_keys(rsv_ht);
free_hash(rsv_ht);
free(current_node_id);
return(PBSE_NONE);
}
free(current_node_id);
current_node_id = NULL;
}
}
/* save this as is to the status strings */
else if ((rc = decode_arst(&temp, NULL, NULL, str, 0)) != PBSE_NONE)
{
free_arst(&temp);
free_all_keys(rsv_ht);
free_hash(rsv_ht);
return(rc);
}
/* perform any special processing */
if (!strncmp(str, ccu_eq, ac_ccu_eq_len))
{
/* save compute unit count in case we need it */
/* note: this string (ccu_eq (CCU=)) needs to be found before cprocs_eq (CPROCS=) */
/* for the node */
ccu_p = str;
}
else if (!strncmp(str, cproc_eq, ac_cproc_eq_len))
{
int ncpus;
long svr_nppcu_value = 0;
/*
* Get the server nppcu value which determines how Hyper-Threaded
* cores are reported. When server nppcu value is:
*
* 0 - Let ALPS choose whether or not to use Hyper-Threaded cores
* (report all cores)
* 1 - Do not use Hyper-Threaded cores
* (report only physical core (compute unit count)
* 2 - Use Hyper-Threaded cores
* (report all cores)
*/
get_svr_attr_l(SRV_ATR_nppcu, &svr_nppcu_value);
if (svr_nppcu_value == NPPCU_NO_USE_HT && ccu_p != NULL)
{
/* no HT (nppcu==1), so use compute unit count */
ncpus = atoi(ccu_p + ac_ccu_eq_len);
/* use CPROC value if we are using APBASIL protocol < 1.3 */
if (ncpus == 0)
ncpus = atoi(str + ac_cproc_eq_len);
/* reset the pointer */
ccu_p = NULL;
}
else
{
/* let ALPS choose (nppcu==0) or use HT (nppcu==2), use actual processor count */
ncpus = atoi(str + ac_cproc_eq_len);
}
set_ncpus(current, parent, ncpus);
}
else if (!strncmp(str, state, strlen(state)))
{
set_state(current, str);
}
} /* END processing the status update */
if (current != NULL)
{
snprintf(node_index_buf, sizeof(node_index_buf), "node_index=%d", node_index++);
decode_arst(&temp, NULL, NULL, node_index_buf, 0);
save_node_status(current, &temp);
unlock_node(current, __func__, NULL, LOGLEVEL);
}
unlock_node(parent, __func__, NULL, LOGLEVEL);
free_all_keys(rsv_ht);
free_hash(rsv_ht);
return(PBSE_NONE);
} /* END process_alps_status() */
示例13: main
int main(int argc, char *argv[])
{
struct tc_config tc[8];
int i, err = 0;
int newstate = -1;
int read_only = 0;
__u8 state;
__u8 pfc[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
__u8 bwg[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
__u8 mac[ETH_ALEN], san_mac[ETH_ALEN];
__u8 cap[DCB_CAP_ATTR_MAX+1];
__u8 numtcs;
bcn_cfg bcn_set_data, bcn_data;
#ifdef DCB_APP_DRV_IF_SUPPORTED
appgroup_attribs app_data = {DCB_APP_IDTYPE_ETHTYPE, 0x8906, 0x08};
#endif /* DCB_APP_DRV_IF_SUPPORTED */
int ifindex;
int optind = 1;
char *ifname;
printf("Calling RTNETLINK interface.\n");
if (argc < 2) {
fprintf(stderr, "usage: %s [-v] <ifname> [on|off|ro]\n",
argv[0]);
exit(1);
}
if (argc > 2) {
if (!strcmp(argv[1], "-v")) {
hexdump = 1;
optind++;
}
if (argc > optind + 1) {
if (!strcmp(argv[optind + 1], "on"))
newstate = 1;
if (!strcmp(argv[optind + 1], "off"))
newstate = 0;
if (!strcmp(argv[optind + 1], "ro"))
read_only = 1;
}
}
ifname = argv[optind];
ifindex = if_nametoindex(ifname);
if (ifindex == 0) {
printf("no ifindex for %s\n", ifname);
exit(1);
}
if ((nl_sd = init_socket()) < 0) {
fprintf(stderr, "error creating netlink socket\n");
return nl_sd;
}
#ifdef DO_GETLINK_QUERY
printf("DOING A GETLINK COMMAND\n");
nlh = start_msg(RTM_GETLINK, ifindex);
if (nlh == NULL)
exit(1);
if (send_msg(nlh))
exit(1);
free(nlh);
nlh = get_msg();
#endif
printf("GETTING DCB STATE\n");
err = get_state(ifname, &state);
if (err) {
fprintf(stderr, "Error getting DCB state\n");
goto err_main;
}
printf("DCB State = %d\n", state);
if (newstate >= 0) {
printf("\nSETTING DCB STATE TO: %d\n", newstate);
err = set_state(ifname, newstate);
if (err)
goto err_main;
err = get_state(ifname, &state);
if (err) {
fprintf(stderr, "Error getting DCB state\n");
goto err_main;
}
printf("New DCB State = %d\n", state);
}
printf("\nGETTING PFC CONFIGURATION\n");
for (i=0; i<8; i++)
pfc[i] = 0x0f;
get_pfc_cfg(ifname, pfc);
printf("PFC config:\n");
for (i=0; i<8; i++)
printf("%x ", pfc[i]);
printf("\n");
get_pfc_state(ifname, &state);
if (err) {
fprintf(stderr, "Error getting PFC status\n");
goto err_main;
}
//.........这里部分代码省略.........
示例14: lock
void RedChannel::run()
{
for (;;) {
Lock lock(_action_lock);
if (_action == WAIT_ACTION) {
_action_cond.wait(lock);
}
int action = _action;
_action = WAIT_ACTION;
lock.unlock();
switch (action) {
case CONNECT_ACTION:
try {
get_client().get_sync_info(get_type(), get_id(), _sync_info);
on_connecting();
set_state(CONNECTING_STATE);
ConnectionOptions con_options(_client.get_connection_options(get_type()),
_client.get_port(),
_client.get_sport(),
_client.get_protocol(),
_client.get_host_auth_options(),
_client.get_connection_ciphers());
RedChannelBase::connect(con_options, _client.get_connection_id(),
_client.get_host().c_str(),
_client.get_password().c_str());
/* If automatic protocol, remember the first connect protocol type */
if (_client.get_protocol() == 0) {
if (get_peer_major() == 1) {
_client.set_protocol(1);
} else {
/* Major is 2 or unstable high value, use 2 */
_client.set_protocol(2);
}
}
/* Initialize when we know the remote major version */
if (_client.get_peer_major() == 1) {
_marshallers = spice_message_marshallers_get1();
} else {
_marshallers = spice_message_marshallers_get();
}
on_connect();
set_state(CONNECTED_STATE);
_loop.add_socket(*this);
_socket_in_loop = true;
on_event();
_loop.run();
} catch (RedPeer::DisconnectedException&) {
_error = SPICEC_ERROR_CODE_SUCCESS;
} catch (Exception& e) {
LOG_WARN("%s", e.what());
_error = e.get_error_code();
} catch (std::exception& e) {
LOG_WARN("%s", e.what());
_error = SPICEC_ERROR_CODE_ERROR;
}
if (_socket_in_loop) {
_socket_in_loop = false;
_loop.remove_socket(*this);
}
if (_outgoing_message) {
_outgoing_message->release();
_outgoing_message = NULL;
}
_incomming_header_pos = 0;
if (_incomming_message) {
_incomming_message->unref();
_incomming_message = NULL;
}
case DISCONNECT_ACTION:
close();
on_disconnect();
set_state(DISCONNECTED_STATE);
_client.on_channel_disconnected(*this);
continue;
case QUIT_ACTION:
set_state(TERMINATED_STATE);
return;
}
}
}
示例15: set_state
// abort a result that's not currently running
//
void RESULT::abort_inactive(int status) {
if (state() >= RESULT_COMPUTE_ERROR) return;
set_state(RESULT_ABORTED, "RESULT::abort_inactive");
exit_status = status;
}