Пример #1
0
static void notif_readystate(HTMLOuterWindow *window)
{
    DOMEvent *event;
    HRESULT hres;

    window->readystate_pending = FALSE;

    if(window->doc_obj && window->doc_obj->basedoc.window == window)
        call_property_onchanged(&window->doc_obj->basedoc.cp_container, DISPID_READYSTATE);

    hres = create_document_event(window->base.inner_window->doc, EVENTID_READYSTATECHANGE, &event);
    if(SUCCEEDED(hres)) {
        event->no_event_obj = TRUE;
        dispatch_event(&window->base.inner_window->doc->node.event_target, event);
        IDOMEvent_Release(&event->IDOMEvent_iface);
    }

    if(window->frame_element) {
        hres = create_document_event(window->frame_element->element.node.doc, EVENTID_READYSTATECHANGE, &event);
        if(SUCCEEDED(hres)) {
            dispatch_event(&window->frame_element->element.node.event_target, event);
            IDOMEvent_Release(&event->IDOMEvent_iface);
        }
    }
}
Пример #2
0
static __inline void process_key_pressed(uint64_t timestamp, KBDLLHOOKSTRUCT *kbhook) {
	// Check and setup modifiers.
	if		(kbhook->vkCode == VK_LSHIFT)	{ set_modifier_mask(MASK_SHIFT_L);	}
	else if (kbhook->vkCode == VK_RSHIFT)	{ set_modifier_mask(MASK_SHIFT_R);	}
	else if (kbhook->vkCode == VK_LCONTROL)	{ set_modifier_mask(MASK_CTRL_L);	}
	else if (kbhook->vkCode == VK_RCONTROL)	{ set_modifier_mask(MASK_CTRL_R);	}
	else if (kbhook->vkCode == VK_LMENU)	{ set_modifier_mask(MASK_ALT_L);	}
	else if (kbhook->vkCode == VK_RMENU)	{ set_modifier_mask(MASK_ALT_R);	}
	else if (kbhook->vkCode == VK_LWIN)		{ set_modifier_mask(MASK_META_L);	}
	else if (kbhook->vkCode == VK_RWIN)		{ set_modifier_mask(MASK_META_R);	}

	
	// Populate key pressed event.
	event.time = timestamp;
	event.reserved = 0x00;

	event.type = EVENT_KEY_PRESSED;
	event.mask = get_modifiers();

	event.data.keyboard.keycode = keycode_to_scancode(kbhook->vkCode);
	event.data.keyboard.rawcode = kbhook->vkCode;
	event.data.keyboard.keychar = CHAR_UNDEFINED;

	logger(LOG_LEVEL_INFO, "%s [%u]: Key %#X pressed. (%#X)\n",
		__FUNCTION__, __LINE__, event.data.keyboard.keycode, event.data.keyboard.rawcode);
	if (wants_to_hook_event(EVENT_KEY_PRESSED)){
		// Populate key pressed event.
		dispatch_event(&event);
	}

	if (!wants_to_hook_event(EVENT_KEY_TYPED))
		return;

	// If the pressed event was not consumed...
	if (event.reserved ^ 0x01) {
		// Buffer for unicode typed chars. No more than 2 needed.
		WCHAR buffer[2]; // = { WCH_NONE };

		// If the pressed event was not consumed and a unicode char exists...
		SIZE_T count = keycode_to_unicode(kbhook->vkCode, buffer, sizeof(buffer));
		for (unsigned int i = 0; i < count; i++) {
			// Populate key typed event.
			event.time = timestamp;
			event.reserved = 0x00;

			event.type = EVENT_KEY_TYPED;
			event.mask = get_modifiers();

			event.data.keyboard.keycode = keycode_to_scancode(kbhook->vkCode);
			event.data.keyboard.rawcode = kbhook->vkCode;
			event.data.keyboard.keychar = buffer[i];

			logger(LOG_LEVEL_INFO, "%s [%u]: Key %#X typed. (%lc)\n",
					__FUNCTION__, __LINE__, event.data.keyboard.keycode, (wint_t) event.data.keyboard.keychar);

			// Fire key typed event.
			dispatch_event(&event);
		}
	}
}
Пример #3
0
static int
dispatch_queue(struct wl_display *display, struct wl_event_queue *queue)
{
	int count;

	if (display->last_error)
		goto err;

	count = 0;
	while (!wl_list_empty(&display->display_queue.event_list)) {
		dispatch_event(display, &display->display_queue);
		if (display->last_error)
			goto err;
		count++;
	}

	while (!wl_list_empty(&queue->event_list)) {
		dispatch_event(display, queue);
		if (display->last_error)
			goto err;
		count++;
	}

	return count;

err:
	errno = display->last_error;

	return -1;
}
Пример #4
0
static __inline void process_button_released(uint64_t timestamp, MSLLHOOKSTRUCT *mshook, uint16_t button) {

	if (wants_to_hook_event(EVENT_MOUSE_RELEASED)){
		// Populate mouse released event.
		event.time = timestamp;
		event.reserved = 0x00;

		event.type = EVENT_MOUSE_RELEASED;
		event.mask = get_modifiers();

		event.data.mouse.button = button;
		event.data.mouse.clicks = click_count;

		event.data.mouse.x = mshook->pt.x;
		event.data.mouse.y = mshook->pt.y;

		logger(LOG_LEVEL_INFO, "%s [%u]: Button %u released %u time(s). (%u, %u)\n",
			__FUNCTION__, __LINE__, event.data.mouse.button,
			event.data.mouse.clicks,
			event.data.mouse.x, event.data.mouse.y);

		// Fire mouse released event.
		dispatch_event(&event);
	}

	if (!wants_to_hook_event(EVENT_MOUSE_CLICKED))
		return;

	// If the pressed event was not consumed...
	if (event.reserved ^ 0x01
			&& last_click.x == mshook->pt.x && last_click.y == mshook->pt.y) {
		// Populate mouse clicked event.
		event.time = timestamp;
		event.reserved = 0x00;

		event.type = EVENT_MOUSE_CLICKED;
		event.mask = get_modifiers();

		event.data.mouse.button = button;
		event.data.mouse.clicks = click_count;
		event.data.mouse.x = mshook->pt.x;
		event.data.mouse.y = mshook->pt.y;

		logger(LOG_LEVEL_INFO, "%s [%u]: Button %u clicked %u time(s). (%u, %u)\n",
				__FUNCTION__, __LINE__, event.data.mouse.button, event.data.mouse.clicks,
				event.data.mouse.x, event.data.mouse.y);

		// Fire mouse clicked event.
		dispatch_event(&event);
	}
}
Пример #5
0
void recoder::add_enc_packet(const uint8_t *data, const uint16_t len)
{
    size_t tmp_rank;

    guard g(m_lock);

    /* don't add packets when we have enough, and try to stop encoder
     * from sending more packets
     */
    if (this->is_complete()) {
        send_ack_packet();
        return;
    }

    if (curr_state() == STATE_DONE)
        return;

    CHECK_EQ(len, this->payload_size()) << "Recoder " << m_coder
                                        << ": Encoded data is too short:"
                                        << len << " < " << this->payload_size();

    /* keep track of changes in rank */
    tmp_rank = this->rank();

    this->decode(const_cast<uint8_t *>(data));

    /* check if rank improved */
    if (this->rank() == tmp_rank)
        inc("non-innovative recoded packets");

    update_timestamp();

    if (this->last_symbol_is_systematic()) {
        inc("systematic packets added");
        send_systematic_packet(data, len);
        m_budget--;
    } else {
        inc("encoded packets added");
    }

    /* signal state machine if generation is complete */
    if (this->is_complete()) {
        send_ack_packet();
        dispatch_event(EVENT_COMPLETE);
    } else {
        dispatch_event(EVENT_RX);
    }

    VLOG(LOG_PKT) << "Recoder " << m_coder << ": Added encoded packet";
}
Пример #6
0
static void process_button_released(MSLLHOOKSTRUCT *mshook, uint16_t button) {
	// Populate mouse released event.
	event.time = GetMessageTime();
	event.reserved = 0x00;

	event.type = EVENT_MOUSE_RELEASED;
	event.mask = get_modifiers();

	event.data.mouse.button = button;
	event.data.mouse.clicks = click_count;

	event.data.mouse.x = mshook->pt.x;
	event.data.mouse.y = mshook->pt.y;

	logger(LOG_LEVEL_INFO, "%s [%u]: Button %u released %u time(s). (%u, %u)\n",
			__FUNCTION__, __LINE__, event.data.mouse.button,
			event.data.mouse.clicks,
			event.data.mouse.x, event.data.mouse.y);

	// Fire mouse released event.
	dispatch_event(&event);

	// If the pressed event was not consumed...
	if (event.reserved ^ 0x01 && last_click.x == mshook->pt.x && last_click.y == mshook->pt.y) {
		// Populate mouse clicked event.
		event.time = GetMessageTime();
		event.reserved = 0x00;

		event.type = EVENT_MOUSE_CLICKED;
		event.mask = get_modifiers();

		event.data.mouse.button = button;
		event.data.mouse.clicks = click_count;
		event.data.mouse.x = mshook->pt.x;
		event.data.mouse.y = mshook->pt.y;

		logger(LOG_LEVEL_INFO, "%s [%u]: Button %u clicked %u time(s). (%u, %u)\n",
				__FUNCTION__, __LINE__, event.data.mouse.button, event.data.mouse.clicks,
				event.data.mouse.x, event.data.mouse.y);

		// Fire mouse clicked event.
		dispatch_event(&event);
	}

	// Reset the number of clicks.
	if (button == click_button && (long int) (event.time - click_time) > hook_get_multi_click_time()) {
		// Reset the click count.
		click_count = 0;
	}
}
Пример #7
0
static ssize_t ch_data(struct senseye_ch* ch, const void* buf, size_t ntw)
{
	if (!ch || !ch->in_pr)
		return -1;

	struct senseye_priv* chp = ch->in_pr;
	size_t ofs = 0;

retry:
	if (!chp->running)
		return -1;

/* flush if the controlling UI has specified one or several framesteps */
	if (!chp->paused || chp->framecount > 0){
		int fc;

		while (chp->framecount > 0 && ntw - ofs > 0){
			ofs += ch->in->data(ch->in, (uint8_t*) buf + ofs, ntw, &fc);
			chp->framecount -= fc;
		}
	}
/* otherwise, block thread, wait for user action and retry */
	else{
		arcan_event ev;
		if (arcan_shmif_wait(&chp->cont, &ev)){
			dispatch_event(&ev, ch->in, chp);
			goto retry;
		}
	}

	ch_pump(ch);
	return ofs;
}
Пример #8
0
bool encoder::process()
{
    guard g(m_lock);

    if (curr_state() == STATE_FULL) {
        if (is_timed_out(FLAGS_encoder_timeout*5)) {
            inc("blocked timeouts");
            LOG(ERROR) << "Encoder " << m_coder
                       << ": Timed out while blocked";
            enc_notify();
            return true;
        }
        return false;
    }

    /* check if decoder is ready to be reused */
    if (curr_state() == STATE_DONE)
        return true;

    /* check if decoder is timed out */
    if (is_timed_out()) {
        LOG(ERROR) << "Encoder " << m_coder << ": Timed out (rank "
                   << m_plain_pkt_count
                   << ", state " << static_cast<int>(curr_state()) << ")";
        dispatch_event(EVENT_TIMEOUT);
        inc("timeouts");
        if (m_plain_pkt_count == this->symbols())
            enc_notify();
    }

    return false;
}
Пример #9
0
bool wpan_task(void)
{
    bool event_processed;
    uint8_t *event = NULL;

    /* mac_task returns true if a request was processed completely */
    event_processed = mac_task();

    /*
     * MAC to NHLE event queue should be dispatched
     * irrespective of the dispatcher state.
     */
    event = (uint8_t *)qmm_queue_remove(&mac_nhle_q, NULL);

    /* If an event has been detected, handle it. */
    if (NULL != event) {
        dispatch_event(event);
        event_processed = true;
    }

#ifdef ENABLE_RTB
    rtb_task();
#endif  /* ENABLE_RTB */
    tal_task();
    pal_task();

    return (event_processed);
}
Пример #10
0
static inline void process_mouse_wheel(uint64_t timestamp, MSLLHOOKSTRUCT *mshook) {
	// Track the number of clicks.
	// Reset the click count and previous button.
	click_count = 1;
	click_button = MOUSE_NOBUTTON;

	// Populate mouse wheel event.
	event.time = timestamp;
	event.reserved = 0x00;

	event.type = EVENT_MOUSE_WHEEL;
	event.mask = get_modifiers();

	event.data.wheel.clicks = click_count;
	event.data.wheel.x = mshook->pt.x;
	event.data.wheel.y = mshook->pt.y;

	event.data.wheel.type = get_scroll_wheel_type();
	event.data.wheel.amount = get_scroll_wheel_amount();

	/* Delta HIWORD(mshook->mouseData)
	 * A positive value indicates that the wheel was rotated
	 * forward, away from the user; a negative value indicates that
	 * the wheel was rotated backward, toward the user. One wheel
	 * click is defined as WHEEL_DELTA, which is 120. */
	event.data.wheel.rotation = ((int16_t) HIWORD(mshook->mouseData) / WHEEL_DELTA) * -1;

	logger(LOG_LEVEL_INFO, "%s [%u]: Mouse wheel type %u, rotated %i units at %u, %u.\n",
			__FUNCTION__, __LINE__, event.data.wheel.type, event.data.wheel.amount *
			event.data.wheel.rotation, event.data.wheel.x, event.data.wheel.y);

	// Fire mouse wheel event.
	dispatch_event(&event);
}
Пример #11
0
static void process_key_released(KBDLLHOOKSTRUCT *kbhook) {
	// Check and setup modifiers.
	if		(kbhook->vkCode == VK_LSHIFT)	{ unset_modifier_mask(MASK_SHIFT_L);		}
	else if (kbhook->vkCode == VK_RSHIFT)	{ unset_modifier_mask(MASK_SHIFT_R);		}
	else if (kbhook->vkCode == VK_LCONTROL)	{ unset_modifier_mask(MASK_CTRL_L);			}
	else if (kbhook->vkCode == VK_RCONTROL)	{ unset_modifier_mask(MASK_CTRL_R);			}
	else if (kbhook->vkCode == VK_LMENU)	{ unset_modifier_mask(MASK_ALT_L);			}
	else if (kbhook->vkCode == VK_RMENU)	{ unset_modifier_mask(MASK_ALT_R);			}
	else if (kbhook->vkCode == VK_LWIN)		{ unset_modifier_mask(MASK_META_L);			}
	else if (kbhook->vkCode == VK_RWIN)		{ unset_modifier_mask(MASK_META_R);			}
	else if (kbhook->vkCode == VK_NUMLOCK)	{ unset_modifier_mask(MASK_NUM_LOCK);		}
	else if (kbhook->vkCode == VK_CAPITAL)	{ unset_modifier_mask(MASK_CAPS_LOCK);		}
	else if (kbhook->vkCode == VK_SCROLL)	{ unset_modifier_mask(MASK_SCROLL_LOCK);	}

	// Populate key pressed event.
	event.time = kbhook->time;
	event.reserved = 0x00;

	event.type = EVENT_KEY_RELEASED;
	event.mask = get_modifiers();

	event.data.keyboard.keycode = keycode_to_scancode(kbhook->vkCode, kbhook->flags);
	event.data.keyboard.rawcode = kbhook->vkCode;
	event.data.keyboard.keychar = CHAR_UNDEFINED;

	logger(LOG_LEVEL_INFO,	"%s [%u]: Key %#X released. (%#X)\n",
			__FUNCTION__, __LINE__, event.data.keyboard.keycode, event.data.keyboard.rawcode);

	// Fire key released event.
	dispatch_event(&event);
}
Пример #12
0
void check_circle_event(arc_t *i, double x0){

    if((i->e != NULL) && (i->e->x != x0)){

        i->e->valid = FALSE;    }

    i->e = NULL;

    if((i->prev == NULL)||(i->next == NULL)){
        return;
    }

    double x;
    point_t o;

    BOOL rst_circle = circle(i->prev->p, i->p, i->next->p, &x,&o);
    if(rst_circle == TRUE && x > x0){
        i->e = dispatch_event();
        i->e->x = x;
        i->e->p = o;
        i->e->a = i;
        i->e->valid = TRUE;

        push_event(i->e);
    }
}
Пример #13
0
int
readmouse(Point *p, uint *button) {
	XEvent ev;

	for(;;) {
		XMaskEvent(display, MouseMask|ExposureMask|StructureNotifyMask|PropertyChangeMask, &ev);
		switch(ev.type) {
		case ConfigureNotify:
		case Expose:
		case NoExpose:
		case PropertyNotify:
			dispatch_event(&ev);
		default:
			continue;
		case ButtonPress:
		case ButtonRelease:
			*button = ev.xbutton.button;
		case MotionNotify:
			p->x = ev.xmotion.x_root;
			p->y = ev.xmotion.y_root;
			break;
		}
		return ev.type;
	}
}
Пример #14
0
static void distribute_event(struct auditd_reply_list *rep)
{
	int attempt = 0;

	/* Make first attempt to send to plugins */
	if (dispatch_event(&rep->reply, attempt) == 1)
		attempt++; /* Failed sending, retry after writing to disk */

	/* End of Event is for realtime interface - skip local logging of it */
	if (rep->reply.type != AUDIT_EOE) {
		int yield = rep->reply.type <= AUDIT_LAST_DAEMON &&
				rep->reply.type >= AUDIT_FIRST_DAEMON ? 1 : 0;
		/* Write to local disk */
		enqueue_event(rep);
		if (yield) {
			struct timespec ts;
			ts.tv_sec = 0;
			ts.tv_nsec = 2 * 1000 * 1000; // 2 milliseconds
			nanosleep(&ts, NULL); // Let other thread try to log it
		}
	} else
		free(rep);	// This function takes custody of the memory

	// FIXME: This is commented out since it fails to work. The
	// problem is that the logger thread free's the buffer. Probably
	// need a way to flag in the buffer if logger thread should free or
	// move the free to this function.

	/* Last chance to send...maybe the pipe is empty now. */
//	if (attempt) 
//		dispatch_event(&rep->reply, attempt);
}
Пример #15
0
static __inline void process_key_released(uint64_t timestamp, KBDLLHOOKSTRUCT *kbhook) {
	// Check and setup modifiers.
	if		(kbhook->vkCode == VK_LSHIFT)	{ unset_modifier_mask(MASK_SHIFT_L);	}
	else if (kbhook->vkCode == VK_RSHIFT)	{ unset_modifier_mask(MASK_SHIFT_R);	}
	else if (kbhook->vkCode == VK_LCONTROL)	{ unset_modifier_mask(MASK_CTRL_L);		}
	else if (kbhook->vkCode == VK_RCONTROL)	{ unset_modifier_mask(MASK_CTRL_R);		}
	else if (kbhook->vkCode == VK_LMENU)	{ unset_modifier_mask(MASK_ALT_L);		}
	else if (kbhook->vkCode == VK_RMENU)	{ unset_modifier_mask(MASK_ALT_R);		}
	else if (kbhook->vkCode == VK_LWIN)		{ unset_modifier_mask(MASK_META_L);		}
	else if (kbhook->vkCode == VK_RWIN)		{ unset_modifier_mask(MASK_META_R);		}

	if (!wants_to_hook_event(EVENT_KEY_RELEASED))
		return;

	// Populate key released event.
	event.time = timestamp;
	event.reserved = 0x00;

	event.type = EVENT_KEY_RELEASED;
	event.mask = get_modifiers();

	event.data.keyboard.keycode = keycode_to_scancode(kbhook->vkCode);
	event.data.keyboard.rawcode = kbhook->vkCode;
	event.data.keyboard.keychar = CHAR_UNDEFINED;

	logger(LOG_LEVEL_INFO,	"%s [%u]: Key %#X released. (%#X)\n",
			__FUNCTION__, __LINE__, event.data.keyboard.keycode, event.data.keyboard.rawcode);

	// Fire key released event.
	dispatch_event(&event);
}
Пример #16
0
/* process_input processes an device input event, and dispatches 
 * spacenav events to the clients by calling dispatch_event.
 * relative inputs (INP_MOTION) are accumulated, and dispatched when
 * we get an INP_FLUSH event. Button events are dispatched immediately
 * and they implicitly flush any pending motion event.
 */
