Mercurial > pidgin.yaz
changeset 5298:857106f8f971
[gaim-migrate @ 5670]
don't let CTCP pings segfault gaim ;-)
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Mon, 05 May 2003 20:57:12 +0000 |
parents | d4c9c5491812 |
children | ee2b7e4de04e |
files | src/protocols/irc/irc.c |
diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/irc/irc.c Mon May 05 20:38:49 2003 +0000 +++ b/src/protocols/irc/irc.c Mon May 05 20:57:12 2003 +0000 @@ -1683,16 +1683,17 @@ if (p) *p = 0; - vector = g_strsplit(word_eol[5], " ", 2); + vector = g_strsplit(word_eol[5], ".", 2); if (gettimeofday(&now, NULL) == 0 && vector != NULL) { - if (now.tv_usec - atol(vector[1]) < 0) { + if (vector[1] && now.tv_usec - atol(vector[1]) < 0) { ping_time.tv_sec = now.tv_sec - atol(vector[0]) - 1; ping_time.tv_usec = now.tv_usec - atol(vector[1]) + 1000000; } else { ping_time.tv_sec = now.tv_sec - atol(vector[0]); - ping_time.tv_usec = now.tv_usec - atol(vector[1]); + if(vector[1]) + ping_time.tv_usec = now.tv_usec - atol(vector[1]); } g_snprintf(buf, sizeof(buf), @@ -2794,8 +2795,11 @@ irc_ctcp_ping(struct gaim_connection *gc, const char *who) { char buf[IRC_BUF_LEN]; - - g_snprintf (buf, sizeof(buf), "\001PING %ld\001", time(NULL)); + struct timeval now; + + gettimeofday(&now, NULL); + g_snprintf (buf, sizeof(buf), "\001PING %lu.%.03lu\001", now.tv_sec, + now.tv_usec/1000); irc_send_privmsg(gc, who, buf, FALSE); }