int
main()
{
	int lock3,mv3,cv3;

	lock3 = CreateLock("lock3",5);
	cv3 = CreateCV("cv3",3);
	mv3 = CreateMV("mv3",3,5);

	WriteToConsole("\nAcquiring lock3 in rpcclient5\n\0", -1, -1, -1);
	if((Acquire("lock3",5)) == -1){
		WriteToConsole("Error acquiring lock3 in rpcclient5\n\0",-1,-1,-1);
		Exit(0);
	}

	if((Wait("cv3",3, "lock3",5)) == -1){
			WriteToConsole("Error waiting on cv3 and lock3 in rpcClient1\n\0",-1,-1,-1);
			Exit(0);
	}

	WriteToConsole("\nGot Signal on cv3 lock3 from rpcClient1\n\0", -1, -1, -1);
	WriteToConsole("\nValue of mv3 index 3 set by rpcClient1 is %d\n\0", GetMV("mv3",3,3), -1, -1);
	Release("lock3",5);

	DeleteLock("lock3",5);
	WriteToConsole(" Deleted Lock3\n\0",-1,-1,-1);
	DeleteMV("mv3",3);
	WriteToConsole(" Deleted MV3\n\0",-1,-1,-1);
	DeleteCV("cv3",3);
	WriteToConsole(" Deleted CV3\n\0",-1,-1,-1);

	Exit(0);
}
Exemple #2
0
// Release the NAT
void NiFreeNat(NAT *n)
{
	// Validate arguments
	if (n == NULL)
	{
		return;
	}

	// Complete management command
	//NiFreeAdminAccept(n);

	// Stop if the virtual host is running
	Lock(n->lock);
	{
		if (n->Virtual != NULL)
		{
			StopVirtualHost(n->Virtual);
			ReleaseVirtual(n->Virtual);
			n->Virtual = NULL;
		}
	}
	Unlock(n->lock);

	// Release the settings
	NiFreeConfig(n);

	// Delete the object
	ReleaseCedar(n->Cedar);
	ReleaseEvent(n->HaltEvent);
	DeleteLock(n->lock);

	Free(n);
}
Exemple #3
0
/*
 * End segment manager
 */
