celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [celix] pnoltes commented on a change in pull request #211: Feature/fix tcp endpoint handling
Date Wed, 29 Apr 2020 17:00:51 GMT

pnoltes commented on a change in pull request #211:
URL: https://github.com/apache/celix/pull/211#discussion_r417469426



##########
File path: bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_topic_receiver.c
##########
@@ -691,11 +693,12 @@ static void psa_tcp_connectToAllRequestedConnections(pubsub_tcp_topic_receiver_t
         hash_map_iterator_t iter = hashMapIterator_construct(receiver->requestedConnections.map);
         while (hashMapIterator_hasNext(&iter)) {
             psa_tcp_requested_connection_entry_t *entry = hashMapIterator_nextValue(&iter);
-            if (!entry->connected) {
-                int rc = pubsub_tcpHandler_connect(entry->parent->socketHandler, entry->url);
-                if (rc < 0) {
-                    //L_WARN("[PSA_TCP] Error connecting to tcp url %s. (%s)", entry->url,
strerror(errno));
-                    allConnected = false;
+            if (entry) {

Review comment:
       if (entry && !entry->connected)

##########
File path: bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_handler.c
##########
@@ -1018,19 +1019,28 @@ int pubsub_tcpHandler_write(pubsub_tcpHandler_t *handle, pubsub_protocol_message
 
             void *headerData = NULL;
             size_t headerSize = 0;
-            // Encode the header, with payload size and metadata size
-            handle->protocol->encodeHeader(handle->protocol->handle, message,
-                                           &headerData,
-                                           &headerSize);
-            // Write header in 1st vector buffer item
-            if (headerSize && headerData) {
+            // check if header is not part of the payload (=> headerBufferSize = 0)s
+            if (entry->headerBufferSize) {
+              // Encode the header, with payload size and metadata size
+              handle->protocol->encodeHeader(handle->protocol->handle, message,
+                                             &headerData,
+                                             &headerSize);
+            }
+            if (!entry->headerBufferSize) {
+              // Skip header buffer, when header is part of payload;
+              msg.msg_iov = &msg_iov[1];
+            } else if (headerSize && headerData) {
+              // Write header in 1st vector buffer item
                 msg.msg_iov[0].iov_base = headerData;
                 msg.msg_iov[0].iov_len = headerSize;
                 msgSize += msg.msg_iov[0].iov_len;
                 msg.msg_iovlen++;
+            } else {
+              L_ERROR("[TCP Socket] No header buffer is generated");
+              msg.msg_iovlen = 0;
             }
             nbytes = 0;
-            if (entry->fd >= 0 && msgSize && headerData)
+            if (entry->fd >= 0 && msgSize && msg.msg_iovlen)

Review comment:
       missing {} around if




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message