Fixed send error in PSA UDP_MC
Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/fc720cf2 Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/fc720cf2 Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/fc720cf2 Branch: refs/heads/develop Commit: fc720cf2ad5cc0d8845650cd956729e8d3fe1ec0 Parents: 3b99cc3 Author: gricciardi <[email protected]> Authored: Wed Sep 20 17:08:23 2017 +0200 Committer: gricciardi <[email protected]> Committed: Wed Sep 20 17:08:23 2017 +0200 ---------------------------------------------------------------------- .../pubsub/publisher/private/src/pubsub_publisher.c | 3 +-- pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/fc720cf2/pubsub/examples/pubsub/publisher/private/src/pubsub_publisher.c ---------------------------------------------------------------------- diff --git a/pubsub/examples/pubsub/publisher/private/src/pubsub_publisher.c b/pubsub/examples/pubsub/publisher/private/src/pubsub_publisher.c index b798ea1..b78a6c5 100644 --- a/pubsub/examples/pubsub/publisher/private/src/pubsub_publisher.c +++ b/pubsub/examples/pubsub/publisher/private/src/pubsub_publisher.c @@ -77,8 +77,7 @@ static void* send_thread(void* arg){ while(stop==false){ place->position.lat = randCoordinate(MIN_LAT,MAX_LAT); place->position.lon = randCoordinate(MIN_LON,MAX_LON); - //int nr_char = (int)randCoordinate(5,100000); - int nr_char = 32; + int nr_char = (int)randCoordinate(5,100000); place->data = calloc(nr_char, 1); for(int i = 0; i < (nr_char-1); i++) { place->data[i] = i%10 + '0'; http://git-wip-us.apache.org/repos/asf/celix/blob/fc720cf2/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c ---------------------------------------------------------------------- diff --git a/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c b/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c index b85f0a9..982c8fc 100644 --- a/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c +++ b/pubsub/pubsub_admin_udp_mc/private/src/topic_publication.c @@ -75,12 +75,14 @@ typedef struct publish_bundle_bound_service { largeUdp_pt largeUdpHandle; }* publish_bundle_bound_service_pt; + typedef struct pubsub_msg{ pubsub_msg_header_pt header; char* payload; - size_t payloadSize; + unsigned int payloadSize; } pubsub_msg_t; + static unsigned int rand_range(unsigned int min, unsigned int max); static celix_status_t pubsub_topicPublicationGetService(void* handle, bundle_pt bundle, service_registration_pt registration, void **service); @@ -286,8 +288,6 @@ static bool send_pubsub_msg(publish_bundle_bound_service_pt bound, pubsub_msg_t* const int iovec_len = 3; // header + size + payload bool ret = true; - int compiledMsgSize = sizeof(pubsub_udp_msg_t) + msg->payloadSize; - struct iovec msg_iovec[iovec_len]; msg_iovec[0].iov_base = msg->header; msg_iovec[0].iov_len = sizeof(*msg->header); @@ -299,7 +299,6 @@ static bool send_pubsub_msg(publish_bundle_bound_service_pt bound, pubsub_msg_t* delay_first_send_for_late_joiners(); if(largeUdp_sendmsg(bound->largeUdpHandle, bound->parent->sendSocket, msg_iovec, iovec_len, 0, &bound->parent->destAddr, sizeof(bound->parent->destAddr)) == -1) { - fprintf(stderr, "Socket: %d, size: %i",bound->parent->sendSocket, compiledMsgSize); perror("send_pubsub_msg:sendSocket"); ret = false; } @@ -342,7 +341,7 @@ static int pubsub_topicPublicationSend(void* handle, unsigned int msgTypeId, con pubsub_msg_t *msg = calloc(1,sizeof(pubsub_msg_t)); msg->header = msg_hdr; - msg->payload = (char *)serializedOutput; + msg->payload = (char*)serializedOutput; msg->payloadSize = serializedOutputLen;
