base-modem: new port getters and peekers
* mm_base_modem_peek_port_* () will return either a port object (no new reference), or NULL if none available. You would usually peek() a port if you're going to use it just in the current method, as there is no way to that reference to get invalid (we're single threaded). * mm_base_modem_get_port_* () will return either NEW references to valid port objects, or NULL if none available. And, you would usually get() a port, whenever you want the port object to be valid even out of the current method, for example when keeping it in the context of an async operation. Also, we need to consider that the primary AT port MAY BE NULL when you peek() or get() it. This is due to the fact that we may be releasing ports (due to device disconnection) in the middle of async operations.
This commit is contained in:
@@ -277,7 +277,7 @@ mm_base_modem_at_sequence (MMBaseModem *self,
|
||||
GError *error = NULL;
|
||||
|
||||
/* No port given, so we'll try to guess which is best */
|
||||
port = mm_base_modem_get_best_at_port (self, &error);
|
||||
port = mm_base_modem_peek_best_at_port (self, &error);
|
||||
if (!port) {
|
||||
g_assert (error != NULL);
|
||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (self),
|
||||
@@ -487,7 +487,7 @@ mm_base_modem_at_command (MMBaseModem *self,
|
||||
GError *error = NULL;
|
||||
|
||||
/* No port given, so we'll try to guess which is best */
|
||||
port = mm_base_modem_get_best_at_port (self, &error);
|
||||
port = mm_base_modem_peek_best_at_port (self, &error);
|
||||
if (!port) {
|
||||
g_assert (error != NULL);
|
||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (self),
|
||||
@@ -536,7 +536,7 @@ mm_base_modem_at_command_ignore_reply (MMBaseModem *self,
|
||||
MMAtSerialPort *port;
|
||||
|
||||
/* No port given, so we'll try to guess which is best */
|
||||
port = mm_base_modem_get_best_at_port (self, NULL);
|
||||
port = mm_base_modem_peek_best_at_port (self, NULL);
|
||||
if (!port)
|
||||
/* No valid port, and we ignore replies, so just exit. */
|
||||
return;
|
||||
|
Reference in New Issue
Block a user