* [PATCH] sim: Make SPN change atomic for consumers
@ 2012-01-23 9:41 Oleg Zhurakivskyy
2012-01-23 16:58 ` Denis Kenzior
0 siblings, 1 reply; 2+ messages in thread
From: Oleg Zhurakivskyy @ 2012-01-23 9:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2286 bytes --]
Due to new spn watch semantics, ofono_sim_get_spn()
will report the absence of SPN while reading it,
which is probably incorrect.
---
src/sim.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/sim.c b/src/sim.c
index e4bd378..703e0db 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -2398,7 +2398,14 @@ static inline void spn_watches_notify(struct ofono_sim *sim)
static void sim_spn_set(struct ofono_sim *sim, const void *data, int length,
const unsigned char *dc)
{
- char *spn;
+ g_free(sim->spn);
+ sim->spn = NULL;
+
+ g_free(sim->spn_dc);
+ sim->spn_dc = NULL;
+
+ if (data == NULL)
+ goto notify;
/*
* TS 31.102 says:
@@ -2416,19 +2423,18 @@ static void sim_spn_set(struct ofono_sim *sim, const void *data, int length,
* itself which is not there either. 11.11 contains the same
* paragraph as 51.101 and has an Annex B which we implement.
*/
- spn = sim_string_to_utf8(data, length);
- if (spn == NULL) {
+ sim->spn = sim_string_to_utf8(data, length);
+ if (sim->spn == NULL) {
ofono_error("EFspn read successfully, but couldn't parse");
goto notify;
}
- if (strlen(spn) == 0) {
- g_free(spn);
+ if (strlen(sim->spn) == 0) {
+ g_free(sim->spn);
+ sim->spn = NULL;
goto notify;
}
- sim->spn = spn;
-
if (dc)
sim->spn_dc = g_memdup(dc, 1);
@@ -2443,7 +2449,7 @@ static void sim_cphs_spn_short_read_cb(int ok, int length, int record,
struct ofono_sim *sim = user_data;
if (!ok) {
- spn_watches_notify(sim);
+ sim_spn_set(sim, NULL, 0, NULL);
return;
}
@@ -2464,7 +2470,7 @@ static void sim_cphs_spn_read_cb(int ok, int length, int record,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
sim_cphs_spn_short_read_cb, sim);
else
- spn_watches_notify(sim);
+ sim_spn_set(sim, NULL, 0, NULL);
return;
}
@@ -2496,12 +2502,6 @@ static void sim_spn_changed(int id, void *userdata)
if (sim->flags & SIM_FLAG_READING_SPN)
return;
- g_free(sim->spn);
- sim->spn = NULL;
-
- g_free(sim->spn_dc);
- sim->spn_dc = NULL;
-
sim->flags |= SIM_FLAG_READING_SPN;
ofono_sim_read(sim->context, SIM_EFSPN_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
--
1.7.5.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] sim: Make SPN change atomic for consumers
2012-01-23 9:41 [PATCH] sim: Make SPN change atomic for consumers Oleg Zhurakivskyy
@ 2012-01-23 16:58 ` Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2012-01-23 16:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 374 bytes --]
Hi Oleg,
On 01/23/2012 03:41 AM, Oleg Zhurakivskyy wrote:
> Due to new spn watch semantics, ofono_sim_get_spn()
> will report the absence of SPN while reading it,
> which is probably incorrect.
> ---
> src/sim.c | 30 +++++++++++++++---------------
> 1 files changed, 15 insertions(+), 15 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-23 16:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-23 9:41 [PATCH] sim: Make SPN change atomic for consumers Oleg Zhurakivskyy
2012-01-23 16:58 ` Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.