예제 #1
0
파일: tunet.c 프로젝트: alick/mytunet
VOID tunet_stop()
{
	logs_append(g_logs, "TUNET_STOP", NULL, NULL, 0);

	if(thread_tunet)
	{
		logout_socket_buffer = buffer_clear(logout_socket_buffer);

		tunet_state = TUNET_STATE_LOGOUT;
		while(tunet_state != TUNET_STATE_NONE && tunet_state != TUNET_STATE_ERROR)
			os_sleep(20);

		os_thread_kill(thread_tunet);
		while(thread_tunet)	os_sleep(20);

		main_socket_buffer = buffer_clear(main_socket_buffer);
		keepalive_socket_buffer = buffer_clear(keepalive_socket_buffer);
		logout_socket_buffer = buffer_clear(logout_socket_buffer);

		strcpy(keepalive_server, "");
		keepalive_server_port = 0;

		strcpy(msg_server, "");
		msg_server_port = 0;
	}

	logs_append(g_logs, "TUNET_STOP", "END", NULL, 0);
}
void fs2netd_reset_connection()
{
	bool reset_gameserver = false;

	if (Net_player->flags & NETINFO_FLAG_MT_CONNECTED) {
		fs2netd_gameserver_disconnect();
		reset_gameserver = true;
	}

	FS2NetD_Disconnect();

	fs2netd_reset_state();

	// wait a little to allow for the port to clear
	os_sleep(500);

	// try to reinit the server connection
	fs2netd_login();

	os_sleep(250);

	if ( reset_gameserver && fs2netd_is_online() ) {
		fs2netd_gameserver_start();
	}
}
예제 #3
0
int main( int argc, char **argv )
{
	void *pTaskHandle = NULL;
	
	enable_log( 1 );
	set_log( LOG_TYPE_CONSOLE, NULL, 0 );

	if( init_session(  ) < 0 )
		return -1;
		
	pTaskHandle = create_task( task_test, 5, 100 );
	if ( pTaskHandle )
	{
		CMessage stMsg;
		
		memset( &stMsg, 0x00, sizeof(stMsg) );
		
		post_task_msg( pTaskHandle, &stMsg );
		
		log_print( "create task ok................." );
	}
	else 
		log_print( "create task failed?????????????????????" );
	
	while ( 1 )
		os_sleep( 1000 );
		
	release_session(  );
	
	return 0;	
}
/*
 * blocking callers sleep here until the todo list is done
 */
