示例#1
0
static GError *
_resolve_m1_through_one_m0(const gchar *m0, const guint8 *prefix, gchar ***result)
{
	GError *err = NULL;
	struct addr_info_s ai;

	GRID_TRACE2("%s(%s,%02X%02X)", __FUNCTION__, m0, prefix[0], prefix[1]);
	meta1_strurl_get_address(m0, &ai);

	do {
		GSList *lmap = meta0_remote_get_meta1_one(&ai,
				_timeout(&rc_resolver_timeout_m0, 30.0), prefix, &err);
		if (!lmap) {
			if (err)
				return err;
			return NEWERROR(500, "No meta1 found");
		}
		else {
			*result = _m0list_to_urlv(lmap);
			g_slist_foreach(lmap, meta0_info_gclean, NULL);
			g_slist_free(lmap);
			err = NULL;
		}
	} while (0);

	return err;
}
示例#2
0
PmTimer::PmTimer()
    : _minimumInterval(-1), _maximumInterval(-1)
{
    IFDEBUG(qDebug() << "PmTimerUShort::constructor");
    connect(&_timer, SIGNAL(error(QSystemAlignedTimer::AlignedTimerError)), this, SLOT(_error(QSystemAlignedTimer::AlignedTimerError)));
    connect(&_timer, SIGNAL(timeout()), this, SLOT(_timeout()));
}
示例#3
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB__CLSVSSL_HDTMOUT, "_clsVSSilence::handleTimeout" )
   void _clsVSSilence::handleTimeout( const UINT32 &millisec,
                                      INT32 &next )
   {
      PD_TRACE_ENTRY ( SDB__CLSVSSL_HDTMOUT ) ;
      _timeout() += millisec ;

      if ( pmdGetOptionCB()->sharingBreakTime() + 1000 <= _timeout() )
      {
         next = CLS_ELECTION_STATUS_SEC ;
         goto done ;
      }
      next = id() ;
   done:
      PD_TRACE_EXIT ( SDB__CLSVSSL_HDTMOUT ) ;
      return ;
   }
