mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	protocol-native: keep reading messages after error
There is no reason to exit the message loop after receiveing an error, we can just process the next message.
This commit is contained in:
		
							parent
							
								
									c9264c9ce1
								
							
						
					
					
						commit
						f894a51eab
					
				
					 1 changed files with 14 additions and 15 deletions
				
			
		| 
						 | 
					@ -222,14 +222,18 @@ process_messages(struct client_data *data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		marshal = pw_resource_get_marshal(resource);
 | 
							marshal = pw_resource_get_marshal(resource);
 | 
				
			||||||
		if (marshal == NULL || msg->opcode >= marshal->n_client_methods) {
 | 
							if (marshal == NULL || msg->opcode >= marshal->n_client_methods) {
 | 
				
			||||||
			res = -ENOSYS;
 | 
								pw_resource_errorf_id(resource, msg->id,
 | 
				
			||||||
			goto invalid_method;
 | 
										-ENOSYS, "invalid method id:%u op:%u",
 | 
				
			||||||
 | 
										msg->id, msg->opcode);
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		demarshal = marshal->server_demarshal;
 | 
							demarshal = marshal->server_demarshal;
 | 
				
			||||||
		if (!demarshal[msg->opcode].func) {
 | 
							if (!demarshal[msg->opcode].func) {
 | 
				
			||||||
			res = -ENOTSUP;
 | 
								pw_resource_errorf_id(resource, msg->id,
 | 
				
			||||||
			goto invalid_message;
 | 
										-ENOTSUP, "function not supported id:%u op:%u",
 | 
				
			||||||
 | 
										msg->id, msg->opcode);
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		permissions = pw_resource_get_permissions(resource);
 | 
							permissions = pw_resource_get_permissions(resource);
 | 
				
			||||||
| 
						 | 
					@ -247,23 +251,18 @@ process_messages(struct client_data *data)
 | 
				
			||||||
		pw_protocol_native_connection_enter(conn);
 | 
							pw_protocol_native_connection_enter(conn);
 | 
				
			||||||
		res = demarshal[msg->opcode].func(resource, msg);
 | 
							res = demarshal[msg->opcode].func(resource, msg);
 | 
				
			||||||
		pw_protocol_native_connection_leave(conn);
 | 
							pw_protocol_native_connection_leave(conn);
 | 
				
			||||||
		if (res < 0)
 | 
							if (res < 0) {
 | 
				
			||||||
			goto invalid_message;
 | 
								pw_resource_errorf_id(resource, msg->id,
 | 
				
			||||||
 | 
										res, "invalid message id:%u op:%u (%s)",
 | 
				
			||||||
 | 
										msg->id, msg->opcode, spa_strerror(res));
 | 
				
			||||||
 | 
								debug_msg("*invalid message*", msg, true);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	res = 0;
 | 
						res = 0;
 | 
				
			||||||
done:
 | 
					done:
 | 
				
			||||||
	context->current_client = NULL;
 | 
						context->current_client = NULL;
 | 
				
			||||||
	return res;
 | 
						return res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
invalid_method:
 | 
					 | 
				
			||||||
	pw_resource_errorf_id(resource, msg->id, res, "invalid method id:%u op:%u",
 | 
					 | 
				
			||||||
			msg->id, msg->opcode);
 | 
					 | 
				
			||||||
	goto done;
 | 
					 | 
				
			||||||
invalid_message:
 | 
					 | 
				
			||||||
	pw_resource_errorf_id(resource, msg->id, res, "invalid message id:%u op:%u (%s)",
 | 
					 | 
				
			||||||
			msg->id, msg->opcode, spa_strerror(res));
 | 
					 | 
				
			||||||
	debug_msg("*invalid message*", msg, true);
 | 
					 | 
				
			||||||
	goto done;
 | 
					 | 
				
			||||||
error:
 | 
					error:
 | 
				
			||||||
	if (client->core_resource)
 | 
						if (client->core_resource)
 | 
				
			||||||
		pw_resource_errorf(client->core_resource, res, "client error %d (%s)",
 | 
							pw_resource_errorf(client->core_resource, res, "client error %d (%s)",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue