[PATCH 0/3] Important DST bug-fix

0 views
Skip to first unread message

Felipe Contreras

unread,
May 23, 2010, 8:01:54 PM5/23/10
to msn-...@googlegroups.com, Felipe Contreras
Hi,

These are to fix bug #262, which caused offline messages to trigger a loop of
auth requests, but only when Daylight Savings Time is on!

I'll try to make a 0.1.1 release soon to include these.

Felipe Contreras (3):
oim: trivial cleanups and reorganization
Fix date parsing for DST
tests: add tests for DST date parsing

pn_oim.c | 37 +++++++++++++++++++------------------
pn_util.c | 2 +-
tests/util.c | 2 ++
3 files changed, 22 insertions(+), 19 deletions(-)

--
You received this message because you are subscribed to the Google Groups "msn-pecan" group.
To post to this group, send email to msn-...@googlegroups.com.
To unsubscribe from this group, send email to msn-pecan+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/msn-pecan?hl=en.

Felipe Contreras

unread,
May 23, 2010, 8:01:55 PM5/23/10
to msn-...@googlegroups.com, Felipe Contreras
No functional changes.

Signed-off-by: Felipe Contreras <felipe.c...@gmail.com>
---
pn_oim.c | 35 ++++++++++++++++++-----------------
1 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/pn_oim.c b/pn_oim.c
index 5c996be..112cafc 100644
--- a/pn_oim.c
+++ b/pn_oim.c
@@ -502,6 +502,9 @@ open_cb (PnNode *conn,

pn_log ("begin");

+ g_signal_handler_disconnect (conn, oim_request->open_sig_handler);
+ oim_request->open_sig_handler = 0;
+
if (oim_request->type == PN_RECEIVE_OIM)
send_receive_request (conn, oim_request);
else if (oim_request->type == PN_DELETE_OIM)
@@ -511,9 +514,6 @@ open_cb (PnNode *conn,
else
send_auth_request (conn, oim_request);

- g_signal_handler_disconnect (conn, oim_request->open_sig_handler);
- oim_request->open_sig_handler = 0;
-
pn_log ("end");
}

@@ -698,7 +698,7 @@ parse_expiration_time (const char *str)
tm.tm_min = min;
tm.tm_hour = hour;
tm.tm_mday = d;
- tm.tm_mon = m-1;
+ tm.tm_mon = m - 1;
tm.tm_year = y - 1900;
tm.tm_isdst = -1;

@@ -736,12 +736,14 @@ process_body_auth (OimRequest *oim_request,
if (cur)
{
gchar *end, *expires;
+ time_t t;

cur = strstr (cur, "<wsu:Expires>") + 13;
end = strchr (cur, '<');
expires = g_strndup (cur, end - cur);

- oim_request->oim_session->expiration_time.messenger_msn_com = parse_expiration_time (expires);
+ t = parse_expiration_time (expires);
+ oim_request->oim_session->expiration_time.messenger_msn_com = t;

g_free (expires);
}
@@ -763,12 +765,14 @@ process_body_auth (OimRequest *oim_request,
if (cur)
{
gchar *end, *expires;
+ time_t t;

cur = strstr (cur, "<wsu:Expires>") + 13;
end = strchr (cur, '<');
expires = g_strndup (cur, end - cur);

- oim_request->oim_session->expiration_time.messengersecure_live_com = parse_expiration_time (expires);
+ t = parse_expiration_time (expires);
+ oim_request->oim_session->expiration_time.messengersecure_live_com = t;

g_free (expires);
}
@@ -855,26 +859,23 @@ oim_process_requests (PecanOimSession *oim_session)
if (oim_request->type != PN_SSO_AUTH_OIM)
{
time_t current_time = time (NULL);
+ gboolean need_auth = FALSE;

if (oim_request->type == PN_RECEIVE_OIM || oim_request->type == PN_DELETE_OIM)
{
if (current_time >= oim_session->expiration_time.messenger_msn_com)
- {
- g_queue_push_head (oim_session->request_queue,
- oim_request_new (oim_session, NULL, NULL, NULL, PN_SSO_AUTH_OIM));
-
- oim_request = g_queue_peek_head (oim_session->request_queue);
- }
+ need_auth = TRUE;
}
else if (oim_request->type == PN_SEND_OIM)
{
if (current_time >= oim_session->expiration_time.messengersecure_live_com)
- {
- g_queue_push_head (oim_session->request_queue,
- oim_request_new (oim_session, NULL, NULL, NULL, PN_SSO_AUTH_OIM));
+ need_auth = TRUE;
+ }

- oim_request = g_queue_peek_head (oim_session->request_queue);
- }
+ if (need_auth)
+ {
+ oim_request = oim_request_new (oim_session, NULL, NULL, NULL, PN_SSO_AUTH_OIM);
+ g_queue_push_head (oim_session->request_queue, oim_request);
}
}

--
1.7.1

Felipe Contreras

unread,
May 23, 2010, 8:01:56 PM5/23/10
to msn-...@googlegroups.com, Felipe Contreras, Devid Antonio Filoni
We didn't experience this problem until daylight savings time started.

Cc: Devid Antonio Filoni <devi...@gmail.com>
Signed-off-by: Felipe Contreras <felipe.c...@gmail.com>
---
pn_oim.c | 2 +-
pn_util.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pn_oim.c b/pn_oim.c
index 112cafc..7e292c1 100644
--- a/pn_oim.c
+++ b/pn_oim.c
@@ -700,7 +700,7 @@ parse_expiration_time (const char *str)
tm.tm_mday = d;
tm.tm_mon = m - 1;
tm.tm_year = y - 1900;
- tm.tm_isdst = -1;
+ tm.tm_isdst = 0;

return mktime (&tm) - timezone;
}
diff --git a/pn_util.c b/pn_util.c
index 30c59d4..02c97d4 100644
--- a/pn_util.c
+++ b/pn_util.c
@@ -968,7 +968,7 @@ pn_parse_date(const char *str)
tm.tm_mday = d;
tm.tm_mon = m;
tm.tm_year = y - 1900;
- tm.tm_isdst = -1;
+ tm.tm_isdst = 0;

return mktime (&tm) - timezone;
}
--
1.7.1

Felipe Contreras

unread,
May 23, 2010, 8:01:57 PM5/23/10
to msn-...@googlegroups.com, Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.c...@gmail.com>
---
tests/util.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tests/util.c b/tests/util.c
index 7319c23..6d0b68d 100644
--- a/tests/util.c
+++ b/tests/util.c
@@ -96,6 +96,8 @@ START_TEST (test_parse_date)
date_cmp_t a[] = {
{ "01 Jan 1970 02:00:00 0200", 0 },
{ "01 Jan 1970 11:00:00 1100", 0 },
+ { "23 Nov 2009 19:35:12 0000", 1259004912 },
+ { "23 May 2010 20:26:57 0000", 1274646417 },
};
int i;
for (i = 0; i < ARRAY_SIZE(a); i++) {
--
1.7.1
Reply all
Reply to author
Forward
0 new messages