* ftpfs.c (linear_abort): Add a timeout after which a reconnect

is performed instead of further fetching of the remaining data.
This commit is contained in:
Pavel Roskin 2002-10-07 17:56:15 +00:00
parent 7ec962a1fb
commit 604950704a
2 changed files with 29 additions and 11 deletions

View File

@ -1,3 +1,8 @@
2002-10-07 Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
* ftpfs.c (linear_abort): Add a timeout after which a reconnect
is performed instead of further fetching of the remaining data.
2002-10-07 Pavel Roskin <proski@gnu.org>
* direntry.c (vfs_s_resolve_symlink): Use g_snprintf() instead

View File

@ -979,6 +979,7 @@ open_data_connection (vfs *me, vfs_s_super *super, char *cmd, char *remote,
return data;
}
#define ABORT_TIMEOUT 5
static void
linear_abort (vfs *me, vfs_s_fh *fh)
{
@ -990,24 +991,36 @@ linear_abort (vfs *me, vfs_s_fh *fh)
FH_SOCK = -1;
SUP.control_connection_buzy = 0;
print_vfs_message(_("ftpfs: aborting transfer."));
if (send(SUP.sock, ipbuf, sizeof(ipbuf), MSG_OOB) != sizeof(ipbuf)) {
print_vfs_message(_("ftpfs: abort error: %s"), unix_error_string(errno));
print_vfs_message (_("ftpfs: aborting transfer."));
if (send (SUP.sock, ipbuf, sizeof (ipbuf), MSG_OOB) != sizeof (ipbuf)) {
print_vfs_message (_("ftpfs: abort error: %s"),
unix_error_string (errno));
return;
}
if (command(me, super, NONE, "%cABOR", DM) != COMPLETE){
if (command (me, super, NONE, "%cABOR", DM) != COMPLETE) {
print_vfs_message (_("ftpfs: abort failed"));
return;
}
if (dsock != -1) {
FD_ZERO(&mask);
FD_SET(dsock, &mask);
if (select(dsock + 1, &mask, NULL, NULL, NULL) > 0)
while (read(dsock, buf, sizeof(buf)) > 0);
FD_ZERO (&mask);
FD_SET (dsock, &mask);
if (select (dsock + 1, &mask, NULL, NULL, NULL) > 0) {
struct timeval start_tim, tim;
gettimeofday (&start_tim, NULL);
/* flush the remaining data */
while (read (dsock, buf, sizeof (buf)) > 0) {
gettimeofday (&tim, NULL);
if (tim.tv_sec > start_tim.tv_sec + ABORT_TIMEOUT) {
/* server keeps sending, drop the connection and reconnect */
reconnect (me, super);
return;
}
}
}
}
if ((get_reply(me, SUP.sock, NULL, 0) == TRANSIENT) && (code == 426))
get_reply(me, SUP.sock, NULL, 0);
if ((get_reply (me, SUP.sock, NULL, 0) == TRANSIENT) && (code == 426))
get_reply (me, SUP.sock, NULL, 0);
}
#if 0