static int todo_wait_done(void)
{
	di_debug("FUNC: %s\n", __func__);
	os_sleep(done_queue, todo.status == TODO_ST_DONE, 0);

	return todo.rc;
}
예제 #5
0
int main(void)
{
    Error	check_error = success;
    uint8	narrow;
    uint8	wide;

    os_sleep(100);

    CheckCleanup(os_boot(boot_module_table, LENGTH(boot_module_table)), boot_failure);
    CheckCleanup(record_command(0, null), record_failure);

  record_failure:	narrow = 2; wide = 1; goto failure;
  boot_failure:		narrow = 1; wide = os_boot_index(); goto failure;
  failure:
    while (!uart_character_ready())
	led_signal(narrow, wide);

    error_stack_print();

    write(PSTR("\r\n\r\nWavelogger v4.0\r\n"));
    write(PSTR("Reset reason: 0x%hx\r\n"), os_reset_reason());

    shell_run(shell_command_table, LENGTH(shell_command_table));

    return 0;
}
예제 #6
0
void wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv)
{
	struct wpa_ctrl_dst *dst, *prev;

	if (priv->sock > -1) {
		char *fname;
		char *buf, *dir = NULL, *gid_str = NULL;
		eloop_unregister_read_sock(priv->sock);
		if (priv->ctrl_dst) {
			/*
			 * Wait a second before closing the control socket if
			 * there are any attached monitors in order to allow
			 * them to receive any pending messages.
			 */
			wpa_printf(MSG_DEBUG, "CTRL_IFACE wait for attached "
				   "monitors to receive messages");
			os_sleep(1, 0);
		}
		close(priv->sock);
		priv->sock = -1;
		fname = wpa_supplicant_ctrl_iface_path(priv->wpa_s);
		if (fname) {
			unlink(fname);
			os_free(fname);
		}

		buf = os_strdup(priv->wpa_s->conf->ctrl_interface);
		if (buf == NULL)
			goto free_dst;
		if (os_strncmp(buf, "DIR=", 4) == 0) {
			dir = buf + 4;
			gid_str = os_strstr(dir, " GROUP=");
			if (gid_str) {
				*gid_str = '\0';
				gid_str += 7;
			}
		} else
			dir = buf;

		if (rmdir(dir) < 0) {
			if (errno == ENOTEMPTY) {
				wpa_printf(MSG_DEBUG, "Control interface "
					   "directory not empty - leaving it "
					   "behind");
			} else {
				perror("rmdir[ctrl_interface]");
			}
		}
		os_free(buf);
	}

free_dst:
	dst = priv->ctrl_dst;
	while (dst) {
		prev = dst;
		dst = dst->next;
		os_free(prev);
	}
	os_free(priv);
}
예제 #7
0
void wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv)
{
	struct wpa_ctrl_dst *dst, *prev;

	if (priv->sock > -1) {
		eloop_unregister_read_sock(priv->sock);
		if (priv->ctrl_dst) {
			/*
			 * Wait a second before closing the control socket if
			 * there are any attached monitors in order to allow
			 * them to receive any pending messages.
			 */
			wpa_printf(MSG_DEBUG, "CTRL_IFACE wait for attached "
				   "monitors to receive messages");
			os_sleep(1, 0);
		}
		close(priv->sock);
		priv->sock = -1;
	}

	dst = priv->ctrl_dst;
	while (dst) {
		prev = dst;
		dst = dst->next;
		os_free(prev);
	}
	os_free(priv);
}
예제 #8
0
파일: tunet.c 프로젝트: alick/mytunet
VOID tunet_start(USERCONFIG *uc)
{
	assert(uc != NULL);

	if(thread_tunet)
	{
		os_thread_kill(thread_tunet);
		while(thread_tunet) os_sleep(20);
	}


	logs_append(g_logs, "TUNET_START", NULL, NULL, 0);

	memcpy(&userconfig, uc, sizeof(USERCONFIG));
	
	strcpy(keepalive_server, "");
	keepalive_server_port = 0;

	strcpy(msg_server, "");
	msg_server_port = 0;

	main_socket = os_socket_tcp_close(main_socket);
	keepalive_socket = os_socket_tcp_close(keepalive_socket);
	logout_socket = os_socket_tcp_close(logout_socket);


	tunet_state = TUNET_STATE_LOGIN;

	main_socket_buffer = buffer_clear(main_socket_buffer);
	keepalive_socket_buffer = buffer_clear(keepalive_socket_buffer);
	logout_socket_buffer = buffer_clear(logout_socket_buffer);

	thread_tunet = os_thread_create(tunet_thread, NULL, FALSE, FALSE);
}
예제 #9
0
void run(int nReaders, uint64_t bytes, bool sync) {
  ThreadPool q(nReaders * 2 + 8, sync);

  Server();
  for (int i = 0; i < nReaders; ++i)
    TcpReader(bytes);

  os_sleep(100 * 1000);
}
u8 hostapd_channel_align_LTE_coex(struct hostapd_data *hapd, u8 oper_chan)
{
	int avail_ch_num, i;
	int avail_ch[14]={0};
	int fail_cnt = 0;
	struct wpa_driver_available_chan_s available_chan; 

	//No LTE COEX need for channels in 5GHz
	if (oper_chan > 14)
		return oper_chan;
	do {
	        os_memset(&available_chan, 0, sizeof(struct wpa_driver_available_chan_s));
                hostapd_drv_get_available_channel(hapd, (u8 *)&available_chan);
                    
		wpa_printf(MSG_DEBUG, "2G CHANNEL=0x%08x", available_chan.ch_2g_base1);
	        if (BIT(31) & available_chan.ch_2g_base1) {
	        	break;
	        } else {
			wpa_printf(MSG_DEBUG, "GET AVAILABLE CHANNEL: command failed");
	        	fail_cnt++;
			if(fail_cnt > 14)
	                	return oper_chan;
			os_sleep(0,1000*350);
		}
	} while(1);
	os_memset(avail_ch, 0, sizeof(avail_ch));
	avail_ch_num = 0;		
	for (i = 0; i < 14; i++) {
		if (BIT(i) & available_chan.ch_2g_base1) {
			avail_ch[avail_ch_num] = i + 1;
			avail_ch_num++;
		} else 
			continue;
	}

	wpa_printf(MSG_DEBUG,"DRIVER Report 2.4G available %d channel", avail_ch_num);
	for (i = 0; i < avail_ch_num; i++)
		wpa_printf(MSG_DEBUG,"Channel[%d] is fine", avail_ch[i]);
		
	wpa_printf(MSG_DEBUG,"Operating Channel = %d", oper_chan );		
	//align channel
	if (avail_ch_num > 0) {
		if (oper_chan <= avail_ch[0])
			oper_chan = avail_ch[0];
		else if (oper_chan >= avail_ch[avail_ch_num-1])
			oper_chan = avail_ch[avail_ch_num-1];
		else
				for (i = 0; i < avail_ch_num; i++) {
					if (oper_chan >= avail_ch[i])
						oper_chan = avail_ch[i];
				}	
		wpa_printf(MSG_DEBUG,"Align Operating Channel = %d", oper_chan );						
	}		

	return oper_chan;			
					
}
예제 #11
0
void busy_run(long long loop, double sleep, struct busy_loop_data * busy_loop)
{
	while (loop > 0)
	{
		assert(busy_loop_run(busy_loop));
		os_sleep(sleep);
		loop--;
	}
}
예제 #12
0
void led_flash(uint8 count, bool wide)
{
    led_set(0, false);
    led_set(1, false);

    for (uint8 i = 0; i < count; ++i)
    {
	if (wide) led_set(0, true);
	          led_set(1, true);

	os_sleep(25);

	led_set(0, false);
	led_set(1, false);

	os_sleep(25);
    }
}
예제 #13
0
void eloop_run(void)
{
	int i;
	struct os_time tv, now;

	while (!eloop.terminate &&
		(eloop.timeout || eloop.reader_count > 0)) {
		if (eloop.timeout) {
			os_get_time(&now);
			if (os_time_before(&now, &eloop.timeout->time))
				os_time_sub(&eloop.timeout->time, &now, &tv);
			else
				tv.sec = tv.usec = 0;
		}

		/*
		 * TODO: wait for any event (read socket ready, timeout (tv),
		 * signal
		 */
		os_sleep(1, 0); /* just a dummy wait for testing */

		eloop_process_pending_signals();

		/* check if some registered timeouts have occurred */
		if (eloop.timeout) {
			struct eloop_timeout *tmp;

			os_get_time(&now);
			if (!os_time_before(&now, &eloop.timeout->time)) {
				tmp = eloop.timeout;
				eloop.timeout = eloop.timeout->next;
				tmp->handler(tmp->eloop_data,
					     tmp->user_data);
				free(tmp);
			}

		}

		eloop.reader_table_changed = 0;
		for (i = 0; i < eloop.reader_count; i++) {
			/*
			 * TODO: call each handler that has pending data to
			 * read
			 */
			if (0 /* TODO: eloop.readers[i].sock ready */) {
				eloop.readers[i].handler(
					eloop.readers[i].sock,
					eloop.readers[i].eloop_data,
					eloop.readers[i].user_data);
				if (eloop.reader_table_changed)
					break;
			}
		}
	}
}
예제 #14
0
파일: ethcard_eth.c 프로젝트: alick/mytunet
static THREADRET raw_socket_loop_thread(THREAD *self)
{
	CHAR buf[2*32767];
	
	ETHCARD_LOOP_RECV_PROC_PARAM *pp, p;
	size_t len = 0, recvlen = 0;
	struct sockaddr_ll addr;

	fd_set set;
	struct timeval tv;

	
	pp = (ETHCARD_LOOP_RECV_PROC_PARAM *)self->param;
	p.ethcard = pp->ethcard;
	p.proc = pp->proc;

	BYTE *pkt_data;

	os_thread_init_complete(self);	

	//pcap_loop(p.ethcard, 0, dispatcher_handler, (BYTE *)&p);
	while(os_thread_is_running(self) || os_thread_is_paused(self))
	{
		tv.tv_sec = 0;
		tv.tv_usec = 0;
		FD_ZERO(&set);
		FD_SET(p.ethcard->fd, &set);
		select(p.ethcard->fd + 1, &set, NULL, NULL, &tv);
		if( FD_ISSET(p.ethcard->fd, &set) )
		{
			len = sizeof(addr);  
			recvlen = recvfrom(p.ethcard->fd,(char *)buf, sizeof(buf), 0, (struct sockaddr *)&addr, &len);
	
			if(recvlen > 0)
			{
				pkt_data = (BYTE *)buf;
		
				if(addr.sll_protocol == 0x8e88)
					p.proc(p.ethcard, pkt_data, recvlen);
			}
			else
			{
				//must be something wrong....
			}			
		}
		else
		{
			//dprintf("ETH Sleep...\n");
			os_sleep(20);
		}
		os_thread_test_paused(self);
	}
	thread_ethcard_recv = os_thread_free(thread_ethcard_recv);	
	return 0;
}
예제 #15
0
파일: tunet.c 프로젝트: alick/mytunet
VOID tunet_cleanup()
{
	os_thread_kill(thread_tunet);
	while(thread_tunet) os_sleep(20);

	main_socket_buffer = buffer_free(main_socket_buffer);
	keepalive_socket_buffer = buffer_free(keepalive_socket_buffer);
	logout_socket_buffer = buffer_free(logout_socket_buffer);

	keepalive_timeout = os_tick_free(keepalive_timeout);
}
예제 #16
0
파일: tunet.c 프로젝트: alick/mytunet
VOID tunet_reset()
{
	logs_append(g_logs, "TUNET_RESET", NULL, NULL, 0);
	if(thread_tunet)
	{
		os_thread_kill(thread_tunet);
		while(thread_tunet) os_sleep(20);
	}

	tunet_state = TUNET_STATE_NONE;
}
예제 #17
0
/*!
 * Get random data.
 *
 * @param      user_ctx  A user context from #fsl_shw_register_user().
 * @param      length    The number of octets of @a data being requested.
 * @param data      A pointer to a location of @a length octets to where
 *                       random data will be returned.
 *
 * @return     FSL_RETURN_NO_RESOURCE_S  A return code of type #fsl_shw_return_t.
 *             FSL_RETURN_OK_S
 */
