Revision 0e902e25 ml.c

View differences:

ml.c
530 530
	}
531 531

  
532 532

  
533
	if(recvdatabuf[recv_id]->status == ACTIVE) {
533
/*	if(recvdatabuf[recv_id]->status == ACTIVE) {
534 534
		//TODO make timeout at least a DEFINE
535 535
		struct timeval timeout = { 4, 0 };
536 536
		recvdatabuf[recv_id]->status = INACTIVE;
......
538 538
			arg, &timeout);
539 539
		return;
540 540
	}
541
*/
541 542

  
542
	if(recvdatabuf[recv_id]->status == INACTIVE) {
543
	if(recvdatabuf[recv_id]->status == ACTIVE) {
543 544
		// Monitoring layer hook
544 545
		if(get_Recv_data_inf_cb != NULL) {
545 546
			mon_data_inf recv_data_inf;
......
626 627
		*/
627 628
		recvdatabuf[recv_id]->timeout_value.tv_sec = recv_timeout.tv_sec;
628 629
		recvdatabuf[recv_id]->timeout_value.tv_usec = recv_timeout.tv_usec;
630
		recvdatabuf[recv_id]->timeout_event = NULL;
629 631
		recvdatabuf[recv_id]->recvID = recv_id;
630 632
		recvdatabuf[recv_id]->starttime = time(NULL);
631 633
		recvdatabuf[recv_id]->msgtype = msg_h->msg_type;
......
700 702
			}
701 703

  
702 704
			//clean up
705
			if (recvdatabuf[recv_id]->timeout_event) {
706
				int ret;
707
				ret = event_del(recvdatabuf[recv_id]->timeout_event);
708
				event_free(recvdatabuf[recv_id]->timeout_event);
709
			}
703 710
			free(recvdatabuf[recv_id]->recvbuf);
704 711
			free(recvdatabuf[recv_id]);
705 712
			recvdatabuf[recv_id] = NULL;
706 713
		} else { // not COMPLETE
707
			//start time out
708
			//TODO make timeout at least a DEFINE
709
			struct timeval timeout = { 4, 0 };
710
			event_base_once(base, -1, EV_TIMEOUT, &recv_timeout_cb, (void *) (long)recv_id, &timeout);
714
			if (!recvdatabuf[recv_id]->timeout_event) {
715
				//start time out
716
				//TODO make timeout at least a DEFINE
717
				struct timeval timeout = { 4, 0 };
718
				recvdatabuf[recv_id]->timeout_event = event_new(base, -1, EV_TIMEOUT, &recv_timeout_cb, (void *) (long)recv_id);
719
				evtimer_add(recvdatabuf[recv_id]->timeout_event, &timeout);
720
			}
711 721
		}
712 722
	}
713 723
}

Also available in: Unified diff