ConditionManagerTimeInterval::ConditionManagerTimeInterval(QObject *parent)
    : ConditionManagerCacheable(parent)
{
    setObjectName("ConditionManagerTimeInterval");
    _timer.setSingleShot(true);
    connect(&_timer, SIGNAL(timeout()), this, SLOT(_timeout()));
}
示例#5
0
文件: hash.c 项目: wsjtangy/loongsso
static int hash_grow(hash *h)
{
    int i, rc;
    struct record *old_recs;
    unsigned int old_recs_length;

    old_recs_length = sizes[h->size_index];
    old_recs        = h->records;

    if (h->size_index == sizes_count - 1) return -1;
    if ((h->records = calloc(sizes[++h->size_index],sizeof(struct record))) == NULL)
	{
        h->records = old_recs;
        return -1;
    }
	
    h->records_count = 0;

    // rehash table
    for (i=0; i < old_recs_length; i++)
	{
        if (old_recs[i].key)
		{
			rc = _timeout(old_recs[i].lifetime);
			if(rc)
			{
				hash_add(h, old_recs[i].key, old_recs[i].value, old_recs[i].lifetime);
			}
		}
	}

    free(old_recs);

    return 0;
}
示例#6
0
static GError *
_resolve_service_through_one_m1(const gchar *m1, struct hc_url_s *u,
		const gchar *s, gchar ***result)
{
	GError *err = NULL;
	struct addr_info_s ai;

	GRID_TRACE2("%s(%s,%s,%s)", __FUNCTION__, m1, hc_url_get(u, HCURL_WHOLE), s);
	meta1_strurl_get_address(m1, &ai);

	*result = meta1v2_remote_list_reference_services(&ai, &err,
			hc_url_get(u, HCURL_NS), hc_url_get_id(u), s,
			_timeout(&rc_resolver_timeout_m1, 30.0),
			_timeout(&rc_resolver_timeout_m1, 30.0));
	g_assert((err!=NULL) ^ (*result!=NULL));

	return err;
}
示例#7
0
NetworkReplyTimeout::NetworkReplyTimeout(QNetworkReply* reply, QObject *parent) :
    QObject(parent)
{
    mNetworkReply = reply;
    if (mNetworkReply) {
        connect(mNetworkReply, SIGNAL(destroyed()), this, SLOT(deleteLater()));
        QTimer::singleShot(TIMEOUT*1000, this, SLOT(_timeout()));
    }
}
示例#8
0
文件: hash.c 项目: wsjtangy/loongsso
int hash_add(hash *h, uint64_t key, char *value, time_t lifetime)
{
	int  rc;
	char tmp[30];
    struct record *recs;
    unsigned int off, ind, size, code;

    if (key <= 0 ) return -2;	
    if (h->records_count > sizes[h->size_index] * load_factor) 
	{
        rc = hash_grow(h);
        if (rc) return rc;
    }
	
	memset(&tmp, 0, sizeof(tmp));
	snprintf(tmp, sizeof(tmp), "%llu", key);

    recs = h->records;
    size = sizes[h->size_index];
	
	code = stringhash(tmp);
    ind = code % size;
    off = 0;
	rc  = 1;

    while (recs[ind].key)
	{
		rc = _timeout(recs[ind].lifetime);
		if(!rc)
		{
			//超时的记录
            h->records_count--;
			break;
		}

		if(key == recs[ind].key)
		{
			return 0;
		}

        ind = (code + (int)pow(++off,2)) % size;
	}
	
	recs[ind].key       = key;
	recs[ind].lifetime  = lifetime;

	memcpy(recs[ind].value, value, sizeof(recs[ind].value));
	
    h->records_count++;

    return 1;
}
示例#9
0
void    Timer::run()
{
    // If the plugin dsoesn't implements ITimer
    if (!Plugins::instance()->getInstance<LightBird::ITimer>(this->id) || this->stopped)
        return ;
    Plugins::instance()->release(this->id);
    QObject::connect(&this->timer, SIGNAL(timeout()), this, SLOT(_timeout()), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(setIntervalSignal()), this, SLOT(_setInterval()), Qt::QueuedConnection);
    this->timer.start(this->interval);
    LOG_TRACE("Timer thread started", Properties("id", this->id).add("name", this->name), "Timer", "run");
    this->exec();
    LOG_TRACE("Timer thread finished", Properties("id", this->id).add("name", this->name), "Timer", "run");
    // The thread where lives the Timer is changed to the thread main
    this->moveToThread(QCoreApplication::instance()->thread());
}
示例#10
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB__CLSVSSL_ACTIVE, "_clsVSSilence::active" )
   void _clsVSSilence::active( INT32 &next )
   {
      PD_TRACE_ENTRY ( SDB__CLSVSSL_ACTIVE ) ;
      _timeout() = 0 ;

      if ( _info()->groupSize() == 1 )
      {
         next = CLS_ELECTION_STATUS_SEC ;
      }
      else
      {
         next = id() ;
      }

      PD_TRACE_EXIT ( SDB__CLSVSSL_ACTIVE ) ;
      return ;
   }
示例#11
0
文件: hash.c 项目: wsjtangy/loongsso
const char *hash_get(hash *h, const uint64_t key)
{
	int  rc;
	char tmp[30];
    struct record *recs;
    unsigned int off, ind, size, code;


	memset(&tmp, 0, sizeof(tmp));
	snprintf(tmp, sizeof(tmp), "%llu", key);
	
	code = stringhash(tmp);
    recs = h->records;
    size = sizes[h->size_index];
    ind  = code % size;
    off  = 0;

    while (recs[ind].key) 
	{
		rc = _timeout(recs[ind].lifetime);
		if(!rc)
		{
			//超时的记录,将这条记录置为删除的标志
			recs[ind].key = 0;
            h->records_count--;
			break;
		}
        if (key == recs[ind].key)
		{
            return recs[ind].value;
        }
		ind = (code + (int)pow(++off,2)) % size;
    }

    return NULL;
}