mike-jumper commented on a change in pull request #228:
URL: https://github.com/apache/guacamole-server/pull/228#discussion_r448549971



##########
File path: src/libguac/client.c
##########
@@ -478,6 +478,29 @@ int guac_client_load_plugin(guac_client* client, const 
char* protocol) {
 
 }
 
+int guac_client_owner_send_required(guac_client* client, const char** 
required) {
+
+    /* Don't send require instruction if client does not support it. */
+    if (!guac_client_supports_require(client))
+        return -1;
+    
+    int retval;
+
+    pthread_rwlock_rdlock(&(client->__users_lock));
+
+    /* Invoke callback with current owner */
+    retval = guac_protocol_send_required(client->__owner->socket, required);
+    
+    /* Flush the socket */
+    guac_socket_flush(client->__owner->socket);
+
+    pthread_rwlock_unlock(&(client->__users_lock));

Review comment:
       Yep - there's a standard C99 way to losslessly transform between `int` 
and ` void*` and back: `intptr_t`, provided by `stdint.h`.
   
   Here's an example of `int` to `void*`:
   
   
https://github.com/apache/guacamole-server/blob/c10ceab7e80f9d6eae9ad98254bf97f41a0de112/src/guaclog/keydef.c#L166
   
   And here's an example of `void*` to `int`:
   
   
https://github.com/apache/guacamole-server/blob/c10ceab7e80f9d6eae9ad98254bf97f41a0de112/src/guaclog/keydef.c#L143
   
   If `intptr_t` weren't a possibility, the next option would be to pass 
everything that the callback needs within a `struct`, including a location to 
store what would otherwise be its return value.




----------------------------------------------------------------
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:
[email protected]


Reply via email to