Revision 1f8ebe96 ml.c

View differences:

ml.c
280 280
			if(set_Monitoring_header_pkt_cb != NULL) {
281 281
				iov[1].iov_len = (set_Monitoring_header_pkt_cb) (&(connectbuf[con_id]->external_socketID), msg_type);
282 282
			}
283
			pkt_len = min(connectbuf[con_id]->pmtusize - iov[2].iov_len - iov[1].iov_len - iov[0].iov_len, msg_len + msg_h.len_mon_data_hdr - offset) ;
283
			pkt_len = min(connectbuf[con_id]->pmtusize - iov[2].iov_len - iov[1].iov_len - iov[0].iov_len, msg_len - offset) ;
284 284

  
285 285
			iov[3].iov_len = pkt_len;
286 286
			iov[3].iov_base = msg + offset;
......
327 327
					break;
328 328
				case OK:
329 329
					//update
330
					offset += pkt_len + iov[2].iov_len;
330
					offset += pkt_len;
331 331
					//transmit data header only in the first packet
332 332
					iov[2].iov_len = 0;
333 333
					break;
334 334
			}
335
		} while(offset != msg_len + msg_h.len_mon_data_hdr && !truncable);
335
		} while(offset != msg_len && !truncable);
336 336
	} while(retry);
337 337
}
338 338

  
......
401 401
	time_t now = time(NULL);
402 402
	double timediff = 0.0;
403 403
	char str[1000];
404

  
404
	
405
	msgbuf += msg_h->len_mon_data_hdr;
406
	msg_size -= msg_h->len_mon_data_hdr;
407
	con_msg = (struct conn_msg *)msgbuf;
408
	
405 409
	// Monitoring layer hook
406 410
	if(get_Recv_data_inf_cb != NULL) {
407 411
		// update pointer to the real data
408
		msgbuf += msg_h->len_mon_data_hdr;
409
		msg_size -= msg_h->len_mon_data_hdr;
410
		con_msg = (struct conn_msg *)msgbuf;
411

  
412 412
		mon_data_inf recv_data_inf;
413 413
		recv_data_inf.remote_socketID = &(con_msg->sock_id);
414 414
		recv_data_inf.buffer = msgbuf;
......
426 426

  
427 427
		// send data recv callback to monitoring module
428 428
		(get_Recv_data_inf_cb) ((void *) &recv_data_inf);
429
	} else {
430
		con_msg = (struct conn_msg *) msgbuf;
431 429
	}
432 430

  
433 431
	//decode sock_id for debug messages
......
716 714
		recvdatabuf[recv_id]->msgtype = msg_h->msg_type;
717 715

  
718 716
		// fill the buffer with zeros
719
		memset(recvdatabuf[recv_id]->recvbuf, 0, msg_h->msg_length);
717
		memset(recvdatabuf[recv_id]->recvbuf, 0, recvdatabuf[recv_id]->bufsize);
720 718
		debug(" new @ id:%d\n",recv_id);
721 719
	} else {	//message structure already exists, no need to create new
722 720
		debug(" found @ id:%d (arrived before this packet: bytes:%d fragments%d\n",recv_id, recvdatabuf[recv_id]->arrivedBytes, recvdatabuf[recv_id]->recvFragments);
723 721
	}
724 722

  
725
	if (msg_h->offset == 0)
723
	//if first packet extract mon data header and advance pointer
724
	if (msg_h->offset == 0) {
725
		memcpy(recvdatabuf[recv_id]->recvbuf, msgbuf, msg_h->len_mon_data_hdr);
726
		msgbuf += msg_h->len_mon_data_hdr;
726 727
		recvdatabuf[recv_id]->firstPacketArrived = 1;
728
	}
727 729

  
728 730

  
729 731
	// increment fragmentnr
......
732 734
	recvdatabuf[recv_id]->arrivedBytes += bufsize;
733 735

  
734 736
	// enter the data into the buffer
735
	memcpy(recvdatabuf[recv_id]->recvbuf + msg_h->offset, msgbuf, bufsize);
737
	memcpy(recvdatabuf[recv_id]->recvbuf + msg_h->len_mon_data_hdr + msg_h->offset, msgbuf, bufsize);
736 738

  
737 739
	//TODO very basic checkif all fragments arrived: has to be reviewed
738 740
	if(recvdatabuf[recv_id]->arrivedBytes == recvdatabuf[recv_id]->bufsize)

Also available in: Unified diff