Hi Mattias,

On 18/10/2018 09:07, Mattias Rönnblom wrote:
Most of the issues I pointed out in v2 of this patchset is still here.

Will recheck feedback for the next version.

With regards to comments on v2, 3/10, could you please help provide clarification on the below?

<Copy from the v2 feedback>
On 03/10/2018 20:06, Mattias Rönnblom wrote:
On 2018-10-03 19:36, Kevin Laatz wrote:
From: Ciara Power <ciara.po...@intel.com>
+
+    if (!telemetry->request_client) {
+        TELEMETRY_LOG_ERR("No client has been chosen to write to");
+        return -1;
+    } > +
+    if (!json_string) {
+        TELEMETRY_LOG_ERR("Invalid JSON string!");
+        return -1;
+    }
+
+    ret = send(telemetry->request_client->fd,
+            json_string, strlen(json_string), 0);

How would this code handle a partial success (as in, for example, half of the string fits the socket buffer)? In not, maybe switching over to a SOCK_SEQPACKET AF_UNIX socket would be the best way around it.

Is the suggestion here simply to use socket(AF_UNIX, SOCK_SEQPACKET) instead of (AF_UNIX, SOCK_STREAM) ?

+
+    buffer_read = read(telemetry->accept_fd, buf, BUF_SIZE-1);

This and the below code seem to assume that read() returns one and only one message, but on a SOCK_STREAM, there is no such thing as a message. It's a byte stream, and you need to provide your own framing, or have an application protocol which allows only have one outstanding request. If you do the latter, you still need to allow for "short" (partial) read()s (i.e. re-read() until done).

Will the above solve this part of the problem too?

Best regards,
Kevin

Reply via email to