Example #1
0
/*-
-- seci, useci = pcap.secs2tv(secs)

Split one numeric seconds into seperate seconds and microseconds.
*/
static int lpcap_secs2tv(lua_State* L)
{
    struct timeval tv;
    double secs = luaL_checknumber(L, 1);

    secs2tv(secs, &tv);
    lua_pushnumber(L, tv.tv_sec);
    lua_pushnumber(L, tv.tv_usec);
    return 2;
}
Example #2
0
static struct timeval* opttimeval(lua_State* L, int argi, struct timeval* tv)
{
    if(lua_isnoneornil(L, argi)) {
#ifndef NDEBUG
        int e =
#endif
            gettimeofday(tv, NULL);
#ifndef NDEBUG
        assert(e == 0); /* can only fail due to argument errors */
#endif
    } else {
        double secs = luaL_checknumber(L, argi);
        secs2tv(secs, tv);
    }
    return tv;
}
Example #3
0
static int pcmk_load_ticket(struct ticket_config *tk)
{
	int rv;
	int64_t v;


	/* This here gets run during startup; testing that here means that
	 * normal operation won't be interrupted with that test. */
	test_atomicity();


	rv = crm_ticket_get(tk, "expires", &v);
	if (!rv) {
		secs2tv(unwall_ts(v), &tk->term_expires);
	}

	rv = crm_ticket_get(tk, "term", &v);
	if (!rv) {
		tk->current_term = v;
	}

	rv = crm_ticket_get(tk, "granted", &v);
	if (!rv) {
		tk->is_granted = v;
	}

	rv = crm_ticket_get(tk, "owner", &v);
	if (!rv) {
		/* No check, node could have been deconfigured. */
		if (!find_site_by_id(v, &tk->leader)) {
			/* Hmm, no site found for the ticket we have in the
			 * CIB!?
			 * Assume that the ticket belonged to us if it was
			 * granted here!
			 */
			log_warn("%s: no site matches; site got reconfigured?",
				tk->name);
			if (tk->is_granted) {
				log_warn("%s: granted here, assume it belonged to us",
					tk->name);
				tk->leader = local;
			}
		}
	}

	return rv;
}
Example #4
0
static int save_expires(struct ticket_config *tk, const char *name,
			const char *val)
{
	secs2tv(unwall_ts(atol(val)), &tk->term_expires);
	return 0;
}