fsl_shw_return_t fsl_shw_get_random(fsl_shw_uco_t * user_ctx, uint32_t length,
				    uint8_t * data)
{
	fsl_shw_return_t return_code = FSL_RETURN_NO_RESOURCE_S;
	/* Boost up length to cover any 'missing' bytes at end of a word */
	uint32_t *buf = os_alloc_memory(length + 3, 0);
	volatile rng_work_entry_t *work = os_alloc_memory(sizeof(*work), 0);

	if ((rng_availability != RNG_STATUS_OK) || (buf == NULL)
	    || (work == NULL)) {
		if (rng_availability != RNG_STATUS_OK) {
			LOG_KDIAG_ARGS("rng not available: %d\n",
				       rng_availability);
		} else {
			LOG_KDIAG_ARGS
			    ("Resource allocation failure: %d or %d bytes",
			     length, sizeof(*work));
		}
		/* Cannot perform function.  Clean up and clear out. */
		if (buf != NULL) {
			os_free_memory(buf);
		}
		if (work != NULL) {
			os_free_memory((void *)work);
		}
	} else {
		unsigned blocking = user_ctx->flags & FSL_UCO_BLOCKING_MODE;

		work->hdr.user_ctx = user_ctx;
		work->hdr.flags = user_ctx->flags;
		work->hdr.callback = user_ctx->callback;
		work->hdr.user_ref = user_ctx->user_ref;
		work->hdr.postprocess = finish_random;
		work->length = length;
		work->data_local = buf;
		work->data_user = data;

		RNG_ADD_WORK_ENTRY((rng_work_entry_t *) work);

		if (blocking) {
			os_sleep(rng_wait_queue, work->completed != FALSE,
				 FALSE);
			finish_random((shw_queue_entry_t *) work);
			return_code = work->hdr.code;
			os_free_memory((void *)work);
		} else {
			return_code = FSL_RETURN_OK_S;
		}
	}

	return return_code;
}				/* fsl_shw_get_entropy */
예제 #18
0
파일: wpatalk.c 프로젝트: KHATEEBNSIT/AP
/* wpatalk_reconnect -- maybe reconnect.
 * If previously connected, disconnects and aborts unless "keep_going"
 * is set (-k option).
 */
