The following code:
memset(&message, 0, sizeof(message));
message.command = command;
message.data = data;
message.size = size;
srs_header_setup(&header, &message);
length = header.length;
buffer = calloc(1, length);
memcpy(buffer, &header, sizeof(header));
if (message.data != NULL && message.size > 0) {
p = (unsigned char *) buffer + sizeof(header);
memcpy(p, message.data, message.size);
}
doesn't depend on shared data structures, so it doesn't need to be
guarded by a mutex.
Signed-off-by: Denis 'GNUtoo' Carikli <[email protected]>
---
srs-client/srs-client.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/srs-client/srs-client.c b/srs-client/srs-client.c
index d16c597..6f3b467 100644
--- a/srs-client/srs-client.c
+++ b/srs-client/srs-client.c
@@ -270,8 +270,6 @@ int srs_client_send(struct srs_client *client, unsigned
short command,
if (client == NULL || client->fd < 0)
return -1;
- SRS_CLIENT_LOCK(client);
-
memset(&message, 0, sizeof(message));
message.command = command;
message.data = data;
@@ -288,6 +286,8 @@ int srs_client_send(struct srs_client *client, unsigned
short command,
memcpy(p, message.data, message.size);
}
+ SRS_CLIENT_LOCK(client);
+
memset(&timeout, 0, sizeof(timeout));
timeout.tv_usec = 300;
--
2.37.2
_______________________________________________
Replicant mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/replicant