EXPORT ER finish_segmgr( void )
{
	ER	ercd, ret = E_OK;

	/* Finish system exception manager */
	ercd = finish_excmgr();
	if ( ercd < E_OK ) {
		ret = ercd;
	}

	/* Delete subsystem registration */
	ercd = tk_def_ssy(SEG_SVC, NULL);
	if ( ercd < E_OK ) {
		ret = ercd;
	}

	/* Remove segment manager lock */
	DeleteLock(&SegLock);

#ifdef DEBUG
	if ( ret < E_OK ) {
		TM_DEBUG_PRINT(("finish_segmgr ercd = %d\n", ret));
	}
#endif
	return ret;
}
void ShardLockManager::OnRemoveCachedLocks()
{
    uint64_t    now;
    ShardLock*  lock;

    now = EventLoop::Now();

    FOREACH_FIRST(lock, lockCacheList)
    {
        // should be unlocked
        ASSERT(!lock->locked);
        // session should be NULL
        ASSERT(lock->session == NULL);
        // not in lock expiry list
        ASSERT(lock->listExpiryNode.next == lock);
        // not in lock pool list
        ASSERT(lock->listPoolNode.next == lock);
        // in tree
        ASSERT(lock->treeNode.IsInTree());

        if (lock->unlockTime < now || lockCacheList.GetLength() > maxCacheCount)
        {
            lockTree.Remove(lock);
            lockCacheList.Remove(lock);
            DeleteLock(lock);
        }
        else
            break;
    }
Exemple #5
0
// Clean-up the L3 switch
void CleanupL3Sw(L3SW *s)
{
	UINT i;
	// Validate arguments
	if (s == NULL)
	{
		return;
	}

	for (i = 0;i < LIST_NUM(s->IfList);i++)
	{
		L3IF *f = LIST_DATA(s->IfList, i);
		Free(f);
	}
	ReleaseList(s->IfList);

	for (i = 0;i < LIST_NUM(s->TableList);i++)
	{
		L3TABLE *t = LIST_DATA(s->TableList, i);
		Free(t);
	}
	ReleaseList(s->TableList);

	DeleteLock(s->lock);
	Free(s);
}
Exemple #6
0
// Cleanup the user object 
void CleanupUser(USER *u)
{
	// Validate arguments
	if (u == NULL)
	{
		return;
	}

	DeleteLock(u->lock);
	Free(u->Name);
	Free(u->RealName);
	Free(u->Note);
	Free(u->GroupName);
	if (u->Group != NULL)
	{
		ReleaseGroup(u->Group);
	}

	// Free authntication data
	FreeAuthData(u->AuthType, u->AuthData);

	if (u->Policy)
	{
		// Free policy data
		Free(u->Policy);
	}

	FreeTraffic(u->Traffic);

	Free(u);
}
Exemple #7
0
// Release the dynamic listener
void FreeDynamicListener(DYNAMIC_LISTENER *d)
{
	// Validate arguments
	if (d == NULL)
	{
		return;
	}

	Lock(d->Lock);
	{
		if (d->Listener != NULL)
		{
			StopListener(d->Listener);
			ReleaseListener(d->Listener);
			d->Listener = NULL;
		}
	}
	Unlock(d->Lock);

	ReleaseCedar(d->Cedar);

	DeleteLock(d->Lock);

	Free(d);
}
void main()
{
	int lck1,cv1;
	
	Print("\nTC1_1 :: Checking Correct Working of Creating & Deleting of Locks and CV.\n",1,1,1);

	lck1 = CreateLock("lock1", 5);			
	Print("\nTC1_1 :: Lock name 'lock1' Created. The Index is '%d'.\n",lck1,1,1);
	
	cv1 = CreateCV("cv1", 3);				
	Print("\nTC1_1 :: CV name 'cv1' Created. The Index is '%d'.\n",cv1,1,1);
	
	Acquire(lck1);							
	
	Print("\nTC1_1 :: Going on wait on 'cv1' using 'lock1'. Now run the 'tc1_2' file.\n",1,1,1);
	Wait(cv1,lck1);
	Print("\nTC1_1 :: Have been signalled on 'cv1' using 'lock1'.\n",1,1,1);

	Release(lck1);							

	DeleteCV(cv1);						

	DeleteLock(lck1);	
	
	Print("\nTC1_1 :: Reached end.\n",lck1,1,1);
	Exit(0);
}
Exemple #9
0
// Release of the Tick64
void FreeTick64()
{
	UINT i;
	if (tk64 == NULL)
	{
		// Uninitialized
		return;
	}

	// Termination process
	tk64->Halt = true;
	Set(halt_tick_event);
	WaitThread(tk64->Thread, INFINITE);
	ReleaseThread(tk64->Thread);

	// Releasing process
	for (i = 0;i < LIST_NUM(tk64->AdjustTime);i++)
	{
		ADJUST_TIME *t = LIST_DATA(tk64->AdjustTime, i);
		Free(t);
	}
	ReleaseList(tk64->AdjustTime);
	DeleteLock(tk64->TickLock);
	Free(tk64);
	tk64 = NULL;

	ReleaseEvent(halt_tick_event);
	halt_tick_event = NULL;
}
void main()
{
    int lck1,cv1;

    Print("\nTC1_2 :: Checking Correct Working of Creating & Deleting of Locks and CV.\n",1,1,1);

    lck1 = CreateLock("lock1", 5);
    Print("\nTC1_2 :: Lock name 'lock1' Created. The Index is '%d'.\n",lck1,1,1);

    cv1 = CreateCV("cv1", 3);
    Print("\nTC1_2 :: CV name 'cv1' Created. The Index is '%d'.\n",cv1,1,1);

    Acquire(lck1);

    Print("\nTC1_2 :: Going to signal on 'cv1'. The waiter on 'cv1' will be woken up.\n",1,1,1);
    Signal(cv1,lck1);


    Release(lck1);

    DeleteCV(cv1);

    DeleteLock(lck1);

    Print("\nTC1_2 :: Reached end.\n",lck1,1,1);
    Exit(0);
}
Exemple #11
0
// Close the secure device
void CloseSec(SECURE *sec)
{
	// Validate arguments
	if (sec == NULL)
	{
		return;
	}

	// Log out
	LogoutSec(sec);

	// Close the session
	CloseSecSession(sec);

	// Release the token information
	FreeSecInfo(sec);

	// Release of the slot list memory
	if (sec->SlotIdList != NULL)
	{
		Free(sec->SlotIdList);
		sec->SlotIdList = NULL;
	}

	// Unload the module
	FreeSecModule(sec);

	// Memory release
	DeleteLock(sec->lock);
	Free(sec);
}
void main()
{
	int lck1,cv1=-1,lck2;
	
	Print("\nTC5_1 :: Checking Working of Wait and Signal. \n",1,1,1);

	lck1 = CreateLock("lock1", 5);			
	Print("\nTC5_1 :: Lock name 'lock1' Created. The Index is '%d'.\n",lck1,1,1);

	Acquire(lck1);							
	
	Print("\nTC5_1 :: Going on wait on 'cv1' that is not created using 'lock1'. Will not go on wait.\n",1,1,1);
	Wait(cv1,lck1);
	Print("\nERROR - TC5_1 :: Could not go on wait on 'cv1' using 'lock1'.\n",1,1,1);

	cv1 = CreateCV("cv1", 3);				
	Print("\nTC5_1 :: CV name 'cv1' Created. The Index is '%d'.\n",cv1,1,1);
	
	Print("\nTC5_1 :: Going on wait on 'cv1' that is now created using 'lock1'. Now run the 'tc5_2' file.\n",1,1,1);
	Wait(cv1,lck1);
	Print("\nTC5_1 :: Have been signalled on 'cv1' using 'lock1'.\n",1,1,1);

	Release(lck1);							

	DeleteCV(cv1);						

	DeleteLock(lck1);						
	
	Print("\nTC5_1 :: Reached end.\n",lck1,1,1);
	Exit(0);
}
void main()
{
	int lck1,cv1,lck2;
	
	Print("\nTC6_1 :: Checking Working of Wait and Signal. \n",1,1,1);

	lck1 = CreateLock("lock1", 5);			
	Print("\nTC6_1 :: Lock name 'lock1' Created. The Index is '%d'.\n",lck1,1,1);

	cv1 = CreateCV("cv1", 3);				
	Print("\nTC6_1 :: CV name 'cv1' Created. The Index is '%d'.\n",cv1,1,1);
	
	Acquire(lck1);												

	Print("\nTC6_1 :: Going on wait on 'cv1' using 'lock1' that is the correct lock (First Waiter). Will go on wait. Now run the 'tc6_2' file. \n",1,1,1);
	Wait(cv1,lck1);
	Print("\nTC6_1 :: Have been Signalled on 'cv1' using 'lock2'.\n",1,1,1);

	Release(lck1);							

	DeleteCV(cv1);						

	DeleteLock(lck1);						

	Print("\nTC6_1 :: Reached end.\n",lck1,1,1);
	Exit(0);
}
Exemple #14
0
// NAT の解放
void NiFreeNat(NAT *n)
{
	// 引数チェック
	if (n == NULL)
	{
		return;
	}

	// 管理コマンド終了
	//NiFreeAdminAccept(n);

	// 仮想ホストが動作中の場合は停止
	Lock(n->lock);
	{
		if (n->Virtual != NULL)
		{
			StopVirtualHost(n->Virtual);
			ReleaseVirtual(n->Virtual);
			n->Virtual = NULL;
		}
	}
	Unlock(n->lock);

	// 設定の解放
	NiFreeConfig(n);

	// オブジェクトの削除
	ReleaseCedar(n->Cedar);
	ReleaseEvent(n->HaltEvent);
	DeleteLock(n->lock);

	Free(n);
}
Exemple #15
0
/*
 * Calendar functions entry
 */
EXPORT	ER	dt_main(INT ac, UB* av[])
{
	ER	er;
	T_DSSY	dssy;

	if (ac < 0) {
		/* Stop other tasks from executing SVC */
		Lock(&dtLock);

		/* Unregister subsystem */
		tk_def_ssy(DT_SVC, NULL);

		/* Delete lock */
		DeleteLock(&dtLock);
		return E_OK;
	}

	/* Create lock */
	er = CreateLock(&dtLock, "dtLk");
	if (er < E_OK) {
		goto err_ret0;
	}

	/* Register subsystem */
	dssy.ssyatr	= TA_NULL;
	dssy.ssypri	= DT_PRI;
	dssy.svchdr	= (FP)svcEntry;
	dssy.breakfn	= NULL;
	dssy.startupfn	= NULL;
	dssy.cleanupfn	= NULL;
	dssy.eventfn	= NULL;
	dssy.resblksz	= 0;
	er = tk_def_ssy(DT_SVC, &dssy);
	if (er < E_OK) {
		goto err_ret1;
	}

	return E_OK;

err_ret1:
	DeleteLock(&dtLock);
	
err_ret0:
	return er;
}
Exemple #16
0
// Release of the string library
void FreeStringLibrary()
{
	// Release of the International Library
	FreeInternational();

	// Release of the lock for token
	DeleteLock(token_lock);
	token_lock = NULL;
}
Exemple #17
0
// 文字列ライブラリの解放
void FreeStringLibrary()
{
	// 国際ライブラリの解放
	FreeInternational();

	// トークン用ロックの解放
	DeleteLock(token_lock);
	token_lock = NULL;
}
int
main()
{
	int lock2, cv2, mv2;

	if((lock2 = CreateLock("lock2",5)) == -1){
		WriteToConsole("Error Creating lock2 in rpcClient4\n\0",-1,-1,-1);
		Exit(0);
	}
	WriteToConsole("lock2 created in rpcClient4 with lockid: %d\n\0",lock2,-1,-1);
	
	WriteToConsole("cv1 created in rpcClient4 with CVid: %d\n\0",cv2,-1,-1);
	if((cv2 = CreateCV("cv2", 3)) == -1){
		WriteToConsole("Error Creating CV2 in rpcClient4\n\0",-1,-1,-1);
		Exit(0);
	}
	WriteToConsole("cv2 created in rpcClient4 with CVid: %d\n\0",cv2,-1,-1);
	
	if((mv2 = CreateMV("mv2", 3, 5)) == -1){
		WriteToConsole("Error Creating MV2 in rpcClient2\n\0",-1,-1,-1);
		Exit(0);
	}
	WriteToConsole("mv2 created in rpcClient2 with MVid: %d\n\0",mv2,-1,-1);
	
	if((Acquire(lock2)) == -1){
		WriteToConsole("Error acquiring lock2 with id:%d in rpcClient4\n\0",lock2,-1,-1);
		Exit(0);
	}
	WriteToConsole("\nAcquired lock2: %d\n\0", lock2, -1, -1);
	WriteToConsole("\nValue of MV2 index 0 set by rpcClient4 is %d\n\0", GetMV(mv2,0), -1, -1);
	
	if((SetMV(mv2, 1, 5)) == -1){
		WriteToConsole("Error setting mv2 in rpcClient4\n\0",-1,-1,-1);
		Exit(0);
	}
	WriteToConsole("\nMV2 index: 1 set to 5 by rpcClient4\n\0", -1, -1, -1);
	
	WriteToConsole("\nSignalling on CV2 Lock2 to rpcClient1\n\0", -1, -1, -1);
	if((Signal(cv2, lock2)) == -1){
		WriteToConsole("Error signalling on cv2 and lock2 in rpcClient4\n\0",-1,-1,-1);
		Exit(0);
	}
	if((Release(lock2)) == -1){
		WriteToConsole("Error releasing lock2 with id:%d in rpcClient1\n\0",lock2,-1,-1);
		Exit(0);
	}
	WriteToConsole("\nReleased lock2: %d\n\0", lock2, -1, -1);

	DeleteLock(lock2);
	WriteToConsole("Sent DeletLock Request id: %d\n\0",lock2,-1,-1);
	DeleteCV(cv2);
	WriteToConsole("Sent DeletCV Request id: %d\n\0",cv2,-1,-1);
	DeleteMV(mv2);
	WriteToConsole("Sent DeleteMV Request id: %d\n\0",mv2,-1,-1);
	Exit(0);
}
Exemple #19
0
// Release the NtXxx function
void NtFree()
{
	if (nat_lock == NULL)
	{
		return;
	}

	DeleteLock(nat_lock);
	nat_lock = NULL;
}
void fun1()
{
	WriteToConsole("In Function 1 - user prog 1\n\0",-1,-1,-1);
	Acquire(lockid);
	WriteToConsole("\nIn user prog1 fun1 - x: %d\n\0", x, -1, -1);
	Release(lockid);
	DeleteLock(lockid);
	WriteToConsole("\nDeleted Lock Id: %d\n\0", lockid, -1, -1);
	Exit(0);
}
Exemple #21
0
// Close tiny log
void FreeTinyLog(TINY_LOG *t)
{
	// Validate arguments
	if (t == NULL)
	{
		return;
	}

	FileClose(t->io);
	DeleteLock(t->Lock);
	Free(t);
}
void main()
{
	int lck1=1, lck2=2;
													Print("\n Checking Wrong Working of Releaseing of Locks. \n\0",1,1,1);

	lck1 = CreateLock("lock1", 5);					Print("\n lck1 Has Been Created in testCase_5. \n\0",1,1,1);
	lck2 = CreateLock("lock2", 5);					Print("\n lck2 Has Been Created in testCase_5. \n\0",1,1,1);

	Acquire(lck1);									Print("\n lck1 Has Been Acquired in testCase_5. \n\0",1,1,1);
	Acquire(lck2);									Print("\n lck2 Has Been Acquired in testCase_5. \n\0",1,1,1);

	Release(lck1);									Print("\n lck1 Has Been Released in testCase_5. \n\0",1,1,1);
	Release(lck2);									Print("\n lck2 Has Been Released in testCase_5. \n\0",1,1,1);

	DeleteLock(lck1);								Print("\n lck1 Has Been Deleted in testCase_5. \n\0",1,1,1);
	DeleteLock(lck2);								Print("\n lck2 Has Been Deleted in testCase_5. \n\0",1,1,1);

													Print("\n Error Should Print That lck2 Does Not Exist. \n\0",1,1,1);
	Release(lck2);							
	
	Exit(0);
}
Exemple #23
0
// Release and stop the IPsec server
void FreeIPsecServer(IPSEC_SERVER *s)
{
	UINT i;
	IPSEC_SERVICES sl;
	// Validate arguments
	if (s == NULL)
	{
		return;
	}

	s->NoMoreChangeSettings = true;

	// Stopp the L2TP server
	StopL2TPServer(s->L2TP, false);

	// Stop the IKE server
	StopIKEServer(s->Ike);

	// Stop all the services explicitly
	Zero(&sl, sizeof(sl));
	IPsecServerSetServices(s, &sl);

	// Releasing process
	FreeUdpListener(s->UdpListener);

	ReleaseCedar(s->Cedar);

	FreeL2TPServer(s->L2TP);

	FreeIKEServer(s->Ike);

	for (i = 0;i < LIST_NUM(s->EtherIPIdList);i++)
	{
		ETHERIP_ID *k = LIST_DATA(s->EtherIPIdList, i);

		Free(k);
	}

	ReleaseList(s->EtherIPIdList);

	// Stop the OS monitoring thread
	s->Halt = true;
	Set(s->OsServiceCheckThreadEvent);
	WaitThread(s->OsServiceCheckThread, INFINITE);
	ReleaseThread(s->OsServiceCheckThread);
	ReleaseEvent(s->OsServiceCheckThreadEvent);

	DeleteLock(s->LockSettings);

	Free(s);
}
Exemple #24
0
// Release the UDP acceleration function
void FreeUdpAccel(UDP_ACCEL *a)
{
	// Validate arguments
	if (a == NULL)
	{
		return;
	}

	while (true)
	{
		BLOCK *b = GetNext(a->RecvBlockQueue);

		if (b == NULL)
		{
			break;
		}

		FreeBlock(b);
	}

	ReleaseQueue(a->RecvBlockQueue);

	ReleaseSock(a->UdpSock);

	if (a->IsInCedarPortList)
	{
		LockList(a->Cedar->UdpPortList);
		{
			DelInt(a->Cedar->UdpPortList, a->MyPort);
		}
		UnlockList(a->Cedar->UdpPortList);
	}

	// Release of NAT-T related
	a->NatT_Halt = true;
	Set(a->NatT_HaltEvent);

	if (a->NatT_GetIpThread != NULL)
	{
		WaitThread(a->NatT_GetIpThread, INFINITE);
		ReleaseThread(a->NatT_GetIpThread);
	}

	ReleaseEvent(a->NatT_HaltEvent);
	DeleteLock(a->NatT_Lock);

	ReleaseCedar(a->Cedar);

	Free(a);
}
Exemple #25
0
// RPC の解放
void RpcFree(RPC *rpc)
{
	// 引数チェック
	if (rpc == NULL)
	{
		return;
	}

	Disconnect(rpc->Sock);
	ReleaseSock(rpc->Sock);

	DeleteLock(rpc->Lock);

	Free(rpc);
}
Exemple #26
0
// Delete the counter
void DeleteCounter(COUNTER *c)
{
	// Validate arguments
	if (c == NULL)
	{
		return;
	}

	// KS
	KS_INC(KS_DELETE_COUNTER_COUNT);
	KS_SUB(KS_CURRENT_COUNT, c->c);

	DeleteLock(c->lock);
	Free(c);
}
Exemple #27
0
// Release the RPC
void RpcFree(RPC *rpc)
{
	// Validate arguments
	if (rpc == NULL)
	{
		return;
	}

	Disconnect(rpc->Sock);
	ReleaseSock(rpc->Sock);

	DeleteLock(rpc->Lock);

	Free(rpc);
}
Exemple #28
0
// Close the configuration file R/W
void FreeCfgRw(CFG_RW *rw)
{
	// Validate arguments
	if (rw == NULL)
	{
		return;
	}

	if (rw->Io != NULL)
	{
		FileClose(rw->Io);
	}

	DeleteLock(rw->lock);
	Free(rw->FileNameW);
	Free(rw->FileName);
	Free(rw);
}
// Free VPN Azure client
void FreeAzureClient(AZURE_CLIENT *ac)
{
	SOCK *disconnect_sock = NULL;
	// Validate arguments
	if (ac == NULL)
	{
		return;
	}

	ac->Halt = true;

	Lock(ac->Lock);
	{
		if (ac->CurrentSock != NULL)
		{
			disconnect_sock = ac->CurrentSock;

			AddRef(disconnect_sock->ref);
		}
	}
	Unlock(ac->Lock);

	if (disconnect_sock != NULL)
	{
		Disconnect(disconnect_sock);
		ReleaseSock(disconnect_sock);
	}

	Set(ac->Event);

	// Stop main thread
	WaitThread(ac->MainThread, INFINITE);
	ReleaseThread(ac->MainThread);

	ReleaseEvent(ac->Event);

	DeleteLock(ac->Lock);

	Free(ac);
}
Exemple #30
0
// Release of DDNS client
void FreeDDNSClient(DDNS_CLIENT *c)
{
	// Validate arguments
	if (c == NULL)
	{
		return;
	}

	// Stop the thread 
	c->Halt = true;
	Set(c->Event);

	WaitThread(c->Thread, INFINITE);
	ReleaseThread(c->Thread);

	ReleaseEvent(c->Event);

	ReleaseCedar(c->Cedar);
	DeleteLock(c->Lock);

	Free(c);
}