[PATCH] serial-port: turn open_count assertion in mm_serial_port_close into simple return

Aleksander Morgado aleksander at aleksander.es
Sun Jan 12 03:04:17 PST 2014


On 12/01/14 03:36, Ben Chan wrote:
> The following call sequence illustrate the problem.
> 
> 1. mm_serial_port_close_force calls mm_serial_port_close.
> 2. Before mm_serial_port_close_force even finishes and returns, it
> invokes a response callback of a command in priv->queue
> 3. The response callback completes and frees the associated context,
> which calls mm_serial_port_close_force again
> 4. The assertion is caused by the second call to mm_serial_port_close_force.

Yeah, so during the first port_close_force() we do need to clear the
command queue, and that triggers completion of AT commands which in turn
try to close their port open request...

One option would be to have all the MMQueueData items be completed in an
idle, so that when they are really completed the port was already marked
as forced_close. I know it's probably too much just to handle this case,
but I also think it's important to warn about the incorrect open/close
counts; and the idle completion is actually a good idea as we avoid
chaining up normal close()s within the forced_close() call.

I'd suggest to wait until we release 1.2, because after that I'd like to
merge the 'aleksander/ports-refactor' branch, and in that branch the
change needed to have the MMQueueData item (named CommandContext in the
branch) completed in idle is just a rename of
g_simple_async_result_complete() to
g_simple_async_result_complete_in_idle().

-- 
Aleksander


More information about the ModemManager-devel mailing list