[Pidgin] #1522: UPnP timeout period is ridiculously long
Pidgin
trac at pidgin.im
Sun Jun 3 23:19:00 EDT 2007
#1522: UPnP timeout period is ridiculously long
------------------------+---------------------------------------------------
Reporter: rgovostes | Owner:
Type: defect | Status: new
Priority: minor | Milestone:
Component: libpurple | Version: 2.0.1
Resolution: | Keywords: upnp timeout file transfer oscar
Pending: 0 |
------------------------+---------------------------------------------------
Comment (by rgovostes):
I've been poring over libpurple's code for the last four hours, trying to
figure out where the hell the bug is. As it turns out, half the code in
UPnP is unused. The culprit seems to be that url_fetch_* in util.c never
times out waiting for a response. I set up a log message in
url_fetch_send_cb() to tell me when the data finishes being sent, then a
second at the top of url_fetch_recv_cb() to tell me when a reply is
received. No reply is received, thanks to my router's craptasticularity.
My cruddy solution is to add `guint tima` to the _PurpleUtilFetchUrlData
struct in util.h, then add this function to util.c :
{{{
static gboolean
purple_util_fetch_url_timeout(gpointer data) {
purple_debug_misc("util", "Timed out waiting for reply!");
PurpleUtilFetchUrlData *gfud = data;
gfud->webdata = g_realloc(gfud->webdata, gfud->len + 1);
gfud->webdata[gfud->len] = '\0';
gfud->callback(gfud, gfud->user_data, gfud->webdata, gfud->len,
NULL);
purple_util_fetch_url_cancel(gfud);
return FALSE;
}
}}}
In purple_util_fetch_url_cancel() in util.c, add
{{{
if (gfud->tima > 0)
purple_timeout_remove(gfud->tima);
}}}
and finally, to the bottom of url_fetch_send_cb() in util.c:
{{{
gfud->tima = purple_timeout_add(30000, purple_util_fetch_url_cancel,
gfud);
}}}
Obviously this should be improved upon before being submitted as a patch;
the timeout should also be in place for connecting, sending, etc. I think
that the way I have it, there's a thirty second limit for the entire
response to be received, which probably isn't optimal.
With these changes, I've reduced the delay in sending a file to around one
minute (30 seconds each for adding a port then deleting it).
--
Ticket URL: <http://developer.pidgin.im/ticket/1522#comment:1>
Pidgin <http://pidgin.im>
Pidgin
More information about the Tracker
mailing list