static void wpatalk_reconnect(void)
{
    if (ctrl_conn) {
        wpatalk_close_connection();
        if (!keep_going) {
            wpatalk_fatal("Exiting due to lost connection");
        }
    }
    for (;;) {
        if (wpatalk_get_socket_path() == 0) {
            #ifdef CONFIG_CTRL_IFACE_UNIX
            ctrl_conn = wpa_ctrl_open(socket_path);
            #else
            #error "wpatalk_open_connection configuration error"
            #endif
        }
        if (ctrl_conn) {
            if (wpa_ctrl_attach(ctrl_conn) == 0) {
                if (warning_displayed || verbose) {
                    wpatalk_info(
                        "Connection (re)established to daemon=%s interface=%s",
                        daemon_name, ctrl_ifname);
                    wpatalk_info("... using socket-file=%s", socket_path);
                    warning_displayed = 0;
 	        }
                wpatalk_attached = 1;
                return;
            } else {
                if (!warning_displayed) {
                    wpatalk_warning(
                        "Failed to attach to daemon %s", daemon_name);
                }
                wpatalk_close_connection();
                ctrl_conn = NULL;
            }
        }
        if (!keep_going) {
            wpatalk_fatal("Failed to connect to daemon %s errno %d "
                        "using socket file %s", 
                daemon_name, errno, socket_path);
            return;
        }
        if (!warning_displayed) {
            wpatalk_info("Could not connect to daemon %s -- re-trying",
                    daemon_name);
            warning_displayed = 1;
        }
        os_sleep(1, 0);
    }

    return;
}
예제 #19
0
void main_child(int pid, void * data)
{
	struct busy_data * busy =
		(struct busy_data *)data;

	os_sleep(1); /* allows the other fork to happen ASAP */
	os_nice_set(pid, busy->nice);

	busy_run((int)(busy->total_sequential_time / (busy->running_time + busy->sleeping_time)),
			busy->sleeping_time,
			busy->busy_loop);
	main_cleanup(busy);
}
예제 #20
0
Error led_init()
{
    DDRC = 0x60;

    for (uint i = 0; i < 20; ++i)
    {
	led_set(i & 1, true);
	led_set((i + 1) & 1, false);
	os_sleep(10);
    }

    return success;
}
예제 #21
0
int main( int argc, char **argv )
{
	void *pShineHandle = NULL;
	CShineParam stShineParam;
	const int8_t *pShineServerIP = "192.168.1.100";
	const int16u_t iShineServerPort = 9000;
	const int8_t *pShineId = "dsflseewfreeeeeeeeee";

	enable_log( 1 );
	set_log( LOG_TYPE_CONSOLE, NULL, 0 );
	
	
	if ( init_shine(  ) < 0 )
		return -1;
		
	//
//	void *open_shine( const CShineParam *pShineParam );
	
	memset( &stShineParam, 0x00, sizeof(stShineParam) );
	memcpy( stShineParam.pServerIP, pShineServerIP, strlen(pShineServerIP) + 1 );
	stShineParam.iServerPort = iShineServerPort;
	
	memcpy( stShineParam.pLocalIP, pShineServerIP, strlen(pShineServerIP) + 1 );
	stShineParam.iLocalPort = 8001;
	
	memcpy( stShineParam.pShineId, pShineId, strlen(pShineId) + 1 );
	
	pShineHandle = open_shine( &stShineParam );
	if ( pShineHandle )
	{
		//int32_t open_shine_tunnel( void *pHandle, int8_t *pPeerShineId );
		int32_t iTunnelId = -1;

		log_print( "open shine ok................" );
			
		iTunnelId = open_shine_tunnel( pShineHandle, "134354325" );
		if ( iTunnelId >= 0 )
		{
			log_print( "open shine tunnel ok.............." );
		}
		else 	
			log_print( "open shine tunnel failed." );
	}
	
	while ( 1 )
		os_sleep( 1000 );
		
	release_shine(  );	
	
	return 0;	
}
예제 #22
0
int main(int argc, char *argv[])
{
    if (kxplayer_initialize() != 0) {
        OS_LOG(os_log_error, "unable to initialize kxplayer.");
        return -1;
    }
    os_log_setlevel(os_log_trace);
    struct os_log_backend* console = os_log_backend_create(os_log_console_interface(), NULL);
    os_log_add_backend(console);
    
    struct kxplayer_agent_option option;
    option.start_callback = start;
    option.receive_callback = receive;
    option.finish_callback = NULL;
    option.userdata = NULL;
    struct kxplayer_agent* agent = kxplayer_agent_create(&option);
    if (agent == NULL) {
        OS_LOG(os_log_error, "unable to create agent.");
        return -1;
    }
    
    if (kxplayer_agent_open(agent, PLAY_URI) != 0) {
        OS_LOG(os_log_error, "unable to open uri %s.", PLAY_URI);
        return -1;
    }
    
    os_sleep(5000);
    kxplayer_agent_open(agent, MP3_FILE);
    os_sleep(999999);
    
    kxplayer_agent_stop(agent);
    
    kxplayer_terminate();
    
    return 0;
}
예제 #23
0
static void handle_start_control(md_msg_control_start_t *start)
{
    int ret;

    if (!md_srv_com_is_agentx_alive())
    {
	char node_id_str[32];
	char master_agentx_port_str[EXA_MAXSIZE_LINE + 1];
	os_snprintf(node_id_str, sizeof(node_id_str), "%u", start->node_id);
	os_snprintf(master_agentx_port_str, sizeof(master_agentx_port_str), "%d",
                    start->master_agentx_port);

        /* XXX No use for a block here */
	{
            char agentx_path[OS_PATH_MAX];
	    char *const argv[] =
		{
                    agentx_path,
		    node_id_str,
		    start->node_name,
		    start->master_agentx_host,
		    master_agentx_port_str,
		    NULL
		};

            exa_env_make_path(agentx_path, sizeof(agentx_path), exa_env_sbindir(), "exa_agentx");
	    ret = exa_system(argv);
	}
	if (ret != EXA_SUCCESS)
	{
	    exalog_error("Error spawning exa_agentx(%d).", ret);
	    md_messaging_ack_control(ret);
	    return;
	}

	/* wait a bit to get the first alive message from agentx
	 * TODO : not robust enough, replace with a timeouted lock */
	os_sleep(MD_HEARTBEAT_TIMEOUT_SECONDS);

	if (!md_srv_com_is_agentx_alive())
	{
	    exalog_error("Error spawning exa_agentx(%d).", -MD_ERR_AGENTX_NOT_ALIVE);
	    md_messaging_ack_control(-MD_ERR_AGENTX_NOT_ALIVE);
	    return;
	}
    }
    md_messaging_ack_control(EXA_SUCCESS);
}
예제 #24
0
void fs2netd_disconnect()
{
	if ( !Is_connected ) {
		return;
	}

	if (Net_player->flags & NETINFO_FLAG_MT_CONNECTED) {
		fs2netd_gameserver_disconnect();
	}

	FS2NetD_Disconnect();

	fs2netd_reset_state();

	os_sleep(500);
}
예제 #25
0
파일: os.c 프로젝트: jkuchta/avr-os
void _os_task_delay_starter(void *arg) {
    int x;
    while(1) {
        os_sleep(1000);
        uptime_secs++;

        for(x = 0; x < num_tasks; x++) {
            if(!BIT_ISSET(tasks[x].flags, TASK_FLAG_RUNNING) && !BIT_ISSET(tasks[x].flags, TASK_FLAG_DONE) &&
                tasks[x].start_delay_secs > 0) {

                tasks[x].start_delay_secs -= 1;

            }
        }
    }
}
예제 #26
0
파일: smtp.c 프로젝트: BrunoBasseto/Hermes
// ------------------------------------------------
// Function:        smtp_quit()
// ------------------------------------------------
// Input:           -
// Output:          -
// ------------------------------------------------
// Description:     Ends an SMTP transaction
// ------------------------------------------------
void smtp_quit(void)
{
    if(!tcp_is_open(SOCKET_SMTP)) return;                           // socket already closed

    // ----------------------
    // sends the QUIT command
    // ----------------------
    tcp_send_text(SOCKET_SMTP, "QUIT\r\n");
    smtp_ok();

    // -------------------------
    // waits for a disconnection
    // -------------------------
    os_sleep(500);
    if(tcp_is_open(SOCKET_SMTP)) tcp_close(SOCKET_SMTP);
    smtp_state = SMTP_IDLE;
}
예제 #27
0
ut_setup()
{
    int i;

    os_random_init();
    unlink(test_tokens_file);
    data.file = test_tokens_file;

    /* We generate two random ports as when two instances of this UT are run at
     * the same time, one can block the other as they try to open the same port.
     *
     * The operation done below with the modulo and the addition is to ensure
     * the value is bound between 1025 and 65535, which is the default
     * non-privileged user accessible ports range.
     */
    data.port = (os_process_id() % 64511) + 1025;
    data.priv_port = (data.port + 1) % 64511 + 1025;

    UT_ASSERT(data.port > 1024);
    UT_ASSERT(data.priv_port > 1024);
    UT_ASSERT(data.port != data.priv_port);

#ifdef WIN32
    data.logfile = "nul";
#else
    data.logfile = "/dev/null";
#endif

    os_thread_create(&server_thread, 0, token_manager_thread, &data);
    os_sleep(1);

    for (i = 0; i < NUM_TEST_CLUSTERS; i++)
        __setup_cluster(&clusters[i]);

    for (i = 0; i < NUM_TEST_CLUSTERS; i++)
    {
        UT_ASSERT_EQUAL(0, tm_init(&clusters[i].tms[0], "127.0.0.1", data.port));
        UT_ASSERT_EQUAL(0, tm_connect(clusters[i].tms[0]));
        UT_ASSERT_EQUAL(0, tm_init(&clusters[i].tms[1], "127.0.0.1", data.port));
        UT_ASSERT_EQUAL(0, tm_connect(clusters[i].tms[1]));
    }

    UT_ASSERT(tm_init(&user_tm, "127.0.0.1", data.priv_port) == 0);
    UT_ASSERT_EQUAL(0, tm_connect(user_tm));
}
예제 #28
0
static int wpa_driver_tista_driver_start( void *priv )
{
    struct wpa_driver_ti_data *drv = (struct wpa_driver_ti_data *)priv;
    u32 uDummyBuf;
    s32 res;

    res = wpa_driver_tista_private_send(priv, DRIVER_START_PARAM, &uDummyBuf, sizeof(uDummyBuf), NULL, 0);

    if (0 != res) {
        wpa_printf(MSG_ERROR, "ERROR - Failed to start driver!");
        wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "HANGED");
    }
    else {
        os_sleep(0, WPA_DRIVER_WEXT_WAIT_US); /* delay 400 ms */
        wpa_printf(MSG_DEBUG, "wpa_driver_tista_driver_start success");
    }
    return res;
}
예제 #29
0
파일: app.c 프로젝트: zeppo21/demo_c
/*
 * Application run. This function contains the execution loop.
 */
void appRun()
{
	BOOL_t running = TRUE;

	if( isInitialized == TRUE )
	{
		/* Run the app loop */
		while( running == TRUE )
		{

			if( os_sleep( 10 ) != NO_MSG )
			{
				updateControls();
			}
		}
	}

}
예제 #30
0
파일: os_win32.c 프로젝트: alick/mytunet
THREAD *os_thread_create(THREADPROC proc, POINTER param, BOOL wait_for_init, BOOL paused)
{
	THREAD *thr;
	DWORD id;
	thr = os_new(THREAD, 1);

	thr->status = paused ? THREAD_PAUSED : THREAD_RUNNING;
	thr->param = param;
	thr->init_complete = FALSE;
	thr->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)proc, thr, 0 ,&id);
	thr->threadid = id;

	while(wait_for_init && !thr->init_complete)
	{
		os_sleep(20);
	}
	return thr;
}