Пример #1
0
void *dim_tcpip_thread(void *tag)
{
	extern int dim_tcpip_init();
	extern void tcpip_task();
	/*	
	int prio;
		
	thr_getprio(thr_self(),&prio);
	thr_setprio(thr_self(),prio+10);
	*/
	if(tag){}
	IO_thread = pthread_self();

	dim_tcpip_init(1);
	if(INIT_thread)
	{
#ifndef darwin
		sem_post(&DIM_INIT_Sema);
#else
		sem_post(DIM_INIT_Semap);
#endif
	}
	while(1)
    {
		tcpip_task();
		/*
#ifndef darwin
		sem_post(&DIM_WAIT_Sema);
#else
		sem_post(DIM_WAIT_Semap);
#endif
		*/
		dim_signal_cond();
    }
}
Пример #2
0
void *dim_tcpip_thread(void *tag)
{
	sigset_t set1, set2;
	int signo;
	/*	
	int prio;
		
	thr_getprio(thr_self(),&prio);
	thr_setprio(thr_self(),prio+10);
	*/
	IO_thread = pthread_self();

	dim_tcpip_init(1);
	while(1)
    {
		if(INIT_thread)
#ifndef darwin
			sem_post(&DIM_INIT_Sema);
#else
			sem_post(DIM_INIT_Semap);
#endif
		tcpip_task();
#ifndef darwin
		sem_post(&DIM_WAIT_Sema);
#else
		sem_post(DIM_WAIT_Semap);
#endif
    }
}
Пример #3
0
static int enable_sig(int conn_id)
{
	int ret = 1, flags = 1;
#ifndef WIN32
	int pid;
#endif

#ifdef DEBUG
	if(!Net_conns[conn_id].channel)
	{
	    printf("Enabling signals on channel 0\n");
	    fflush(stdout);
	}
#endif

	if(!init_done)
	{
		dim_tcpip_init(0);
	}
	if(Threads_on)
	{
#ifdef WIN32
		DIM_IO_valid = 0;
/*
		ret = connect(DIM_IO_path[0], (struct sockaddr*)&DIM_sockname, sizeof(DIM_sockname));
*/
		closesock(DIM_IO_path[0]);
		DIM_IO_path[0] = -1;
		if( (DIM_IO_path[0] = (int)socket(AF_INET, SOCK_STREAM, 0)) == -1 ) 
		{
			perror("socket");
			return(1);
		}		
		ret = ioctl(DIM_IO_path[0], FIONBIO, &flags);
		if(ret != 0)
		{
			perror("ioctlsocket");
		}
		DIM_IO_valid = 1;
#else
		if(DIM_IO_path[1] != -1)
		{
			if(!DIM_IO_Done)
			{
				DIM_IO_Done = 1;
				write(DIM_IO_path[1], &flags, 4);
			}
		}
#endif
	}
#ifndef WIN32
	if(!Threads_on)
	{
	    pid = getpid();

#ifndef __linux__
		ret = ioctl(Net_conns[conn_id].channel, SIOCSPGRP, &pid );
#else
	    ret = fcntl(Net_conns[conn_id].channel,F_SETOWN, pid);
#endif
	    if(ret == -1)
	    {
#ifdef DEBUG
	        printf("ioctl returned -1\n");
#endif
			return(ret);
	    }
	}
	ret = ioctl(Net_conns[conn_id].channel, FIOASYNC, &flags );
	if(ret == -1)
	{
#ifdef DEBUG
		printf("ioctl1 returned -1\n");
#endif
		return(ret);
	}
	
    flags = fcntl(Net_conns[conn_id].channel,F_GETFD,0);
#ifdef DEBUG
    if(flags == -1)
    {
		printf("error\n");
    }
#endif
    ret = fcntl(Net_conns[conn_id].channel,F_SETFD, flags | FD_CLOEXEC );
    if(ret == -1)
    {
#ifdef DEBUG
		printf("ioctl2 returned -1\n");
#endif
		return(ret);
    }
#endif
	return(1);
}