Ejemplo n.º 1
0
Archivo: object.cpp Proyecto: webjb/bbb
s_object_t::s_object_t()
{
//	PRINT_INFO("xc_ao_t::xc_ao_t\n");
    m_quit = 1;	
    CREATE_MUTEX(m_mutex);
    CREATE_SIGNAL(m_signal, 0);	
}
Ejemplo n.º 2
0
pwr_tStatus
sync_MutexInit (
  thread_sMutex		*mp
)
{

#if defined OS_ELN

  pwr_tStatus sts = SYNC__SUCCESS;

  ELN$CREATE_MUTEX(*mp, &sts);

  return sts;

#elif defined OS_LYNX && defined PWR_LYNX_30

  return errno_Pstatus(pthread_mutex_init(mp, NULL));

#elif defined OS_POSIX

  return errno_Status(pthread_mutex_init(mp, NULL));

#elif defined OS_VMS

  return errno_Status(tis_mutex_init(mp));

#else
# error Not defined for this platform !
#endif
}
Ejemplo n.º 3
0
void plc_inittimer (
  plc_sThread *tp
)
{

#if 0
  /* Create the timer mutex */
#ifdef OS_ELN
  {
    int	sts;
    ELN$CREATE_MUTEX(tp->timer_mutex, &sts);
    if (EVEN(sts))
      pwr_Bugcheck(sts, "Cannot create timer_mutex");
  }
#elif defined OS_POSIX
  {
    pthread_mutexattr_t attr;

    pthread_mutexattr_create(&attr);
    if (pthread_mutex_init(&tp->timer_mutex, attr) == -1) 
      pwr_Bugcheck(errno, "Cannot create timer_mutex");
    pthread_mutexattr_delete(&attr);
  }
#endif
#endif
}
Ejemplo n.º 4
0
CEventMgr::CEventMgr()
{
	m_pUserData = NULL;
	m_fnEventCallBack = NULL;
	m_MutexEventQueue = CREATE_MUTEX();
	m_bRun = FALSE;
	m_Thread = NULL;
	m_ThreadId = 0;
}
Ejemplo n.º 5
0
CUserMgr::CUserMgr()
{
	m_fnEventCallBack = NULL;
	m_pUserData = NULL;
	m_fnYUVFrameCallBack = NULL;
	m_pYUVFrameUserData = NULL;
	m_strUserID = "";
	m_strUserPwd = "";
	m_strLocalIP = "";
	m_sslSocket.SetUserMgr(this);
	m_loginMgr.SetUserMgr(this);
	m_serverMgr.SetUserMgr(this);
	m_provisionMgr.SetUserMgr(this);
	m_operationMgr.SetUserMgr(this);
	m_mediaMgr.SetUserMgr(this);
	m_timer.SetUserMgr(this);
	m_MutexInterface = CREATE_MUTEX();
	m_EventInterface = ::CreateEvent(NULL, TRUE, FALSE, NULL);
	m_serverStatus = 0;
	m_sessionId = "";
	m_bIsDisconnect = FALSE;
}
Ejemplo n.º 6
0
/* Functions */
int QueryDNSListenUDPInit(ConfigFileInfo *ConfigInfo)
{
	CompatibleAddr ListenAddr;

	const char	*LocalAddr = ConfigGetRawString(ConfigInfo, "LocalInterface");

	int			LocalPort = ConfigGetInt32(ConfigInfo, "LocalPort");

	int			AddrLen;

	RefusingResponseCode = ConfigGetInt32(ConfigInfo, "RefusingResponseCode");

	Family = GetAddressFamily(LocalAddr);

	ListenSocketUDP = socket(Family, SOCK_DGRAM, IPPROTO_UDP);

	if(ListenSocketUDP == INVALID_SOCKET)
	{
		int		ErrorNum = GET_LAST_ERROR();
		char	ErrorMessage[320];
		ErrorMessage[0] = '\0';

		GetErrorMsg(ErrorNum, ErrorMessage, sizeof(ErrorMessage));

		ERRORMSG("Creating UDP socket failed. %d : %s\n",
				 ErrorNum,
				 ErrorMessage
				 );
		return -1;
	}

	memset(&ListenAddr, 0, sizeof(ListenAddr));

	if( Family == AF_INET )
	{
		FILL_ADDR4(ListenAddr.Addr4, AF_INET, LocalAddr, LocalPort);

		AddrLen = sizeof(struct sockaddr);
	} else {
		char Addr[LENGTH_OF_IPV6_ADDRESS_ASCII] = {0};

		sscanf(LocalAddr, "[%s]", Addr);

		ListenAddr.Addr6.sin6_family = Family;
		ListenAddr.Addr6.sin6_port = htons(LocalPort);
		IPv6AddressToNum(Addr, &(ListenAddr.Addr6.sin6_addr));

		AddrLen = sizeof(struct sockaddr_in6);
	}

	if(	bind(ListenSocketUDP, (struct sockaddr*)&(ListenAddr), AddrLen)
			!= 0
		)
	{
		int		ErrorNum = GET_LAST_ERROR();
		char	ErrorMessage[320];
		ErrorMessage[0] = '\0';

		GetErrorMsg(ErrorNum, ErrorMessage, sizeof(ErrorMessage));

		ERRORMSG("Opening UDP socket failed. %d : %s\n",
				 ErrorNum,
				 ErrorMessage
				 );
		return -2;
	}

	CREATE_MUTEX(ListenMutex);
	EFFECTIVE_LOCK_INIT(LockOfSendBack);

	MaximumMessageSize = GetMaximumMessageSize(ListenSocketUDP);
	if(MaximumMessageSize < 0)
	{
		MaximumMessageSize = 1000;
	}
	Inited = TRUE;

	return 0;
}
Ejemplo n.º 7
0
static gdb_sLocal *
mapLocalDb (
  pwr_tStatus		*sts
)
{

#if defined OS_LYNX || defined OS_LINUX
  pthread_mutexattr_t	mattr;
#endif

  gdb_AssumeLocked;

  if (gdbroot->db->version != gdb_cVersion)
    pwr_Return(NULL, sts, GDH__REVLEVEL);

#ifdef	OS_ELN
  ELN$CREATE_MUTEX(gdbroot->thread_lock, NULL);

#elif defined(OS_LINUX) || defined(OS_LYNX) && !defined(PWR_LYNX_30)
  pthread_mutexattr_init(&mattr);
  if (pthread_mutex_init(&gdbroot->thread_lock, &mattr) == -1) {
    perror("mapLocalDb: pthread_mutex_init, ");
    pwr_Return(NULL, sts, GDB__MUTEXINIT);
  }

#elif defined OS_LYNX
  pthread_mutexattr_create(&mattr);
  if (pthread_mutex_init(&gdbroot->thread_lock, mattr) == -1) {
    perror("mapLocalDb: pthread_mutex_init, ");
    pwr_Return(NULL, sts, GDB__MUTEXINIT);
  }
#endif

  /* Map hash tables.  */

  gdbroot->oid_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.oid_ht, &gdbroot->db->h.oid_ht, NULL, NULL);
  if (gdbroot->oid_ht == NULL) errh_Bugcheck(*sts, "initiating oid hash table");

  gdbroot->vid_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.vid_ht, &gdbroot->db->h.vid_ht, NULL, NULL);
  if (gdbroot->vid_ht == NULL) errh_Bugcheck(*sts, "initiating vid hash table");

  gdbroot->vn_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.vn_ht, &gdbroot->db->h.vn_ht, NULL, NULL);
  if (gdbroot->vn_ht == NULL) errh_Bugcheck(*sts, "initiating vn hash table");

  gdbroot->nid_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.nid_ht, &gdbroot->db->h.nid_ht, NULL, NULL);
  if (gdbroot->nid_ht == NULL) errh_Bugcheck(*sts, "initiating nid hash table");

  gdbroot->cid_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.cid_ht, &gdbroot->db->h.cid_ht, NULL, NULL);
  if (gdbroot->cid_ht == NULL) errh_Bugcheck(*sts, "initiating cid hash table");

  gdbroot->tid_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.tid_ht, &gdbroot->db->h.tid_ht, NULL, NULL);
  if (gdbroot->tid_ht == NULL) errh_Bugcheck(*sts, "initiating tid hash table");

  gdbroot->family_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.family_ht, &gdbroot->db->h.family_ht, NULL, NULL);
  if (gdbroot->family_ht == NULL) errh_Bugcheck(*sts, "initiating family hash table");

  gdbroot->ms_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.ms_ht, &gdbroot->db->h.ms_ht, NULL, NULL);
  if (gdbroot->ms_ht == NULL) errh_Bugcheck(*sts, "initiating mount server hash table");

  gdbroot->as_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.as_ht, &gdbroot->db->h.as_ht, NULL, NULL);
  if (gdbroot->as_ht == NULL) errh_Bugcheck(*sts, "initiating alias server hash table");

  gdbroot->subc_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.subc_ht, &gdbroot->db->h.subc_ht, NULL, NULL);
  if (gdbroot->subc_ht == NULL) errh_Bugcheck(*sts, "initiating subscription client hash table");

  gdbroot->subs_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.subs_ht, &gdbroot->db->h.subs_ht, NULL, NULL);
  if (gdbroot->subs_ht == NULL) errh_Bugcheck(*sts, "initiating subscription server hash table");

  gdbroot->sans_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.sans_ht, &gdbroot->db->h.sans_ht, NULL, NULL);
  if (gdbroot->sans_ht == NULL) errh_Bugcheck(*sts, "initiating subscribed alarm notification server hash table");

  gdbroot->ccvol_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.ccvol_ht, &gdbroot->db->h.ccvol_ht, NULL, NULL);
  if (gdbroot->ccvol_ht == NULL) errh_Bugcheck(*sts, "initiating cached class volume hash table");

  gdbroot->cclass_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.cclass_ht, &gdbroot->db->h.cclass_ht, NULL, NULL);
  if (gdbroot->cclass_ht == NULL) errh_Bugcheck(*sts, "initiating cached class hash table");

  gdbroot->sc_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.sc_ht, &gdbroot->db->h.sc_ht, NULL, NULL);
  if (gdbroot->sc_ht == NULL) errh_Bugcheck(*sts, "initiating sub class object hash table");

  gdbroot->catt_tt = ptree_Create(sts, gdbroot->pool, &gdbroot->t.catt_tt, &gdbroot->db->t.catt_tt,
				  compCatt);
  if (gdbroot->catt_tt == NULL) errh_Bugcheck(*sts, "initiating class attribute tree table");

  if (offsetof(sub_sClient, sid) != offsetof(sub_sServer, sid))
    errh_Bugcheck(GDH__WEIRD, "offset id: client - server");
  if (offsetof(sub_sClient, sid) != offsetof(dl_sLink, dlid))
    errh_Bugcheck(GDH__WEIRD, "offset id: client - dlink");
  if (offsetof(sub_sClient, subc_htl) != offsetof(sub_sServer, subs_htl))
    errh_Bugcheck(GDH__WEIRD, "offset htl: client - server");
  if (offsetof(sub_sClient, subc_htl) != offsetof(dl_sLink, subc_htl))
    errh_Bugcheck(GDH__WEIRD, "offset htl: client - dlink");
  if ((offsetof(gdb_sNobject, flags) - offsetof(gdb_sNobject, cid_ll)) 
      != (offsetof(gdb_sScObject, flags) - offsetof(gdb_sScObject, cid_ll)))
    errh_Bugcheck(GDH__WEIRD, "offset between cid_ll and flags in gdb_sNobject and gdb_sScObject");
  if (gdb_mNo_isSc != gdb_mSc_isSc)
    errh_Bugcheck(GDH__WEIRD, "gdb_mNo_isSubClass != gdb_mSc_isSubClass");

  return gdbroot;  
}