@@ -1830,8 +1830,10 @@ static int
parse_open(struct vchiq_state *state, struct vchiq_header *header)
{
const struct vchiq_open_payload *payload;
+ struct vchiq_openack_payload ack_payload;
struct vchiq_service *service = NULL;
int msgid, size;
+ int openack_id;
unsigned int localport, remoteport, fourcc;
short version, version_min;
@@ -1866,34 +1868,36 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header)
}
service->peer_version = version;
- if (service->srvstate == VCHIQ_SRVSTATE_LISTENING) {
- struct vchiq_openack_payload ack_payload = {
- service->version
- };
- int openack_id = MAKE_OPENACK(service->localport, remoteport);
+ if (service->srvstate != VCHIQ_SRVSTATE_LISTENING)
+ goto done;
- if (state->version_common <
- VCHIQ_VERSION_SYNCHRONOUS_MODE)
- service->sync = 0;
+ ack_payload.version = service->version;
+ openack_id = MAKE_OPENACK(service->localport, remoteport);
- /* Acknowledge the OPEN */
- if (service->sync) {
- if (queue_message_sync(state, NULL, openack_id, memcpy_copy_callback,
- &ack_payload, sizeof(ack_payload)) == -EAGAIN)
- goto bail_not_ready;
+ if (state->version_common < VCHIQ_VERSION_SYNCHRONOUS_MODE)
+ service->sync = 0;
- /* The service is now open */
- set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC);
- } else {
- if (queue_message(state, NULL, openack_id, memcpy_copy_callback,
- &ack_payload, sizeof(ack_payload), 0) == -EINTR)
- goto bail_not_ready;
+ /* Acknowledge the OPEN */
+ if (service->sync) {
+ if (queue_message_sync(state, NULL, openack_id,
+ memcpy_copy_callback,
+ &ack_payload,
+ sizeof(ack_payload)) == -EAGAIN)
+ goto bail_not_ready;
- /* The service is now open */
- set_service_state(service, VCHIQ_SRVSTATE_OPEN);
- }
+ /* The service is now open */
+ set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC);
+ } else {
+ if (queue_message(state, NULL, openack_id,
+ memcpy_copy_callback, &ack_payload,
+ sizeof(ack_payload), 0) == -EINTR)
+ goto bail_not_ready;
+
+ /* The service is now open */
+ set_service_state(service, VCHIQ_SRVSTATE_OPEN);
}
+done:
/* Success - the message has been dealt with */
vchiq_service_put(service);
return 1;