Ejemplo n.º 1
0
PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout)
{
    PRIntn rv;
    PRThread *thred = PR_CurrentThread();

    PR_ASSERT(cvar != NULL);
    /* We'd better be locked */
    PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));
    PR_ASSERT(PR_TRUE == cvar->lock->locked);
    /* and it better be by us */
    PR_ASSERT(pthread_equal(cvar->lock->owner, pthread_self()));

    if (_PT_THREAD_INTERRUPTED(thred)) goto aborted;

    /*
     * The thread waiting is used for PR_Interrupt
     */
    thred->waiting = cvar;  /* this is where we're waiting */

    /*
     * If we have pending notifies, post them now.
     *
     * This is not optimal. We're going to post these notifies
     * while we're holding the lock. That means on MP systems
     * that they are going to collide for the lock that we will
     * hold until we actually wait.
     */
    if (0 != cvar->lock->notified.length)
        pt_PostNotifies(cvar->lock, PR_FALSE);

    /*
     * We're surrendering the lock, so clear out the locked field.
     */
    cvar->lock->locked = PR_FALSE;

    if (timeout == PR_INTERVAL_NO_TIMEOUT)
        rv = pthread_cond_wait(&cvar->cv, &cvar->lock->mutex);
    else
        rv = pt_TimedWait(&cvar->cv, &cvar->lock->mutex, timeout);

    /* We just got the lock back - this better be empty */
    PR_ASSERT(PR_FALSE == cvar->lock->locked);
    cvar->lock->locked = PR_TRUE;
    cvar->lock->owner = pthread_self();

    PR_ASSERT(0 == cvar->lock->notified.length);
    thred->waiting = NULL;  /* and now we're not */
    if (_PT_THREAD_INTERRUPTED(thred)) goto aborted;
    if (rv != 0)
    {
        _PR_MD_MAP_DEFAULT_ERROR(rv);
        return PR_FAILURE;
    }
    return PR_SUCCESS;

aborted:
    PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
    thred->state &= ~PT_THREAD_ABORTED;
    return PR_FAILURE;
}  /* PR_WaitCondVar */
Ejemplo n.º 2
0
int
js_is_task_locked(JSTaskState *task)
{
    return (PR_CurrentThread() == js_owner_thread);
}
Ejemplo n.º 3
0
int
rdf_GetURL (MWContext *cx, int method, Net_GetUrlExitFunc *exit_routine, RDFFile rdfFile)
{
	MozillaEvent_rdf_GetURL		*event;
	URL_Struct      		*urls = NULL;
        char				*url;

#ifdef DEBUG_gagan
        return 0;
#endif

    if (cx == NULL)  return 0;
        if (rdfFile->refreshingp && rdfFile->updateURL) {
          url = rdfFile->updateURL;
        } else {
          url = rdfFile->url;
        }
        if (strcmp(url, gNavCntrUrl) == 0) {
          urls = NET_CreateURLStruct(url,  NET_CACHE_ONLY_RELOAD);
#ifdef NU_CACHE
          if (!CacheManager_Contains(url)) {
#else
          if (NET_IsURLInDiskCache(urls) || NET_IsURLInMemCache(urls)) {
          } else {
#endif
            NET_FreeURLStruct(urls);
            urls = NULL;
          }
        }
	if (!urls) 
          urls = NET_CreateURLStruct(url, (rdfFile->refreshingp ? 
                                           NET_SUPER_RELOAD : NET_NORMAL_RELOAD));
	if (urls == NULL) return 0;
	urls->fe_data = rdfFile;
	if (method) urls->method = method;

	if (PR_CurrentThread() == mozilla_thread)
	{
		htLoadBegins(urls, url);
		NET_GetURL(urls, FO_CACHE_AND_RDF, cx, rdf_GetUrlExitFunc);
	}
	else
	{
		/* send event to Mozilla thread */
		
		if (mozilla_event_queue == NULL)	return(0);
		event = PR_NEW(MozillaEvent_rdf_GetURL);
		if (event == NULL)	return(0);
		PR_InitEvent(&(event->ce.event), cx,
			(PRHandleEventProc)rdf_HandleEvent_GetURL,
			(PRDestroyEventProc)rdf_DisposeEvent_GetURL);
		event->url = copyString(url);
		event->urls = urls;
		event->method = FO_CACHE_AND_RDF;
		event->cx = cx;
		event->exitFunc = rdf_GetUrlExitFunc;
		PR_PostEvent(mozilla_event_queue, &(event->ce.event));
	}
	return 1;
}
#endif /* MOZILLA_CLIENT */



void
possiblyRereadRDFFiles (void* data)
{
	possiblyRefreshRDFFiles();
/*	timerID = FE_SetTimeout(possiblyRereadRDFFiles, NULL, 1000 * 60 * 10); 
	once every 10 minutes
	diabled for legal reasons.*/
}



void
RDFglueInitialize()
{
#ifdef MOZILLA_CLIENT

	timerID = FE_SetTimeout(possiblyRereadRDFFiles, NULL, 1000 * 60 * 10); /* once every 10 minutes */
	if (gRLForbiddenDomains != NULL)
	{
		freeMem(gRLForbiddenDomains);
		gRLForbiddenDomains = NULL;
	}
	if (PREF_CopyCharPref("browser.relatedLinksDisabledForDomains", &gRLForbiddenDomains) != PREF_OK)
	{
		gRLForbiddenDomains = NULL;
	}

#endif /* MOZILLA_CLIENT */
}