JNIEXPORT void JNICALL Java_ism_monagent_EMListener_delete_1message_1queue
  (JNIEnv *env, jobject obj)
{
    TRACE("delete_message_queue()");
    delete_message_queue();
}
Exemple #2
0
int
switch_event_disconnected( struct switch_info *sw_info ) {
  int old_state = sw_info->state;

  if ( sw_info->state == SWITCH_STATE_DISCONNECTED ||
       sw_info->state == SWITCH_STATE_CONNECTION_FAILED ) {
    debug( "already disconnected" );
    return -1;
  }

  if ( sw_info->state == SWITCH_STATE_COMPLETED ) {
    sw_info->state = SWITCH_STATE_DISCONNECTED;
  }
  else {
    sw_info->state = SWITCH_STATE_CONNECTION_FAILED;
  }

  if ( old_state == SWITCH_STATE_COMPLETED ) {
    switch_unset_timeout( echo_reply_timeout, NULL );
  }

  if ( sw_info->fragment_buf != NULL ) {
    free_buffer( sw_info->fragment_buf );
    sw_info->fragment_buf = NULL;
  }

  if ( sw_info->send_queue != NULL ) {
    delete_message_queue( sw_info->send_queue );
    sw_info->send_queue = NULL;
  }

  if ( sw_info->recv_queue != NULL ) {
    delete_message_queue( sw_info->recv_queue );
    sw_info->recv_queue = NULL;
  }

  if ( sw_info->secure_channel_fd >= 0 ) {
    set_readable( switch_info.secure_channel_fd, false );
    set_writable( switch_info.secure_channel_fd, false );
    delete_fd_handler( switch_info.secure_channel_fd );
  }

  uint8_t state = MESSENGER_OPENFLOW_DISCONNECTED;
  if ( sw_info->state == SWITCH_STATE_CONNECTION_FAILED ) {
    state = MESSENGER_OPENFLOW_FAILD_TO_CONNECT;
  }

  debug( "Notify switch_disconnected to switch manager." );
  char switch_manager[] =  SWITCH_MANAGER;
  list_element switch_manager_only_list;
  switch_manager_only_list.next = NULL;
  switch_manager_only_list.data = switch_manager;
  service_send_to_application( &switch_manager_only_list, state, &sw_info->datapath_id, NULL );

  // Check switch_manager registration
  debug( "Checking switch manager's switch list." );
  sw_info->retry_count = UNREGISTRATION_RETRY_COUNT;
  set_list_switches_reply_handler( confirm_self_dpid_is_unregistered );
  if ( send_list_switches_request( sw_info ) ) {
    switch_set_timeout( UNREGISTRATION_TIMEOUT, unregistration_timeout, sw_info );
  }
  else {
    error( "Failed to send switch list request to switch manager." );
    stop_switch();
  }

  return 0;
}
int
main(int argc, char **argv)
{
/*****************test 1********************************/
	message_queue *tmp_queue;
	if((tmp_queue = create_message_queue()) == NULL)
	{
		printf("create queue error!\n");
    	return -1;
    }

    int i = 1;
    buffer *tmp_buf;
    char *tmp_char;

	tmp_char = *sample_string;
    while( tmp_char != NULL )
    {
       	tmp_buf = alloc_buffer_with_length(10);
        strcpy(tmp_buf->data, tmp_char);
        printf("the insert is %s, and %d\n",(char*)tmp_buf->data,sizeof(*(tmp_buf->data)));
        enqueue_message(tmp_queue, tmp_buf);
		tmp_char = sample_string[i];
        if(tmp_char == NULL)
            break;
        i++;
    }  

    int len;
    buffer *out;
    for( len = tmp_queue->length; len > 0; len-- )
    {
    	out = dequeue_message(tmp_queue);
        if(out->data == NULL)
            break;
        printf("%s\n", out->data);
        free_buffer(out);
  	}

    delete_message_queue(tmp_queue);
/*****************test 2********************************/

	message_queue *tmp_queue_;
   	if((tmp_queue_ = create_message_queue()) == NULL)
	{
		printf("create queue error!\n");
    	return -1;
    }
    int j = 1;
    buffer *tmp_buf_;
    char *tmp_char_;    
    
	tmp_char_ = *sample_string;
    while( tmp_char_ != NULL )
    {
       	tmp_buf_ = alloc_buffer_with_length(10);
        strcpy(tmp_buf_->data, tmp_char_);
        printf("the insert is %s, and %d\n",(char*)tmp_buf_->data,sizeof(*(tmp_buf_->data)));
        enqueue_message(tmp_queue_, tmp_buf_);
		tmp_char_ = sample_string[j];
        if(tmp_char_ == NULL)
            break;
        j++;
    }  

    delete_message_queue(tmp_queue_);
/*****************end of test********************************/


    return 0;
}
Exemple #4
0
static void
test_delete_message_queue_if_queue_is_not_created() {
  message_queue *queue = NULL;
  expect_assert_failure( delete_message_queue( queue ) );
}