mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-19 21:28:50 +00:00
ipc: Fix in_handles handling by syncing with the server
This commit is contained in:
parent
a41c1ce1c5
commit
9c490127bb
|
@ -135,6 +135,8 @@ def generate_client_c(file, p):
|
||||||
f.write("\tstruct ipc_" + call.name + "_reply _reply;\n")
|
f.write("\tstruct ipc_" + call.name + "_reply _reply;\n")
|
||||||
else:
|
else:
|
||||||
f.write("\tstruct ipc_result_reply _reply = {0};\n")
|
f.write("\tstruct ipc_result_reply _reply = {0};\n")
|
||||||
|
if call.in_handles:
|
||||||
|
f.write("\tstruct ipc_result_reply _sync = {0};\n")
|
||||||
|
|
||||||
f.write("""
|
f.write("""
|
||||||
\t// Other threads must not read/write the fd while we wait for reply
|
\t// Other threads must not read/write the fd while we wait for reply
|
||||||
|
@ -151,9 +153,25 @@ def generate_client_c(file, p):
|
||||||
write_result_handler(f, 'ret', cleanup, indent="\t")
|
write_result_handler(f, 'ret', cleanup, indent="\t")
|
||||||
|
|
||||||
if call.in_handles:
|
if call.in_handles:
|
||||||
|
f.write("\n\t// Send our handles separately\n")
|
||||||
|
f.write("\n\t// Wait for server sync")
|
||||||
|
# Must sync with the server so it's expecting the next message.
|
||||||
|
write_invocation(
|
||||||
|
f,
|
||||||
|
'ret',
|
||||||
|
'ipc_receive',
|
||||||
|
(
|
||||||
|
'&ipc_c->imc',
|
||||||
|
'&_sync',
|
||||||
|
'sizeof(_sync)'
|
||||||
|
),
|
||||||
|
indent="\t"
|
||||||
|
)
|
||||||
|
f.write(';')
|
||||||
|
write_result_handler(f, 'ret', cleanup, indent="\t")
|
||||||
|
|
||||||
# Must send these in a second message
|
# Must send these in a second message
|
||||||
# since the server doesn't know how many to expect.
|
# since the server doesn't know how many to expect.
|
||||||
f.write("\n\t// Send our handles separately\n")
|
|
||||||
f.write("\n\t// We need this message data as filler only\n")
|
f.write("\n\t// We need this message data as filler only\n")
|
||||||
f.write("\tstruct ipc_command_msg _handle_msg = {\n")
|
f.write("\tstruct ipc_command_msg _handle_msg = {\n")
|
||||||
f.write("\t .cmd = " + str(call.id) + ",\n")
|
f.write("\t .cmd = " + str(call.id) + ",\n")
|
||||||
|
@ -254,6 +272,8 @@ ipc_dispatch(volatile struct ipc_client_state *ics, ipc_command_t *ipc_command)
|
||||||
f.write("\t\tstruct ipc_%s_reply reply = {0};\n" % call.name)
|
f.write("\t\tstruct ipc_%s_reply reply = {0};\n" % call.name)
|
||||||
else:
|
else:
|
||||||
f.write("\t\tstruct ipc_result_reply reply = {0};\n")
|
f.write("\t\tstruct ipc_result_reply reply = {0};\n")
|
||||||
|
if call.in_handles:
|
||||||
|
f.write("\tstruct ipc_result_reply _sync = {XRT_SUCCESS};\n")
|
||||||
if call.out_handles:
|
if call.out_handles:
|
||||||
f.write("\t\t%s %s[MAX_HANDLES] = {0};\n" % (
|
f.write("\t\t%s %s[MAX_HANDLES] = {0};\n" % (
|
||||||
call.out_handles.typename, call.out_handles.arg_name))
|
call.out_handles.typename, call.out_handles.arg_name))
|
||||||
|
@ -267,6 +287,22 @@ ipc_dispatch(volatile struct ipc_client_state *ics, ipc_command_t *ipc_command)
|
||||||
f.write("\t\t%s in_%s[MAX_HANDLES] = {0};\n" % (
|
f.write("\t\t%s in_%s[MAX_HANDLES] = {0};\n" % (
|
||||||
call.in_handles.typename, call.in_handles.arg_name))
|
call.in_handles.typename, call.in_handles.arg_name))
|
||||||
f.write("\t\tstruct ipc_command_msg _handle_msg = {0};\n")
|
f.write("\t\tstruct ipc_command_msg _handle_msg = {0};\n")
|
||||||
|
|
||||||
|
# Let the client know we are ready to receive the handles.
|
||||||
|
write_invocation(
|
||||||
|
f,
|
||||||
|
'xrt_result_t sync_result',
|
||||||
|
'ipc_send',
|
||||||
|
(
|
||||||
|
"(struct ipc_message_channel *)&ics->imc",
|
||||||
|
"&_sync",
|
||||||
|
"sizeof(_sync)"
|
||||||
|
),
|
||||||
|
indent="\t\t"
|
||||||
|
)
|
||||||
|
f.write(";")
|
||||||
|
write_result_handler(f, "sync_result",
|
||||||
|
indent="\t\t")
|
||||||
write_invocation(
|
write_invocation(
|
||||||
f,
|
f,
|
||||||
'xrt_result_t receive_handle_result',
|
'xrt_result_t receive_handle_result',
|
||||||
|
|
Loading…
Reference in a new issue