Ejemplo n.º 1
0
long WINAPI httpd_server_queue(void* param)
{
    static sHTTPSync* task;
    static HANDLE hThread;
    static DWORD  result;

    while(1)
    {
        if((result = WaitForSingleObject(svr_q_event,INFINITE)) == WAIT_OBJECT_0)
        {
            while(svr_q_tc < svr_max_clients)
            {
                svr_q_queue.Lock();
                task = (sHTTPSync*)svr_q_queue.m_head;

                if(!task)
                {
                    svr_q_queue.Unlock();
                    break;
                }
                else
                {
                    svr_q_queue.DelLocked(task);
                    svr_q_queue.Unlock();
                }

                if((DWORD)task->to < GetTickCount())
                {
                    closesocket((SOCKET)task->s);
                    my_memfree(task);
                }
                else
                {
                    svr_q_tc++;
                    hThread = CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)httpd_launch_client,(LPVOID)task->s,NULL,&result);

                    my_memfree(task);

                    if(!hThread)
                    {
                        svr_q_tc--;
                    }
                    else
                    {
                        CloseHandle(hThread);
                    }
                }//else
            }//while
        }//if
        else
        {
            return 0;
        }
    }//while(1)
    return 1;
}
Ejemplo n.º 2
0
VOID DlgFree(sDialog* dlg)
{
	if(dlg){
		while(dlg->lNum)
		{
			//DestroyWindow(dlg->table[dlg->lNum-1]->hWnd);
			my_memfree(dlg->table[dlg->lNum-1]);
			dlg->table[dlg->lNum-1] = NULL;
			dlg->lNum--;
		}
		my_memfree(dlg);
		//memset(dlg,0xAA,sizeof(sDialog));
	}
}
Ejemplo n.º 3
0
long WINAPI SysThread(sSysThreadHelper* p)
{
	lphp_vparam vp;
	mb_event mbe = {MBT_CALLBACK,0};
	char cb[32];

	mbe.php = p->php;
	strncpy(cb,p->cb,sizeof(cb)-1);

	//make a copy of vp
	vp = p->vp;

	if(vp.type == LPHP_STRING){
		vp.data = strdup((const char*)vp.data);
	}

	sman_incref(mbe.php);
	SetEvent(p->hEvent);

	MBMultiParam(mbe.php,cb,&mbe,"v",&vp);
	sman_decref(mbe.php);

	if(vp.type == LPHP_STRING){
		my_memfree(vp.data);
	}
	return 0;
}
void execute_choice(int choice)
{
    unsigned int size = 0;
    void *alloc = NULL;
    void *addr = NULL;
    int ret_val = 1;
    switch (choice)
    {
        case 1:
            printf("Enter the size of memory to be allocated(<%d): ",MAX_MEMORY);
            scanf("%u",&size);
            alloc = first_fit_alloc(size);

            if (NULL == alloc)
            {
                printf("Memory of size %u cannot be successfully allocated\n",size);
            }
            else
            {
                printf("Memory of size %u successfully allocated at address 0x%x\n", size, alloc);
            }
            break;

        case 2:
            printf("Enter the address of memory to be freed: ");
            scanf("%x",&addr);
            ret_val = my_memfree((void *)addr);

            if (0 == ret_val)
            {
                printf("Memory at address 0x%x cannot be freed\n ", addr);
            }
            else
            {
                printf("Memory at address 0x%x successfully freed\n ", addr);
            }
            break;

        case 3:
            display_free_list();
            break;

        case 4:
            display_busy_list();
            break;

        default:
            break;
    }
    return;    
}