Based on `send_message()`, retval would only be -1 if a GLE operation fails, in which case an exception has been set. Otherwise, retval will either be 1 or 0 to denote success and failure for the socket write. I don't think there's anything to fix there.

Offhand, where is `return_value` declared? I see it used by all of these functions that call `send_message()`. It looks like the GLE document gets assigned there should `send_message()` invoked `do_safe_op()`, but I don't see the link between that and the PHP return value, unless it's some global symbol for that purpose.