SuperHashTable::~SuperHashTable()
{
    doKill();
#ifdef TRACE_HASH
    dumpStats();
#endif
}
Exemple #2
0
bool KJob::kill( KillVerbosity verbosity )
{
    Q_D(KJob);
    if ( doKill() )
    {
        setError( KilledJobError );

        if ( verbosity!=Quietly )
        {
            emitResult();
        }
        else
        {
            // If we are displaying a progress dialog, remove it first.
            d->isFinished = true;
            emit finished(this);

            if ( isAutoDelete() )
                deleteLater();
        }

        return true;
    }
    else
    {
        return false;
    }
}
void SuperHashTable::kill(void)
{
    releaseAll();
    doKill();
    tablesize = InitialTableSize;
    tablecount = 0;
    setCache(0);
    table = (void * *) checked_malloc(InitialTableSize*sizeof(void *),-604);
    memset(table,0,InitialTableSize*sizeof(void *));
}
Exemple #4
0
void KrPreviewJob::removeItem(KrViewItem *item)
{
    setTotalAmount(KJob::Files, totalAmount(KJob::Files) - _scheduled.removeAll(item));
    if(_job) {
        doKill();
        if(!_scheduled.isEmpty())
            _timer.start();
    }
    if(_scheduled.isEmpty())
        emitResult();
}
void SuperHashTable::kill(void)
{
    _releaseAll();
    if (tablesize != InitialTableSize)
    {
        doKill();
        tablesize = InitialTableSize;
        table = (void * *)checked_malloc(InitialTableSize*sizeof(void *), -604);
        memset(table, 0, InitialTableSize*sizeof(void *));
    }
}
void AllMessagesListJob::jobFinished(KJob *kjob)
{
    MessagesListJob *job = dynamic_cast<MessagesListJob *>(kjob);
    Q_ASSERT(job);

    if (!job) return;
    m_jobs.removeAll(job);

    if (job->error()) {
        setError(job->error());
        setErrorText(job->errorText());
        kWarning() << "Job error: " << job->errorString();
        return;
    }

    d->list.append(job->list());

    int out = job->out(); // incoming or outgoing
    Q_ASSERT(out == 0 || out == 1);
    // If this was the first job, start all others
    if (d->totalCount[out] == -1)
    {
        d->totalCount[out] = job->totalCount();
        for (int offset = 100; offset < d->totalCount[out]; offset += 100)
            startNewJob(offset, qMin(100, d->totalCount[out] - offset), out);
    }
    else if (d->totalCount[out] != job->totalCount())
    {
        // TODO: some new messages might have been added, what should we do then?
        doKill();
        setError(KJob::UserDefinedError + 2);
        if (out == 1)
        {
            setErrorText(i18n("The number of outgoing messages has changed between requests."));
        }
        else // out == 0
        {
            setErrorText(i18n("The number of incoming messages has changed between requests."));
        }

        kWarning() << "Job error: " << job->errorString();
        emitResult();
        return;
    }

    // All jobs have finished
    if (m_jobs.size() == 0)
    {
        qSort(d->list); // sort by message ID (which should be equivalent to sorting by date)
        emitResult();
    }
}
SuperHashTable::~SuperHashTable()
{
    doKill();
}
void SuperHashTable::reinit(unsigned initsize)
{
    doKill();
    init(initsize);
}
Exemple #9
0
KrPreviewJob::~KrPreviewJob()
{
    doKill();
}
void paraNode()
/* paraNode - a net server. */
{
char *line;
char *command;
struct sockaddr_in sai;

/* We have to know who we are... */
hostName = getMachine();
initRandom();
getTicksToHundreths();

/* log init */
if (optionExists("log"))
    logOpenFile("paraNode", optionVal("log", NULL));
else    
    logOpenSyslog("paraNode", optionVal("logFacility", NULL));
logSetMinPriority(optionVal("logMinPriority", "info"));
logInfo("starting paraNode on %s", hostName);

/* Make job lists. */
jobsRunning = newDlList();
jobsFinished = newDlList();

/* Set up socket and self to listen to it. */
ZeroVar(&sai);
sai.sin_family = AF_INET;
sai.sin_port = htons(paraNodePort);
sai.sin_addr.s_addr = INADDR_ANY;
mainRudp = rudpMustOpenBound(&sai);
mainRudp->maxRetries = 12;

/* Event loop. */
findNow();
for (;;)
    {
    /* Get next incoming message and optionally check to make
     * sure that it's from a host we trust, and check signature
     * on first bit of incoming data. */
    if (pmReceive(&pmIn, mainRudp))
	{
	findNow();
	if (hubName == NULL || ntohl(pmIn.ipAddress.sin_addr.s_addr) == hubIp 
		|| ntohl(pmIn.ipAddress.sin_addr.s_addr) == localIp)
	    {
	    /* Host and signature look ok,  read a string and
	     * parse out first word as command. */
	    line = pmIn.data;
	    logDebug("message from %s: \"%s\"",
                     paraFormatIp(ntohl(pmIn.ipAddress.sin_addr.s_addr)),
                     line);
	    command = nextWord(&line);
	    if (command != NULL)
		{
		if (sameString("quit", command))
		    break;
		else if (sameString("run", command))
		    doRun(line, &pmIn.ipAddress);
		else if (sameString("jobDone", command))
		    jobDone(line);
		else if (sameString("status", command))
		    doStatus();
		else if (sameString("kill", command))
		    doKill(line);
		else if (sameString("check", command))
		    doCheck(line, &pmIn.ipAddress);
		else if (sameString("resurrect", command))
		    doResurrect(line, &pmIn.ipAddress);
		else if (sameString("listJobs", command))
		    listJobs();
		else if (sameString("fetch", command))
		    doFetch(line);
                else
                    logWarn("invalid command: \"%s\"", command);
		}
	    logDebug("done command");
	    }
	else
	    {
	    logWarn("command from unauthorized host %s",
                    paraFormatIp(ntohl(pmIn.ipAddress.sin_addr.s_addr)));
	    }
	}
    }
rudpClose(&mainRudp);
}
tpGLRenderSurfaceWin32::~tpGLRenderSurfaceWin32()
{
	tpLogNotify("%s destroy window",__FUNCTION__);
	doKill();
}
void tpGLRenderSurfaceWin32::doCreate() {

	_classname.format("tpGLRenderSurface_%d",++__tempwnd_id);

	_instance = GetModuleHandle(NULL);

	WNDCLASS wndclass;

#if defined(WINCE)
	wndclass.style			= CS_HREDRAW | CS_VREDRAW;
	wndclass.lpfnWndProc	= (WNDPROC) WndProc;
	wndclass.cbClsExtra		= 0;
	wndclass.cbWndExtra		= 0;
	wndclass.hInstance		= _instance;
	wndclass.hIcon			= 0;
	wndclass.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wndclass.hbrBackground	= (HBRUSH) GetStockObject(WHITE_BRUSH);
	wndclass.lpszMenuName	= 0;
	wndclass.lpszClassName	= _classname.mb_str();	
#else 
	wndclass.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; 
	wndclass.lpfnWndProc   = (WNDPROC) WndProc;//DefWindowProc;
	wndclass.cbClsExtra    = 0;
	wndclass.cbWndExtra    = 0;
	wndclass.hInstance     = _instance;
	wndclass.hCursor       = 0;
	wndclass.hIcon         = 0;
	wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wndclass.lpszMenuName  = 0;                            
	wndclass.lpszClassName = _classname.mb_str();
#endif

	if (!RegisterClass(&wndclass))
		return;

#if !defined(WINCE)
	if (!(_handle = CreateWindowEx( 0,
		_classname.mb_str(),
		_classname.mb_str(),
		WS_BORDER | WS_CAPTION | WS_POPUP, //WS_POPUP is good for fullscreen
		40,
		40,
		640,
		480,
		0,
		0,
		_instance,
		0)))
	{
		doKill();
		return;
	}
#else

	_handle = CreateWindow(
		_classname.mb_str(), 
		_T("Window"), 
		WS_VISIBLE,
		CW_USEDEFAULT, 
		CW_USEDEFAULT, 
		CW_USEDEFAULT, 
		CW_USEDEFAULT, 
		NULL, 
		NULL, 
		_instance, 
		NULL);

	if (!_handle)
	{	
		doKill();
		return;
	}
#endif

	if (!(_dc = GetDC(_handle)))
	{
		tpLogError("%s could not create a DC",__FUNCTION__);
		doKill();
		return;
	}

#if defined(WINCE)
	/* EGL aliases */
#define EGL_FALSE			0
#define EGL_TRUE			1

	/* Out-of-band handle values */
	/* These values may vary depending on semantics of native concepts */
#define EGL_DEFAULT_DISPLAY		((void *)0)
#define EGL_NO_CONTEXT			((EGLContext)0)
#define EGL_NO_DISPLAY			((EGLDisplay)0)
#define EGL_NO_SURFACE			((EGLSurface)0)

	/* Config attributes */
#define EGL_BUFFER_SIZE			0x3020
#define EGL_ALPHA_SIZE			0x3021
#define EGL_BLUE_SIZE			0x3022
#define EGL_GREEN_SIZE			0x3023
#define EGL_RED_SIZE			0x3024
#define EGL_DEPTH_SIZE			0x3025
#define EGL_STENCIL_SIZE		0x3026
#define EGL_CONFIG_CAVEAT		0x3027
#define EGL_CONFIG_ID			0x3028
#define EGL_LEVEL			0x3029
#define EGL_MAX_PBUFFER_HEIGHT		0x302A
#define EGL_MAX_PBUFFER_PIXELS		0x302B
#define EGL_MAX_PBUFFER_WIDTH		0x302C
#define EGL_NATIVE_RENDERABLE		0x302D
#define EGL_NATIVE_VISUAL_ID		0x302E
#define EGL_NATIVE_VISUAL_TYPE		0x302F
#define EGL_PRESERVED_RESOURCES		0x3030
#define EGL_SAMPLES			0x3031
#define EGL_SAMPLE_BUFFERS		0x3032
#define EGL_SURFACE_TYPE		0x3033
#define EGL_TRANSPARENT_TYPE		0x3034
#define EGL_TRANSPARENT_BLUE_VALUE	0x3035
#define EGL_TRANSPARENT_GREEN_VALUE	0x3036
#define EGL_TRANSPARENT_RED_VALUE	0x3037
#define EGL_NONE			0x3038	/* Attrib list terminator */
#define EGL_BIND_TO_TEXTURE_RGB		0x3039
#define EGL_BIND_TO_TEXTURE_RGBA	0x303A
#define EGL_MIN_SWAP_INTERVAL		0x303B
#define EGL_MAX_SWAP_INTERVAL		0x303C
#define EGL_LUMINANCE_SIZE		0x303D
#define EGL_ALPHA_MASK_SIZE		0x303E
#define EGL_COLOR_BUFFER_TYPE		0x303F
#define EGL_RENDERABLE_TYPE		0x3040


	static EGLint const attribute_list[] = {
		EGL_RED_SIZE, 1,
		EGL_GREEN_SIZE, 1,
		EGL_BLUE_SIZE, 1,
		EGL_NONE
	};

	/* get an EGL display connection */
	display = tpGL::eglGetDisplay((NativeDisplayType)EGL_DEFAULT_DISPLAY);

	/* initialize the EGL display connection */
	tpGL::eglInitialize(display, NULL, NULL);

	/* get an appropriate EGL frame buffer configuration */
	tpGL::eglChooseConfig(display, attribute_list, &config, 1, &num_config);

	/* create an EGL rendering context */
	context = tpGL::eglCreateContext(display, config, EGL_NO_CONTEXT, NULL);

	if (_handle) {
		/* create an EGL window surface */
		surface = tpGL::eglCreateWindowSurface(display, config, _handle, NULL);

	}

#else

	PIXELFORMATDESCRIPTOR pfd = { 
		sizeof(PIXELFORMATDESCRIPTOR),
		1,                     
		PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL,      
		PFD_TYPE_RGBA,         
		32,                    
		0, 0, 0, 0, 0, 0,      
		0,                     
		0,                     
		0,                     
		0, 0, 0, 0,            
		16,	// < depth
		0,                     
		0,                     
		PFD_MAIN_PLANE,        
		0,                     
		0, 0, 0                
	};

	tpGL gl;

	int visual_id = ChoosePixelFormat(_dc, &pfd); 

	if (!SetPixelFormat(_dc, visual_id, &pfd))
	{
		tpLogError("%s pixel format not supported",__FUNCTION__);

		doKill();
		return;
	}

	if (!(_context = tpGL::CreateContext(_dc)))
	{
		tpLogError("%s could not create GL context",__FUNCTION__);
		doKill();
		return;
	}

#endif

	tpLogNotify("%s created window",__FUNCTION__);
}