void process_input(struct dev_input *inp)
{
	int sign;

	switch(inp->type) {
	case INP_MOTION:
		if(abs(inp->val) < cfg.dead_threshold) {
			break;
		}

		inp->idx = cfg.map_axis[inp->idx];
		sign = cfg.invert[inp->idx] ? -1 : 1;

		inp->val = (int)((float)inp->val * cfg.sensitivity * (inp->idx < 3 ? cfg.sens_trans : cfg.sens_rot));

		ev.type = EVENT_MOTION;
		ev.motion.data = (int*)&ev.motion.x;
		ev.motion.data[inp->idx] = sign * inp->val;
		ev_pending = 1;
		break;

	case INP_BUTTON:
		if(ev_pending) {
			dispatch_event(&ev);
			ev_pending = 0;
		}
		inp->idx = cfg.map_button[inp->idx];

		ev.type = EVENT_BUTTON;
		ev.button.press = inp->val;
		ev.button.bnum = inp->idx;
		dispatch_event(&ev);
		break;

	case INP_FLUSH:
		if(ev_pending) {
			dispatch_event(&ev);
			ev_pending = 0;
		}
		break;

	default:
		break;
	}
}
Пример #17
0
static Ret ftk_source_ps2mouse_dispatch(FtkSource* thiz)
{
	int ret = 0;
	DECL_PRIV(thiz, priv);

	dispatch_event(priv);

	return RET_OK;
}
Пример #18
0
void
xevent_loop(void) {
	XEvent ev;

	while(running) {
		XNextEvent(display, &ev);
		dispatch_event(&ev);
	}
}
Пример #19
0
static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
        VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
{
    HTMLDocument *This = impl_from_IHTMLDocument4(iface);

    TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);

    return dispatch_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled);
}
Пример #20
0
static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
        VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
{
    HTMLElement *This = impl_from_IHTMLElement3(iface);

    TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
          pfCancelled);

    return dispatch_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
}
Пример #21
0
static void ch_pump(struct senseye_ch* ch)
{
	if (!ch || !ch->in_pr)
		return;

	struct senseye_priv* priv = ch->in_pr;
	struct arcan_event ev;

	while(arcan_shmif_poll(&priv->cont, &ev) != 0)
		dispatch_event(&ev, ch->in, priv);
}
Пример #22
0
void recoder::send_rec_credits()
{
    update_budget();

    if (m_budget <= 0) {
        dispatch_event(EVENT_CREDIT_SENT);
        return;
    }

    for (; m_budget > 0 && m_rec_pkt_count <= m_max_budget; m_budget--) {
        guard g(m_lock);
        send_rec_packet();
    }

    if (m_rec_pkt_count >= m_max_budget) {
        dispatch_event(EVENT_MAXED);
    } else {
        dispatch_event(EVENT_CREDIT_SENT);
    }
}
Пример #23
0
void scenario_render(scenario_t *scenario)
{
	color_t color;
	color.r = 0;
	color.g = 0;
	color.b = 0;

	screen_fill(&scenario->graphics->screen, &color);
	dispatch_event(&scenario->ed, EV_RENDER, (void*) scenario->graphics);
	screen_update(scenario->graphics);
}
Пример #24
0
void hook_stop_proc() {
	// Populate the hook stop event.
	event.time = get_event_timestamp();
	event.reserved = 0x00;

	event.type = EVENT_HOOK_DISABLED;
	event.mask = 0x00;

	// Fire the hook stop event.
	dispatch_event(&event);
}
Пример #25
0
void decoder::add_enc_packet(const uint8_t *data, const uint16_t len)
{
    size_t rank, symbol_index, msecs;
    bool systematic;
    size_t size = this->payload_size();

    guard g(m_lock);

    if (this->is_complete()) {
        inc("redundant received");
        if (++m_red_pkt_count % FLAGS_ack_interval == 0)
            send_ack_packet();
        return;
    }

    CHECK_EQ(len, size) << "Decoder " << m_coder
                        << ": Invalid length:" << len << " != " << size;

    rank = this->rank();
    this->decode(const_cast<uint8_t *>(data));
    m_enc_pkt_count++;

    if (this->rank() == rank) {
        VLOG(LOG_PKT) << "Decoder " << m_coder << ": Added non-innovative";
        inc("non-innovative received");
        update_timestamp();
        update_packet_timestamp();
        return;
    }

    systematic = this->last_symbol_is_systematic();
    symbol_index = this->last_symbol_index();

    if (this->is_complete()) {
        dispatch_event(EVENT_COMPLETE);
        return;
    }

    if (this->is_partial_complete())
        send_partial_decoded_packets(this->rank());

    if (systematic) {
        inc("systematic received");
        VLOG(LOG_PKT) << "Decoder " << m_coder << ": Added systematic ("
                      << symbol_index << ")";
        send_decoded_packet(symbol_index);
    } else {
        VLOG(LOG_PKT) << "Decoder " << m_coder << ": Added encoded";
        inc("encoded received");
    }

    update_timestamp();
    update_packet_timestamp();
}
Пример #26
0
void recoder::send_rec_budget()
{
    while (m_rec_pkt_count < m_max_budget && next_state() == STATE_SEND_BUDGET) {
        guard g(m_lock);
        send_rec_packet();
    }

    dispatch_event(EVENT_BUDGET_SENT);
    inc("forward generations written");
    VLOG(LOG_GEN) << "Recoder " << m_coder << ": Write recoded packets ("
                  << m_rec_pkt_count << " of " << m_max_budget << ")";
}
Пример #27
0
uint
flushevents(long event_mask, bool dispatch) {
	XEvent ev;
	uint n = 0;

	while(XCheckMaskEvent(display, event_mask, &ev)) {
		if(dispatch)
			dispatch_event(&ev);
		n++;
	}
	return n;
}
Пример #28
0
bool decoder::process()
{
    if (curr_state() == STATE_DONE)
        return true;

    if (is_timed_out() && !this->is_complete() &&
        !this->is_partial_complete()) {
        LOG(ERROR) << "Decoder " << m_coder << ": Timed out (rank "
                   << this->rank() << ")";
        inc("incomplete timeouts");
        dispatch_event(EVENT_TIMEOUT);
        return false;
    }

    if (is_timed_out()) {
        dispatch_event(EVENT_TIMEOUT);
        return false;
    }

    if (curr_state() == STATE_WAIT && packet_timed_out()) {

        if (this->is_partial_complete())
            return false;

        double req_budget = source_budget(1, 254, 254, m_e3);

        VLOG(LOG_GEN) << "Decoder " << m_coder << ": Request more data (rank "
                      << this->rank() << ", seq " << m_req_seq << ")";

        for (; req_budget >= 0; req_budget--)
            send_request(m_req_seq);
        m_req_seq++;
        update_packet_timestamp();

        return false;
    }

    return false;
}
Пример #29
0
void encoder::send_encoded_budget()
{
    VLOG(LOG_GEN) << "Encoder " << m_coder << ": Send "
                  << (m_max_budget - m_enc_pkt_count) << " redundant packets";

    guard g(m_lock);

    while (m_enc_pkt_count < m_max_budget)
        send_encoded_packet(m_type);

    update_timestamp();
    dispatch_event(EVENT_BUDGET_SENT);
}
Пример #30
0
// 启动事件侦听
void* start_reactor(void* p_epoll_fd)
{
	CHECK_NULL_ASSERT(p_epoll_fd);

	int epoll_fd = *((int*)p_epoll_fd);

	struct epoll_event events[s_max_events];
	while (1) {
		int nfds = epoll_wait(epoll_fd, events, s_max_events, -1);
		check_result(nfds, errno, "epoll_wait");

		dispatch_event(events, nfds);
	}
}