comparison src/protocols/yahoo/yahoo_filexfer.c @ 9798:255596f41014

[gaim-migrate @ 10666] This is patch number 1002252 by Joe Shaw. He writes: If you start a file transfer with a yahoo user and then unplug the network, wait a couple minutes, and plug it back in, a minute or so later the gaim UI will completely freeze, eventually consume all your memory and crash. This is because ft.c:transfer_cb() does not correctly handle the case in which both READ and WRITE conditions are coming in, and because the yahoo_xfer_read() and yahoo_xfer_write() functions are incorrectly returning 0 on errors instead of -1. Since transfer_cb() is getting both conditions, it only checks READ first and gets back 0 bytes (because the connection has been hung up). 0 is not explicitly handled, so nothing is done and we get ourselves into an infinite loop. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sat, 21 Aug 2004 02:02:25 +0000
parents d27156c9c876
children 8490f2e292a6
comparison
equal deleted inserted replaced
9797:62eb9fe24692 9798:255596f41014
251 251
252 len = read(xfer->fd, buf, sizeof(buf)); 252 len = read(xfer->fd, buf, sizeof(buf));
253 253
254 if (len <= 0) { 254 if (len <= 0) {
255 if ((gaim_xfer_get_size(xfer) > 0) && 255 if ((gaim_xfer_get_size(xfer) > 0) &&
256 (gaim_xfer_get_bytes_sent(xfer) >= gaim_xfer_get_size(xfer))) 256 (gaim_xfer_get_bytes_sent(xfer) >= gaim_xfer_get_size(xfer))) {
257 gaim_xfer_set_completed(xfer, TRUE); 257 gaim_xfer_set_completed(xfer, TRUE);
258 else 258 return 0;
259 gaim_xfer_cancel_remote(xfer); 259 } else
260 return 0; 260 return -1;
261 } 261 }
262 262
263 263
264 if (!xd->started) { 264 if (!xd->started) {
265 xd->rxqueue = g_realloc(xd->rxqueue, len + xd->rxlen); 265 xd->rxqueue = g_realloc(xd->rxqueue, len + xd->rxlen);
300 { 300 {
301 ssize_t len; 301 ssize_t len;
302 struct yahoo_xfer_data *xd = xfer->data; 302 struct yahoo_xfer_data *xd = xfer->data;
303 303
304 if (!xd) 304 if (!xd)
305 return 0; 305 return -1;
306 306
307 if (gaim_xfer_get_type(xfer) != GAIM_XFER_SEND) { 307 if (gaim_xfer_get_type(xfer) != GAIM_XFER_SEND) {
308 return 0; 308 return -1;
309 } 309 }
310 310
311 len = write(xfer->fd, buffer, size); 311 len = write(xfer->fd, buffer, size);
312 312
313 if (len == -1) { 313 if (len == -1) {
314 if (gaim_xfer_get_bytes_sent(xfer) >= gaim_xfer_get_size(xfer)) 314 if (gaim_xfer_get_bytes_sent(xfer) >= gaim_xfer_get_size(xfer))
315 gaim_xfer_set_completed(xfer, TRUE); 315 gaim_xfer_set_completed(xfer, TRUE);
316 if ((errno != EAGAIN) && (errno != EINTR)) 316 if ((errno != EAGAIN) && (errno != EINTR))
317 gaim_xfer_cancel_remote(xfer); 317 return -1;
318 return 0; 318 return 0;
319 } 319 }
320 320
321 if ((gaim_xfer_get_bytes_sent(xfer) + len) >= gaim_xfer_get_size(xfer)) 321 if ((gaim_xfer_get_bytes_sent(xfer) + len) >= gaim_xfer_get_size(xfer))
322 gaim_xfer_set_completed(xfer, TRUE); 322 gaim_xfer_set_completed(xfer, TRUE);